power saving on idle
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user