From eb79b98f2b319df35e74c0543c15b2ec1e6e72a2 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Mon, 9 Feb 2026 12:45:16 +0100 Subject: [PATCH] power saving on idle --- src/CrossPointSettings.cpp | 1 + src/main.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/CrossPointSettings.cpp b/src/CrossPointSettings.cpp index ffeef2b9..4ea59ba0 100644 --- a/src/CrossPointSettings.cpp +++ b/src/CrossPointSettings.cpp @@ -274,6 +274,7 @@ float CrossPointSettings::getReaderLineCompression() const { } unsigned long CrossPointSettings::getSleepTimeoutMs() const { + return 6UL * 60 * 60 * 1000; // TEST switch (sleepTimeout) { case SLEEP_1_MIN: return 1UL * 60 * 1000; diff --git a/src/main.cpp b/src/main.cpp index 33515bce..24bb6466 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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); + } } }