Mémorisation dernière durée en EEPROM
This commit is contained in:
parent
8cd2ee3943
commit
bc904d4f01
12
src/main.cpp
12
src/main.cpp
@ -4,6 +4,7 @@
|
|||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
#include <Adafruit_SSD1306.h>
|
#include <Adafruit_SSD1306.h>
|
||||||
#include <RotaryEncoder.h>
|
#include <RotaryEncoder.h>
|
||||||
|
#include <EEPROM.h>
|
||||||
|
|
||||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||||
#define SCREEN_HEIGHT 64 // OLED display height, 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
|
// durée par défaut en secondes
|
||||||
int count = 12;
|
int count;
|
||||||
bool statutDecompte = 0;
|
bool statutDecompte = 0;
|
||||||
unsigned long LastUpdateTimer = 0;
|
unsigned long LastUpdateTimer = 0;
|
||||||
unsigned long LastReadBP = 0;
|
unsigned long LastReadBP = 0;
|
||||||
@ -53,7 +54,12 @@ void setup() {
|
|||||||
pinMode(ENCROT_BP, INPUT);
|
pinMode(ENCROT_BP, INPUT);
|
||||||
pinMode(SORTIE_RELAIS, OUTPUT);
|
pinMode(SORTIE_RELAIS, OUTPUT);
|
||||||
digitalWrite(SORTIE_RELAIS, LOW);
|
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)
|
Wire.begin(SDA, SCL); // join i2c bus (address optional for master)
|
||||||
Serial.begin(115200); // start serial for output
|
Serial.begin(115200); // start serial for output
|
||||||
|
|
||||||
@ -129,6 +135,8 @@ void loop() {
|
|||||||
statutDecompte = !statutDecompte;
|
statutDecompte = !statutDecompte;
|
||||||
if (statutDecompte) {
|
if (statutDecompte) {
|
||||||
LastUpdateTimer = currentMillis;
|
LastUpdateTimer = currentMillis;
|
||||||
|
EEPROM.put(0, count);
|
||||||
|
EEPROM.commit();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
encoder.setPosition(count);
|
encoder.setPosition(count);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user