diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-04-02 11:13:50 +1100 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-04-02 11:13:50 +1100 |
| commit | e20ebe7574db5aedc73f07b7bb3a0a01eae93c84 (patch) | |
| tree | 34c93ec8a80e282f3ce3e47dd60c41e46de0f8b3 /src/system_fsm/idle.cpp | |
| parent | a750af35aa6afda40aadca8f7cf8db75f41a43b2 (diff) | |
| parent | 0d0c4b2307cac8436fea7276956f293262b265ed (diff) | |
| download | tangara-fw-e20ebe7574db5aedc73f07b7bb3a0a01eae93c84.tar.gz | |
Merge branch 'main' into lua-volume
Diffstat (limited to 'src/system_fsm/idle.cpp')
| -rw-r--r-- | src/system_fsm/idle.cpp | 9 |
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 |
