summaryrefslogtreecommitdiff
path: root/src/system_fsm/idle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/system_fsm/idle.cpp')
-rw-r--r--src/system_fsm/idle.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/system_fsm/idle.cpp b/src/system_fsm/idle.cpp
index b6bb2572..e28864b3 100644
--- a/src/system_fsm/idle.cpp
+++ b/src/system_fsm/idle.cpp
@@ -13,6 +13,7 @@
#include "audio_fsm.hpp"
#include "event_queue.hpp"
+#include "samd.hpp"
#include "storage.hpp"
#include "system_events.hpp"
#include "system_fsm.hpp"
@@ -40,7 +41,7 @@ void Idle::entry() {
events::Audio().Dispatch(OnIdle{});
events::Ui().Dispatch(OnIdle{});
- sIdleTimeout = xTimerCreate("idle_timeout", kTicksBeforeSleep, false, NULL,
+ sIdleTimeout = xTimerCreate("idle_timeout", kTicksBeforeSleep, true, NULL,
timer_callback);
xTimerStart(sIdleTimeout, portMAX_DELAY);
}
@@ -63,6 +64,12 @@ void Idle::react(const internal::IdleTimeout& ev) {
transit<Running>();
return;
}
+ if (sServices->samd().GetChargeStatus() !=
+ drivers::Samd::ChargeStatus::kDischarging) {
+ // Stay powered on if we're plugged in, in order to charge faster, sync
+ // files, flash updates, etc.
+ return;
+ }
ESP_LOGI(kTag, "system shutting down");
// FIXME: It would be neater to just free a bunch of our pointers, deinit the