From bc904d4f01b5daa52656625f9fe9694a98458a3a Mon Sep 17 00:00:00 2001 From: Laurent Claude Date: Thu, 7 Sep 2023 12:51:38 +0200 Subject: [PATCH] =?UTF-8?q?M=C3=A9morisation=20derni=C3=A8re=20dur=C3=A9e?= =?UTF-8?q?=20en=20EEPROM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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);