diff options
| author | mark9064 <30447455+mark9064@users.noreply.github.com> | 2024-08-22 21:24:04 +0100 |
|---|---|---|
| committer | NeroBurner <pyro4hell@gmail.com> | 2024-09-21 21:08:07 +0200 |
| commit | c3d05901a05a274f30c15b8c0640b6ecdd973ac3 (patch) | |
| tree | d63aaacce475f495670787f79019df8af6e2af7d /src/systemtask/SystemTask.h | |
| parent | b3756e45fa50ce81255dc3bb21cbce4af3254f2f (diff) | |
Refactor SystemTask state handling for resilience
State transitions now happen immediately where possible
This simplifies state management in general,
and prevents bugs such as the chime issue from occurring in the first place
Diffstat (limited to 'src/systemtask/SystemTask.h')
| -rw-r--r-- | src/systemtask/SystemTask.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index 11dea52c..339587c1 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -52,7 +52,7 @@ namespace Pinetime { namespace System { class SystemTask { public: - enum class SystemTaskState { Sleeping, Running, GoingToSleep, WakingUp }; + enum class SystemTaskState { Sleeping, Running, GoingToSleep }; SystemTask(Drivers::SpiMaster& spi, Pinetime::Drivers::SpiNorFlash& spiNorFlash, Drivers::TwiMaster& twiMaster, @@ -88,7 +88,7 @@ namespace Pinetime { }; bool IsSleeping() const { - return state == SystemTaskState::Sleeping || state == SystemTaskState::WakingUp; + return state != SystemTaskState::Running; } private: @@ -131,6 +131,7 @@ namespace Pinetime { bool fastWakeUpDone = false; void GoToRunning(); + void GoToSleep(); void UpdateMotion(); bool stepCounterMustBeReset = false; static constexpr TickType_t batteryMeasurementPeriod = pdMS_TO_TICKS(10 * 60 * 1000); |
