Skip to content

Commit

Permalink
Pass the timer as const
Browse files Browse the repository at this point in the history
Doing this matches the other Controllers, which are also passed
as const to the StatusIcons.
  • Loading branch information
JustScott committed Feb 20, 2024
1 parent 895f9a5 commit a36cde7
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/components/timer/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -23,6 +23,6 @@ void Timer::StopTimer() {
xTimerStop(timer, 0);
}

bool Timer::IsRunning() {
bool Timer::IsRunning() const {
return (xTimerIsTimerActive(timer) == pdTRUE);
}
4 changes: 2 additions & 2 deletions src/components/timer/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/displayapp/screens/WatchFaceDigital.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ 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},
settingsController {settingsController},
heartRateController {heartRateController},
motionController {motionController},
weatherService {weatherService},
timer {timer},
statusIcons(batteryController, bleController, timer) {

statusIcons.Create();
Expand Down
9 changes: 4 additions & 5 deletions src/displayapp/screens/WatchFaceDigital.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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*/) {
Expand Down
2 changes: 1 addition & 1 deletion src/displayapp/screens/settings/QuickSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion src/displayapp/screens/settings/QuickSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/displayapp/widgets/StatusIcons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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} {
}

Expand Down
4 changes: 2 additions & 2 deletions src/displayapp/widgets/StatusIcons.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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<uint8_t> batteryPercentRemaining {};
Utility::DirtyValue<bool> powerPresent {};
Expand Down

0 comments on commit a36cde7

Please sign in to comment.