mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 15:47:39 +03:00
Prevent device sleep during WiFi file transfer and OTA updates
Fixes #199 - device would auto-sleep after 10 minutes while webserver was running. Adds preventAutoSleep() method to Activity base class, allowing activities to signal they should keep the device awake.
This commit is contained in:
parent
04ad4e5aa4
commit
5c028ba106
@ -22,4 +22,5 @@ class Activity {
|
||||
virtual void onExit() { Serial.printf("[%lu] [ACT] Exiting activity: %s\n", millis(), name.c_str()); }
|
||||
virtual void loop() {}
|
||||
virtual bool skipLoopDelay() { return false; }
|
||||
virtual bool preventAutoSleep() { return false; }
|
||||
};
|
||||
|
||||
@ -70,4 +70,5 @@ class CrossPointWebServerActivity final : public ActivityWithSubactivity {
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
bool skipLoopDelay() override { return webServer && webServer->isRunning(); }
|
||||
bool preventAutoSleep() override { return webServer && webServer->isRunning(); }
|
||||
};
|
||||
|
||||
@ -41,4 +41,5 @@ class OtaUpdateActivity : public ActivityWithSubactivity {
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
bool preventAutoSleep() override { return state == CHECKING_FOR_UPDATE || state == UPDATE_IN_PROGRESS; }
|
||||
};
|
||||
|
||||
@ -316,9 +316,10 @@ void loop() {
|
||||
lastMemPrint = millis();
|
||||
}
|
||||
|
||||
// Check for any user activity (button press or release)
|
||||
// Check for any user activity (button press or release) or active background work
|
||||
static unsigned long lastActivityTime = millis();
|
||||
if (inputManager.wasAnyPressed() || inputManager.wasAnyReleased()) {
|
||||
if (inputManager.wasAnyPressed() || inputManager.wasAnyReleased() ||
|
||||
(currentActivity && currentActivity->preventAutoSleep())) {
|
||||
lastActivityTime = millis(); // Reset inactivity timer
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user