From c399199bfccb5298fe4b0cf566d8e69729596ba4 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 30 Jan 2024 09:55:31 +1100 Subject: Improve handling of sd card changes during runtime - mount if an sd card is inserted - unmount if it's removed --- src/system_fsm/include/system_fsm.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/system_fsm/include/system_fsm.hpp') diff --git a/src/system_fsm/include/system_fsm.hpp b/src/system_fsm/include/system_fsm.hpp index cb733639..2db1cddc 100644 --- a/src/system_fsm/include/system_fsm.hpp +++ b/src/system_fsm/include/system_fsm.hpp @@ -59,6 +59,7 @@ class SystemState : public tinyfsm::Fsm { virtual void react(const StorageMounted&) {} virtual void react(const StorageError&) {} virtual void react(const KeyLockChanged&) {} + virtual void react(const SdDetectChanged&) {} virtual void react(const audio::PlaybackFinished&) {} virtual void react(const internal::IdleTimeout&) {} @@ -95,12 +96,22 @@ class Running : public SystemState { void exit() override; void react(const KeyLockChanged&) override; - void react(const StorageError&) override; + void react(const SdDetectChanged&) override; void react(const audio::PlaybackFinished&) override; using SystemState::react; + + private: + auto mountStorage() -> bool; + auto unmountStorage() -> void; + + bool storage_mounted_; }; +/** + * State for when the screen is off, controls locked, and music paused. Prelude + * to shutting off power completely. + */ class Idle : public SystemState { public: void entry() override; -- cgit v1.2.3