diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-08-21 15:43:23 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-08-21 15:43:23 +1000 |
| commit | 764b01e913d0123747757e5efd3545d46e921848 (patch) | |
| tree | 76f0a1d2afb4b60818cc46fd5649938713f2f261 /src/system_fsm/include | |
| parent | 27f329a9dbf18a046ade534c9330b03e586cdb98 (diff) | |
| download | tangara-fw-764b01e913d0123747757e5efd3545d46e921848.tar.gz | |
Add idle->standby support when locked and no music
Diffstat (limited to 'src/system_fsm/include')
| -rw-r--r-- | src/system_fsm/include/system_events.hpp | 18 | ||||
| -rw-r--r-- | src/system_fsm/include/system_fsm.hpp | 24 |
2 files changed, 22 insertions, 20 deletions
diff --git a/src/system_fsm/include/system_events.hpp b/src/system_fsm/include/system_events.hpp index 87461f0b..f62da801 100644 --- a/src/system_fsm/include/system_events.hpp +++ b/src/system_fsm/include/system_events.hpp @@ -28,15 +28,7 @@ struct BootComplete : tinyfsm::Event {}; */ struct FatalError : tinyfsm::Event {}; -/* - * Sent before unmounting the system storage. Storage will not be unmounted - * until each reaction to this even has returned. FSMs should immediately cease - * their usage of storage. - * - * May be emitted either by UiState in response to user action, or by SysState - * as a part of either entering low-power standby or powering off. - */ -struct StorageUnmountRequested : tinyfsm::Event {}; +struct OnIdle : tinyfsm::Event {}; /* * Sent by SysState when the system storage has been successfully mounted. @@ -64,15 +56,11 @@ struct ChargingStatusChanged : tinyfsm::Event {}; namespace internal { -/* - * Sent when the actual unmount operation should be performed. Always dispatched - * by SysState in response to StoragePrepareToUnmount. - */ -struct ReadyToUnmount : tinyfsm::Event {}; - struct GpioInterrupt : tinyfsm::Event {}; struct SamdInterrupt : tinyfsm::Event {}; +struct IdleTimeout : tinyfsm::Event {}; + } // namespace internal } // namespace system_fsm diff --git a/src/system_fsm/include/system_fsm.hpp b/src/system_fsm/include/system_fsm.hpp index b31cc6b7..0698be9b 100644 --- a/src/system_fsm/include/system_fsm.hpp +++ b/src/system_fsm/include/system_fsm.hpp @@ -22,6 +22,9 @@ #include "tinyfsm.hpp" #include "touchwheel.hpp" +#include "freertos/FreeRTOS.h" +#include "freertos/timers.h" + #include "system_events.hpp" #include "track_queue.hpp" @@ -47,10 +50,10 @@ class SystemState : public tinyfsm::Fsm<SystemState> { virtual void react(const DisplayReady&) {} virtual void react(const BootComplete&) {} - virtual void react(const StorageUnmountRequested&) {} - virtual void react(const internal::ReadyToUnmount&) {} virtual void react(const StorageMounted&) {} virtual void react(const StorageError&) {} + virtual void react(const KeyLockChanged&) {} + virtual void react(const internal::IdleTimeout&) {} protected: static std::shared_ptr<drivers::Gpios> sGpios; @@ -95,13 +98,24 @@ class Running : public SystemState { void entry() override; void exit() override; - void react(const StorageUnmountRequested&) override; - void react(const internal::ReadyToUnmount&) override; + void react(const KeyLockChanged&) override; void react(const StorageError&) override; using SystemState::react; }; -class Unmounted : public SystemState {}; +class Idle : public SystemState { + public: + void entry() override; + void exit() override; + + void react(const KeyLockChanged&) override; + void react(const internal::IdleTimeout&) override; + + using SystemState::react; + + private: + TimerHandle_t sIdleTimeout; +}; /* * Something unrecoverably bad went wrong. Shows an error (if possible), awaits |
