From a6ab1504058304012791281f9eb42c262745888f Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 19 May 2023 21:21:27 +1000 Subject: Add tinyfsm, start converting core functions to an FSM-based event loop --- src/system_fsm/system_fsm.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/system_fsm/system_fsm.cpp (limited to 'src/system_fsm/system_fsm.cpp') diff --git a/src/system_fsm/system_fsm.cpp b/src/system_fsm/system_fsm.cpp new file mode 100644 index 00000000..c529df5e --- /dev/null +++ b/src/system_fsm/system_fsm.cpp @@ -0,0 +1,24 @@ +#include "system_fsm.hpp" +#include "system_events.hpp" + +namespace system_fsm { + +std::shared_ptr SystemState::sGpioExpander; +std::shared_ptr SystemState::sSamd; + +std::shared_ptr SystemState::sTouch; +std::shared_ptr SystemState::sBattery; +std::shared_ptr SystemState::sStorage; +std::shared_ptr SystemState::sDisplay; +std::shared_ptr SystemState::sDac; +std::shared_ptr SystemState::sDatabase; + +void SystemState::react(const FatalError& err) { + if (!is_in_state()) { + transit(); + } +} + +} // namespace system_fsm + +FSM_INITIAL_STATE(system_fsm::SystemState, system_fsm::states::Booting) -- cgit v1.2.3