From e2607ffe6de21d6d89df7b3a2a6914bad808a05e Mon Sep 17 00:00:00 2001 From: Nicu Hodos Date: Sat, 8 Feb 2025 09:02:32 +0100 Subject: [PATCH] edge case for when threshold is smaller than timer --- include/display.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/display.h b/include/display.h index 050b335..03fb64f 100644 --- a/include/display.h +++ b/include/display.h @@ -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(); }