edge case for when threshold is smaller than timer

This commit is contained in:
Nicu Hodos 2025-02-08 09:02:32 +01:00
parent 06fd7ad3cd
commit e2607ffe6d

View File

@ -81,7 +81,7 @@ namespace Display {
int8 timer = 0, current = 0;
void (*timerCallback)(int8);
Task tDisplayTimer(SECONDS(10), 2,
Task tDisplayTimer(SECONDS(10), TASK_ONCE + 1,
[]{
if (current >= 0) {
clockDisplay.print(current, DEC);
@ -94,13 +94,17 @@ namespace Display {
return true;
},
[]{
tDisplayTimer.setIterations(TASK_ONCE + 1);
tDisplayTime.enable();
});
Task tTimer(MINUTES(1), TASK_FOREVER,
[]{
static constexpr uint8 threshold = 16;
current--;
if (current == timer) tDisplayTimer.restart();
if (current == 16) {
if (current == timer) {
if (timer <= threshold) tDisplayTimer.setIterations(TASK_FOREVER);
tDisplayTimer.restart();
} else if (current == threshold) {
tDisplayTimer.setIterations(TASK_FOREVER);
tDisplayTimer.restart();
}