LP_TIMER(500, HandleHeater); void HandleHeater() { static int currentPart = 0; static bool states[PARTS]; if (inSelectionMode) { digitalWrite(ssrPin, LOW); return; } int current = Output/100 * PARTS; int last = 0; for (int i = 1; i < PARTS; i++) { last += states[i] ? 1 : 0; if (i) { states[i-1] = states[i]; } } bool next = current >= last ? true : false; if (Output < 1) next = false; states[PARTS-1] = next; oled.setCursor(128-6*PARTS, 7); sprintf(timeBuffer, "%3d", (int)(Output)); char symbol; for (int i = 0; i < PARTS; i++) { int index = i - (PARTS - 3); symbol = index < 0 ? ' ' : timeBuffer[index]; oled.invertText(states[i]); oled.print(symbol); oled.invertText(false); } if (temperatureSensorError) { next = 0; } digitalWrite(ssrPin, next); currentPart++; if (currentPart >= PARTS) { currentPart = 0; } #ifdef PlotValues Serial.print(Setpoint); Serial.print(","); Serial.print(Input); Serial.print(","); Serial.print(Output); Serial.println(",0,100"); #endif }