ajustement première seconde de décompte,

reprise au temps en cours,
temps par défaut à l'allumage 12 sec
This commit is contained in:
Laurent Claude 2023-09-05 11:19:42 +02:00
parent ffa4c5b006
commit ecf8711e54

View File

@ -63,6 +63,7 @@ void setup() {
for(;;); // Don't proceed, loop forever for(;;); // Don't proceed, loop forever
} }
encoder.setPosition(count);
// Clear the buffer // Clear the buffer
display.clearDisplay(); display.clearDisplay();
@ -80,8 +81,9 @@ void loop() {
display.setTextSize(6); display.setTextSize(6);
display.setTextColor(SSD1306_WHITE); // Draw white text display.setTextColor(SSD1306_WHITE); // Draw white text
unsigned long currentMillis = millis(); unsigned long currentMillis = millis();
int newPos;
if (statutDecompte) { if (statutDecompte) { // on est en mode de compte à rebours
if (count > 0) { if (count > 0) {
if (currentMillis - LastUpdateTimer >= 1000) { if (currentMillis - LastUpdateTimer >= 1000) {
LastUpdateTimer = currentMillis; LastUpdateTimer = currentMillis;
@ -95,13 +97,19 @@ void loop() {
} }
else { else {
statutDecompte = 0; statutDecompte = 0;
count = encoder.getPosition();
display.clearDisplay();
display.setCursor(0, 20);
display.println(count);
display.display();
} }
} }
else { else { // on est en mode réglage / pause
static int pos = 0; static int pos = 0;
encoder.tick(); encoder.tick();
int newPos = encoder.getPosition(); newPos = encoder.getPosition();
if (pos != newPos) { if (pos != newPos) {
if (newPos < 0) { if (newPos < 0) {
newPos = 0; newPos = 0;
@ -119,6 +127,12 @@ void loop() {
if (digitalRead(ENCROT_BP) && (currentMillis - LastReadBP > 250)){ if (digitalRead(ENCROT_BP) && (currentMillis - LastReadBP > 250)){
LastReadBP = currentMillis; LastReadBP = currentMillis;
statutDecompte = !statutDecompte; statutDecompte = !statutDecompte;
if (statutDecompte) {
LastUpdateTimer = currentMillis;
}
else {
encoder.setPosition(count);
}
} }
digitalWrite(SORTIE_RELAIS, statutDecompte); digitalWrite(SORTIE_RELAIS, statutDecompte);