From db57a51cbbcbbb5ce6a9bcd58226821bfa0ae208 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 22 Nov 2022 18:07:23 +1100 Subject: [PATCH] Create printSleepCountdown.cpp --- .../utils/printSleepCountdown.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 source/Core/Threads/OperatingModes/utils/printSleepCountdown.cpp diff --git a/source/Core/Threads/OperatingModes/utils/printSleepCountdown.cpp b/source/Core/Threads/OperatingModes/utils/printSleepCountdown.cpp new file mode 100644 index 00000000..f883bd0d --- /dev/null +++ b/source/Core/Threads/OperatingModes/utils/printSleepCountdown.cpp @@ -0,0 +1,18 @@ +#include "OperatingModeUtilities.h" +#ifndef NO_SLEEP_MODE +void printCountdownUntilSleep(int sleepThres) { + /* + * Print seconds or minutes (if > 99 seconds) until sleep + * mode is triggered. + */ + TickType_t lastEventTime = lastButtonTime < lastMovementTime ? lastMovementTime : lastButtonTime; + TickType_t downCount = sleepThres - xTaskGetTickCount() + lastEventTime; + if (downCount > (99 * TICKS_SECOND)) { + OLED::printNumber(downCount / 60000 + 1, 2, FontStyle::SMALL); + OLED::print(SymbolMinutes, FontStyle::SMALL); + } else { + OLED::printNumber(downCount / 1000 + 1, 2, FontStyle::SMALL); + OLED::print(SymbolSeconds, FontStyle::SMALL); + } +} +#endif \ No newline at end of file