diff options
| author | Jan Hustak <coding@journey.sk> | 2024-10-20 12:01:36 +0200 |
|---|---|---|
| committer | JF <JF002@users.noreply.github.com> | 2025-11-04 21:25:31 +0100 |
| commit | db5d4704cc4a7361c80d1eab199af268364545c7 (patch) | |
| tree | 060efe2965b0984637fc8054353c1dcea5ffb622 /src/displayapp/screens/StopWatch.h | |
| parent | 74cf69bb6716657575f52e0e207ff123c6e01575 (diff) | |
StopWatch: add persistence
# Conflicts:
# src/displayapp/screens/StopWatch.h
Diffstat (limited to 'src/displayapp/screens/StopWatch.h')
| -rw-r--r-- | src/displayapp/screens/StopWatch.h | 106 |
1 files changed, 47 insertions, 59 deletions
diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h index 7256dd5b..b2e85b7a 100644 --- a/src/displayapp/screens/StopWatch.h +++ b/src/displayapp/screens/StopWatch.h @@ -3,76 +3,64 @@ #include "displayapp/screens/Screen.h" #include <lvgl/lvgl.h> -#include <FreeRTOS.h> -#include "portmacro_cmsis.h" - +#include "components/stopwatch/StopWatchController.h" #include "systemtask/SystemTask.h" #include "systemtask/WakeLock.h" -#include "displayapp/apps/Apps.h" -#include "displayapp/Controllers.h" #include "Symbols.h" -namespace Pinetime { - namespace Applications { - namespace Screens { - - enum class States { Init, Running, Halted }; - - struct TimeSeparated_t { - int hours; - int mins; - int secs; - int hundredths; - }; +namespace Pinetime::Applications { + namespace Screens { - class StopWatch : public Screen { - public: - explicit StopWatch(System::SystemTask& systemTask); - ~StopWatch() override; - void Refresh() override; - - void playPauseBtnEventHandler(); - void stopLapBtnEventHandler(); - bool OnButtonPushed() override; + struct TimeSeparated { + int hours; + int mins; + int secs; + int hundredths; + }; - private: - void SetInterfacePaused(); - void SetInterfaceRunning(); - void SetInterfaceStopped(); + class StopWatch : public Screen { + public: + explicit StopWatch(System::SystemTask& systemTask, + Controllers::StopWatchController& stopWatchController); + ~StopWatch() override; + void Refresh() override; - void Reset(); - void Start(); - void Pause(); + void PlayPauseBtnEventHandler(); + void StopLapBtnEventHandler(); + bool OnButtonPushed() override; - Pinetime::System::WakeLock wakeLock; - States currentState = States::Init; - TickType_t startTime; - TickType_t oldTimeElapsed = 0; - TickType_t blinkTime = 0; - static constexpr int maxLapCount = 20; - TickType_t laps[maxLapCount + 1]; - static constexpr int displayedLaps = 2; - int lapsDone = 0; - lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap; - lv_obj_t* lapText; - bool isHoursLabelUpdated = false; + private: + void DisplayPaused(); + void DisplayStarted(); + void DisplayCleared(); - lv_task_t* taskRefresh; - }; - } + void RenderTime(); + void RenderPause(); + void RenderLaps(); - template <> - struct AppTraits<Apps::StopWatch> { - static constexpr Apps app = Apps::StopWatch; - static constexpr const char* icon = Screens::Symbols::stopWatch; + Pinetime::System::WakeLock wakeLock; + Controllers::StopWatchController& stopWatchController; + TickType_t blinkTime = 0; + static constexpr int displayedLaps = 2; + lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap; + lv_obj_t* lapText; + bool isHoursLabelUpdated = false; - static Screens::Screen* Create(AppControllers& controllers) { - return new Screens::StopWatch(*controllers.systemTask); - }; - - static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) { - return true; - }; + lv_task_t* taskRefresh; }; } + + template <> + struct AppTraits<Apps::StopWatch> { + static constexpr Apps app = Apps::StopWatch; + static constexpr const char* icon = Screens::Symbols::stopWatch; + + static Screens::Screen* Create(AppControllers& controllers) { + return new Screens::StopWatch(*controllers.systemTask, + controllers.stopWatchController); + } + static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) { + return true; + } + }; } |
