integrated endSequence into mainloop (instead of delay) 2

This commit is contained in:
Patrick Haßel 2025-03-13 14:08:33 +01:00
parent 241dc3c2b5
commit 15f4e4feb2

View File

@ -2,7 +2,8 @@
#include <LittleFS.h> #include <LittleFS.h>
#include "display.h" #include "display.h"
#define COUNTDOWN_END_SEQUENCE_REPEAT 2 #define COUNTDOWN_END_SEQUENCE_STEPS 5
#define COUNTDOWN_END_SEQUENCE_REPEAT 3
enum CountdownState { enum CountdownState {
CONFIG, READY, RUNNING, PAUSED, END CONFIG, READY, RUNNING, PAUSED, END
@ -64,12 +65,14 @@ void drawSequence() {
if (countdownEndSequenceLast != 0 && now - countdownEndSequenceLast < countdownEndSequenceDelay) { if (countdownEndSequenceLast != 0 && now - countdownEndSequenceLast < countdownEndSequenceDelay) {
return; return;
} }
switch (countdownEndSequenceStep % 3) { switch (countdownEndSequenceStep % COUNTDOWN_END_SEQUENCE_STEPS) {
case 0: case 0:
case 2:
drawAll(WHITE); drawAll(WHITE);
countdownEndSequenceDelay = 100; countdownEndSequenceDelay = 100;
break; break;
case 1: case 1:
case 3:
drawBlack(); drawBlack();
countdownEndSequenceDelay = 100; countdownEndSequenceDelay = 100;
break; break;
@ -80,7 +83,7 @@ void drawSequence() {
} }
countdownEndSequenceStep++; countdownEndSequenceStep++;
countdownEndSequenceLast = now; countdownEndSequenceLast = now;
if (countdownEndSequenceStep >= 3 * COUNTDOWN_END_SEQUENCE_REPEAT) { if (countdownEndSequenceStep >= COUNTDOWN_END_SEQUENCE_STEPS * COUNTDOWN_END_SEQUENCE_REPEAT) {
setState(READY); setState(READY);
} }
} }