diff --git a/src/main.cpp b/src/main.cpp index c788fa9..1b0d2e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels @@ -27,7 +28,7 @@ RotaryEncoder encoder(ENCROT_A, ENCROT_B, RotaryEncoder::LatchMode::TWO03); // durée par défaut en secondes -int count = 12; +int count; bool statutDecompte = 0; unsigned long LastUpdateTimer = 0; unsigned long LastReadBP = 0; @@ -53,7 +54,12 @@ void setup() { pinMode(ENCROT_BP, INPUT); pinMode(SORTIE_RELAIS, OUTPUT); digitalWrite(SORTIE_RELAIS, LOW); - + + //Init EEPROM + EEPROM.begin(1); + EEPROM.get(0, count); + + //Init I2C Wire.begin(SDA, SCL); // join i2c bus (address optional for master) Serial.begin(115200); // start serial for output @@ -129,6 +135,8 @@ void loop() { statutDecompte = !statutDecompte; if (statutDecompte) { LastUpdateTimer = currentMillis; + EEPROM.put(0, count); + EEPROM.commit(); } else { encoder.setPosition(count);