#include <U8x8lib.h>
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);
// U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8();
uint8_t state = 1; // current state (start in last state == default == Datum)
uint32_t previousMillis = 1; // time management
constexpr uint32_t interval = 1500; // default periode between steps
void setup()
{
Serial.begin(115200);
Serial.println("Setup");
// OLED
u8x8.begin();
u8x8.setFont(u8x8_font_7x14_1x2_f);
}
void loop()
{
// Serial.println("loop");
OLED();
}
void showCase(char* text) {
u8x8.clear();
u8x8.setCursor(1, 4);
u8x8.print(text);
}
void OLED()
{
// Serial.println("OLED");
switch (state)
{
case 0: // Kalenderwoche // wenn wir in Schritt 0 sind
if (millis() - previousMillis >= interval) // und das Intervall abgelaufen ist
{
previousMillis = millis();
// previousMillis += interval; // merken wir uns die Zeit
state++; // drehen den Status weiter
Serial.println("case 0"); // und führen ab hier eine Aktion aus
showCase("Case: 0");
}
break;
case 1 : // Temperatur
if (millis() - previousMillis >= interval)
{
previousMillis = millis();
// previousMillis += interval;
state++;
Serial.println("case 1");
showCase("Case: 1");
}
break;
case 2 : // Luftfeuchte
if (millis() - previousMillis >= interval)
{
previousMillis = millis();
// previousMillis += interval;
state++;
Serial.println("case 2");
showCase("Case: 2");
}
break;
case 3 : // Druck
if (millis() - previousMillis >= interval)
{
previousMillis = millis();
// previousMillis += interval;
state++;
Serial.println("case 3");
showCase("Case: 3");
}
break;
default : // Datum
if (millis() - previousMillis >= interval)
{
previousMillis = millis();
// previousMillis += interval;
state = 0;
Serial.println("case default");
showCase("Case: default");
}
break;
}
}