power saving on idle

This commit is contained in:
Xuan Son Nguyen
2026-02-09 12:45:16 +01:00
parent 9b04c2ec76
commit eb79b98f2b
2 changed files with 9 additions and 1 deletions

View File

@@ -274,6 +274,7 @@ float CrossPointSettings::getReaderLineCompression() const {
} }
unsigned long CrossPointSettings::getSleepTimeoutMs() const { unsigned long CrossPointSettings::getSleepTimeoutMs() const {
return 6UL * 60 * 60 * 1000; // TEST
switch (sleepTimeout) { switch (sleepTimeout) {
case SLEEP_1_MIN: case SLEEP_1_MIN:
return 1UL * 60 * 1000; return 1UL * 60 * 1000;

View File

@@ -408,6 +408,13 @@ void loop() {
if (currentActivity && currentActivity->skipLoopDelay()) { if (currentActivity && currentActivity->skipLoopDelay()) {
yield(); // Give FreeRTOS a chance to run tasks, but return immediately yield(); // Give FreeRTOS a chance to run tasks, but return immediately
} else { } else {
delay(10); // Normal delay when no activity requires fast response static constexpr unsigned long IDLE_POWER_SAVING_MS = 10000;
if (millis() - lastActivityTime >= IDLE_POWER_SAVING_MS) {
// If we've been inactive for a while, increase the delay to save power
delay(50);
} else {
// Short delay to prevent tight loop while still being responsive
delay(10);
}
} }
} }