From 8e5519711dabd9e871fa913bf0071a74d6a7b8ca Mon Sep 17 00:00:00 2001 From: JustScott Date: Tue, 20 Feb 2024 16:05:31 -0600 Subject: [PATCH] Pass the timer as const Doing this matches the other Controllers, which are also passed as const to the StatusIcons. --- src/components/timer/Timer.cpp | 4 ++-- src/components/timer/Timer.h | 4 ++-- src/displayapp/screens/WatchFaceDigital.cpp | 5 ++--- src/displayapp/screens/WatchFaceDigital.h | 9 ++++----- src/displayapp/screens/settings/QuickSettings.cpp | 2 +- src/displayapp/screens/settings/QuickSettings.h | 2 +- src/displayapp/widgets/StatusIcons.cpp | 2 +- src/displayapp/widgets/StatusIcons.h | 4 ++-- 8 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/components/timer/Timer.cpp b/src/components/timer/Timer.cpp index 279178cd33..935d41e288 100644 --- a/src/components/timer/Timer.cpp +++ b/src/components/timer/Timer.cpp @@ -11,7 +11,7 @@ void Timer::StartTimer(std::chrono::milliseconds duration) { xTimerStart(timer, 0); } -std::chrono::milliseconds Timer::GetTimeRemaining() { +std::chrono::milliseconds Timer::GetTimeRemaining() const { if (IsRunning()) { TickType_t remainingTime = xTimerGetExpiryTime(timer) - xTaskGetTickCount(); return std::chrono::milliseconds(remainingTime * 1000 / configTICK_RATE_HZ); @@ -23,6 +23,6 @@ void Timer::StopTimer() { xTimerStop(timer, 0); } -bool Timer::IsRunning() { +bool Timer::IsRunning() const { return (xTimerIsTimerActive(timer) == pdTRUE); } diff --git a/src/components/timer/Timer.h b/src/components/timer/Timer.h index 2469666f4f..406ae03327 100644 --- a/src/components/timer/Timer.h +++ b/src/components/timer/Timer.h @@ -15,9 +15,9 @@ namespace Pinetime { void StopTimer(); - std::chrono::milliseconds GetTimeRemaining(); + std::chrono::milliseconds GetTimeRemaining() const; - bool IsRunning(); + bool IsRunning() const; private: TimerHandle_t timer; diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 89df921086..e4bb80c6ac 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -18,12 +18,12 @@ using namespace Pinetime::Applications::Screens; WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController, const Controllers::Battery& batteryController, const Controllers::Ble& bleController, + const Controllers::Timer& timer, Controllers::NotificationManager& notificationManager, Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, Controllers::MotionController& motionController, - Controllers::SimpleWeatherService& weatherService, - Controllers::Timer& timer) + Controllers::SimpleWeatherService& weatherService) : currentDateTime {{}}, dateTimeController {dateTimeController}, notificationManager {notificationManager}, @@ -31,7 +31,6 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController, heartRateController {heartRateController}, motionController {motionController}, weatherService {weatherService}, - timer {timer}, statusIcons(batteryController, bleController, timer) { statusIcons.Create(); diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index 357769a488..9773240d41 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -31,12 +31,12 @@ namespace Pinetime { WatchFaceDigital(Controllers::DateTime& dateTimeController, const Controllers::Battery& batteryController, const Controllers::Ble& bleController, + const Controllers::Timer& timer, Controllers::NotificationManager& notificationManager, Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, Controllers::MotionController& motionController, - Controllers::SimpleWeatherService& weather, - Controllers::Timer& timer); + Controllers::SimpleWeatherService& weather); ~WatchFaceDigital() override; void Refresh() override; @@ -76,7 +76,6 @@ namespace Pinetime { Controllers::HeartRateController& heartRateController; Controllers::MotionController& motionController; Controllers::SimpleWeatherService& weatherService; - Controllers::Timer& timer; lv_task_t* taskRefresh; Widgets::StatusIcons statusIcons; @@ -92,12 +91,12 @@ namespace Pinetime { return new Screens::WatchFaceDigital(controllers.dateTimeController, controllers.batteryController, controllers.bleController, + controllers.timer, controllers.notificationManager, controllers.settingsController, controllers.heartRateController, controllers.motionController, - *controllers.weatherController, - controllers.timer); + *controllers.weatherController); }; static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) { diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index 614c19c2de..3f1615df25 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -34,7 +34,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, Controllers::MotorController& motorController, Pinetime::Controllers::Settings& settingsController, const Controllers::Ble& bleController, - Controllers::Timer& timer) + const Controllers::Timer& timer) : app {app}, dateTimeController {dateTimeController}, brightness {brightness}, diff --git a/src/displayapp/screens/settings/QuickSettings.h b/src/displayapp/screens/settings/QuickSettings.h index c3e3e80fbb..297c41e84c 100644 --- a/src/displayapp/screens/settings/QuickSettings.h +++ b/src/displayapp/screens/settings/QuickSettings.h @@ -24,7 +24,7 @@ namespace Pinetime { Controllers::MotorController& motorController, Pinetime::Controllers::Settings& settingsController, const Controllers::Ble& bleController, - Controllers::Timer& timer); + const Controllers::Timer& timer); ~QuickSettings() override; diff --git a/src/displayapp/widgets/StatusIcons.cpp b/src/displayapp/widgets/StatusIcons.cpp index f53b596fc8..18b3fa5950 100644 --- a/src/displayapp/widgets/StatusIcons.cpp +++ b/src/displayapp/widgets/StatusIcons.cpp @@ -3,7 +3,7 @@ using namespace Pinetime::Applications::Widgets; -StatusIcons::StatusIcons(const Controllers::Battery& batteryController, const Controllers::Ble& bleController, Controllers::Timer& timer) +StatusIcons::StatusIcons(const Controllers::Battery& batteryController, const Controllers::Ble& bleController, const Controllers::Timer& timer) : batteryIcon(true), batteryController {batteryController}, bleController {bleController}, timer {timer} { } diff --git a/src/displayapp/widgets/StatusIcons.h b/src/displayapp/widgets/StatusIcons.h index a5d5083dc5..39189a07e5 100644 --- a/src/displayapp/widgets/StatusIcons.h +++ b/src/displayapp/widgets/StatusIcons.h @@ -13,7 +13,7 @@ namespace Pinetime { namespace Widgets { class StatusIcons { public: - StatusIcons(const Controllers::Battery& batteryController, const Controllers::Ble& bleController, Controllers::Timer& timer); + StatusIcons(const Controllers::Battery& batteryController, const Controllers::Ble& bleController, const Controllers::Timer& timer); void Align(); void Create(); @@ -27,7 +27,7 @@ namespace Pinetime { Screens::BatteryIcon batteryIcon; const Pinetime::Controllers::Battery& batteryController; const Controllers::Ble& bleController; - Controllers::Timer& timer; + const Controllers::Timer& timer; Utility::DirtyValue batteryPercentRemaining {}; Utility::DirtyValue powerPresent {};