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

@@ -408,6 +408,13 @@ void loop() {
if (currentActivity && currentActivity->skipLoopDelay()) {
yield(); // Give FreeRTOS a chance to run tasks, but return immediately
} 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);
}
}
}