Pass the timer as const

Doing this matches the other Controllers, which are also passed
as const to the StatusIcons.
This commit is contained in:
JustScott 2024-02-20 16:05:31 -06:00
parent 66930a55f5
commit 3fa9dbbac7
8 changed files with 15 additions and 17 deletions

View file

@ -11,7 +11,7 @@ void Timer::StartTimer(std::chrono::milliseconds duration) {
xTimerStart(timer, 0); xTimerStart(timer, 0);
} }
std::chrono::milliseconds Timer::GetTimeRemaining() { std::chrono::milliseconds Timer::GetTimeRemaining() const {
if (IsRunning()) { if (IsRunning()) {
TickType_t remainingTime = xTimerGetExpiryTime(timer) - xTaskGetTickCount(); TickType_t remainingTime = xTimerGetExpiryTime(timer) - xTaskGetTickCount();
return std::chrono::milliseconds(remainingTime * 1000 / configTICK_RATE_HZ); return std::chrono::milliseconds(remainingTime * 1000 / configTICK_RATE_HZ);
@ -23,6 +23,6 @@ void Timer::StopTimer() {
xTimerStop(timer, 0); xTimerStop(timer, 0);
} }
bool Timer::IsRunning() { bool Timer::IsRunning() const {
return (xTimerIsTimerActive(timer) == pdTRUE); return (xTimerIsTimerActive(timer) == pdTRUE);
} }

View file

@ -15,9 +15,9 @@ namespace Pinetime {
void StopTimer(); void StopTimer();
std::chrono::milliseconds GetTimeRemaining(); std::chrono::milliseconds GetTimeRemaining() const;
bool IsRunning(); bool IsRunning() const;
private: private:
TimerHandle_t timer; TimerHandle_t timer;

View file

@ -18,12 +18,12 @@ using namespace Pinetime::Applications::Screens;
WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController, WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController, const Controllers::Battery& batteryController,
const Controllers::Ble& bleController, const Controllers::Ble& bleController,
const Controllers::Timer& timer,
Controllers::NotificationManager& notificationManager, Controllers::NotificationManager& notificationManager,
Controllers::Settings& settingsController, Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController, Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController, Controllers::MotionController& motionController,
Controllers::SimpleWeatherService& weatherService, Controllers::SimpleWeatherService& weatherService)
Controllers::Timer& timer)
: currentDateTime {{}}, : currentDateTime {{}},
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
notificationManager {notificationManager}, notificationManager {notificationManager},
@ -31,7 +31,6 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
heartRateController {heartRateController}, heartRateController {heartRateController},
motionController {motionController}, motionController {motionController},
weatherService {weatherService}, weatherService {weatherService},
timer {timer},
statusIcons(batteryController, bleController, timer) { statusIcons(batteryController, bleController, timer) {
statusIcons.Create(); statusIcons.Create();

View file

@ -31,12 +31,12 @@ namespace Pinetime {
WatchFaceDigital(Controllers::DateTime& dateTimeController, WatchFaceDigital(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController, const Controllers::Battery& batteryController,
const Controllers::Ble& bleController, const Controllers::Ble& bleController,
const Controllers::Timer& timer,
Controllers::NotificationManager& notificationManager, Controllers::NotificationManager& notificationManager,
Controllers::Settings& settingsController, Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController, Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController, Controllers::MotionController& motionController,
Controllers::SimpleWeatherService& weather, Controllers::SimpleWeatherService& weather);
Controllers::Timer& timer);
~WatchFaceDigital() override; ~WatchFaceDigital() override;
void Refresh() override; void Refresh() override;
@ -75,7 +75,6 @@ namespace Pinetime {
Controllers::HeartRateController& heartRateController; Controllers::HeartRateController& heartRateController;
Controllers::MotionController& motionController; Controllers::MotionController& motionController;
Controllers::SimpleWeatherService& weatherService; Controllers::SimpleWeatherService& weatherService;
Controllers::Timer& timer;
lv_task_t* taskRefresh; lv_task_t* taskRefresh;
Widgets::StatusIcons statusIcons; Widgets::StatusIcons statusIcons;
@ -91,12 +90,12 @@ namespace Pinetime {
return new Screens::WatchFaceDigital(controllers.dateTimeController, return new Screens::WatchFaceDigital(controllers.dateTimeController,
controllers.batteryController, controllers.batteryController,
controllers.bleController, controllers.bleController,
controllers.timer,
controllers.notificationManager, controllers.notificationManager,
controllers.settingsController, controllers.settingsController,
controllers.heartRateController, controllers.heartRateController,
controllers.motionController, controllers.motionController,
*controllers.weatherController, *controllers.weatherController);
controllers.timer);
}; };
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) { static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {

View file

@ -34,7 +34,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
Controllers::MotorController& motorController, Controllers::MotorController& motorController,
Pinetime::Controllers::Settings& settingsController, Pinetime::Controllers::Settings& settingsController,
const Controllers::Ble& bleController, const Controllers::Ble& bleController,
Controllers::Timer& timer) const Controllers::Timer& timer)
: app {app}, : app {app},
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
brightness {brightness}, brightness {brightness},

View file

@ -24,7 +24,7 @@ namespace Pinetime {
Controllers::MotorController& motorController, Controllers::MotorController& motorController,
Pinetime::Controllers::Settings& settingsController, Pinetime::Controllers::Settings& settingsController,
const Controllers::Ble& bleController, const Controllers::Ble& bleController,
Controllers::Timer& timer); const Controllers::Timer& timer);
~QuickSettings() override; ~QuickSettings() override;

View file

@ -3,7 +3,7 @@
using namespace Pinetime::Applications::Widgets; 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} { : batteryIcon(true), batteryController {batteryController}, bleController {bleController}, timer {timer} {
} }

View file

@ -13,7 +13,7 @@ namespace Pinetime {
namespace Widgets { namespace Widgets {
class StatusIcons { class StatusIcons {
public: 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 Align();
void Create(); void Create();
@ -27,7 +27,7 @@ namespace Pinetime {
Screens::BatteryIcon batteryIcon; Screens::BatteryIcon batteryIcon;
const Pinetime::Controllers::Battery& batteryController; const Pinetime::Controllers::Battery& batteryController;
const Controllers::Ble& bleController; const Controllers::Ble& bleController;
Controllers::Timer& timer; const Controllers::Timer& timer;
Utility::DirtyValue<uint8_t> batteryPercentRemaining {}; Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
Utility::DirtyValue<bool> powerPresent {}; Utility::DirtyValue<bool> powerPresent {};