Skip to content

Commit 40f7e1c

Browse files
committed
TimerController: Rename to Timer
1 parent 661ffbe commit 40f7e1c

7 files changed

Lines changed: 26 additions & 26 deletions

File tree

src/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ list(APPEND SOURCE_FILES
472472
components/firmwarevalidator/FirmwareValidator.cpp
473473
components/motor/MotorController.cpp
474474
components/settings/Settings.cpp
475-
components/timer/TimerController.cpp
475+
components/timer/Timer.cpp
476476
components/alarm/AlarmController.cpp
477477
components/fs/FS.cpp
478478
drivers/Cst816s.cpp
@@ -537,7 +537,7 @@ list(APPEND RECOVERY_SOURCE_FILES
537537
components/ble/MotionService.cpp
538538
components/firmwarevalidator/FirmwareValidator.cpp
539539
components/settings/Settings.cpp
540-
components/timer/TimerController.cpp
540+
components/timer/Timer.cpp
541541
components/alarm/AlarmController.cpp
542542
drivers/Cst816s.cpp
543543
FreeRTOS/port.c
@@ -653,7 +653,7 @@ set(INCLUDE_FILES
653653
components/ble/MotionService.h
654654
components/ble/weather/WeatherService.h
655655
components/settings/Settings.h
656-
components/timer/TimerController.h
656+
components/timer/Timer.h
657657
components/alarm/AlarmController.h
658658
drivers/Cst816s.h
659659
FreeRTOS/portmacro.h
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
#include "components/timer/TimerController.h"
1+
#include "components/timer/Timer.h"
22

33
using namespace Pinetime::Controllers;
44

5-
TimerController::TimerController(void* const timerData, TimerCallbackFunction_t timerCallbackFunction) {
5+
Timer::Timer(void* const timerData, TimerCallbackFunction_t timerCallbackFunction) {
66
timer = xTimerCreate("Timer", 1, pdFALSE, timerData, timerCallbackFunction);
77
}
88

9-
void TimerController::StartTimer(std::chrono::milliseconds duration) {
9+
void Timer::StartTimer(std::chrono::milliseconds duration) {
1010
xTimerChangePeriod(timer, pdMS_TO_TICKS(duration.count()), 0);
1111
xTimerStart(timer, 0);
1212
}
1313

14-
std::chrono::milliseconds TimerController::GetTimeRemaining() {
14+
std::chrono::milliseconds Timer::GetTimeRemaining() {
1515
if (IsRunning()) {
1616
TickType_t remainingTime = xTimerGetExpiryTime(timer) - xTaskGetTickCount();
1717
return std::chrono::milliseconds(remainingTime * 1000 / configTICK_RATE_HZ);
1818
}
1919
return std::chrono::milliseconds(0);
2020
}
2121

22-
void TimerController::StopTimer() {
22+
void Timer::StopTimer() {
2323
xTimerStop(timer, 0);
2424
}
2525

26-
bool TimerController::IsRunning() {
26+
bool Timer::IsRunning() {
2727
return (xTimerIsTimerActive(timer) == pdTRUE);
2828
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace Pinetime {
99
namespace Controllers {
10-
class TimerController {
10+
class Timer {
1111
public:
12-
TimerController(void* timerData, TimerCallbackFunction_t timerCallbackFunction);
12+
Timer(void* timerData, TimerCallbackFunction_t timerCallbackFunction);
1313

1414
void StartTimer(std::chrono::milliseconds duration);
1515

src/displayapp/DisplayApp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
9595
touchHandler {touchHandler},
9696
filesystem {filesystem},
9797
lvgl {lcd, filesystem},
98-
timerController(this, TimerCallback) {
98+
timer(this, TimerCallback) {
9999
}
100100

101101
void DisplayApp::Start(System::BootErrors error) {
@@ -452,7 +452,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
452452
Screens::Notifications::Modes::Preview);
453453
break;
454454
case Apps::Timer:
455-
currentScreen = std::make_unique<Screens::Timer>(timerController);
455+
currentScreen = std::make_unique<Screens::Timer>(timer);
456456
break;
457457
case Apps::Alarm:
458458
currentScreen = std::make_unique<Screens::Alarm>(alarmController, settingsController.GetClockType(), *systemTask, motorController);

src/displayapp/DisplayApp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "components/firmwarevalidator/FirmwareValidator.h"
1313
#include "components/settings/Settings.h"
1414
#include "displayapp/screens/Screen.h"
15-
#include "components/timer/TimerController.h"
15+
#include "components/timer/Timer.h"
1616
#include "components/alarm/AlarmController.h"
1717
#include "touchhandler/TouchHandler.h"
1818

@@ -94,7 +94,7 @@ namespace Pinetime {
9494

9595
Pinetime::Controllers::FirmwareValidator validator;
9696
Pinetime::Components::LittleVgl lvgl;
97-
Pinetime::Controllers::TimerController timerController;
97+
Pinetime::Controllers::Timer timer;
9898

9999
TaskHandle_t taskHandle;
100100

src/displayapp/screens/Timer.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
1717
}
1818
}
1919

20-
Timer::Timer(Controllers::TimerController& timerController) : timerController {timerController} {
20+
Timer::Timer(Controllers::Timer& timerController) : timer {timerController} {
2121

2222
lv_obj_t* colonLabel = lv_label_create(lv_scr_act(), nullptr);
2323
lv_obj_set_style_local_text_font(colonLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
@@ -85,7 +85,7 @@ void Timer::MaskReset() {
8585
buttonPressing = false;
8686
// A click event is processed before a release event,
8787
// so the release event would override the "Pause" text without this check
88-
if (!timerController.IsRunning()) {
88+
if (!timer.IsRunning()) {
8989
lv_label_set_text_static(txtPlayPause, "Start");
9090
}
9191
maskPosition = 0;
@@ -103,8 +103,8 @@ void Timer::UpdateMask() {
103103
}
104104

105105
void Timer::Refresh() {
106-
if (timerController.IsRunning()) {
107-
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timerController.GetTimeRemaining());
106+
if (timer.IsRunning()) {
107+
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
108108
minuteCounter.SetValue(secondsRemaining.count() / 60);
109109
secondCounter.SetValue(secondsRemaining.count() % 60);
110110
} else if (buttonPressing && xTaskGetTickCount() > pressTime + pdMS_TO_TICKS(150)) {
@@ -132,15 +132,15 @@ void Timer::SetTimerStopped() {
132132
}
133133

134134
void Timer::ToggleRunning() {
135-
if (timerController.IsRunning()) {
136-
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timerController.GetTimeRemaining());
135+
if (timer.IsRunning()) {
136+
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
137137
minuteCounter.SetValue(secondsRemaining.count() / 60);
138138
secondCounter.SetValue(secondsRemaining.count() % 60);
139-
timerController.StopTimer();
139+
timer.StopTimer();
140140
SetTimerStopped();
141141
} else if (secondCounter.GetValue() + minuteCounter.GetValue() > 0) {
142142
auto timerDuration = std::chrono::minutes(minuteCounter.GetValue()) + std::chrono::seconds(secondCounter.GetValue());
143-
timerController.StartTimer(timerDuration);
143+
timer.StartTimer(timerDuration);
144144
Refresh();
145145
SetTimerRunning();
146146
}

src/displayapp/screens/Timer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
#include "displayapp/widgets/Counter.h"
88
#include <lvgl/lvgl.h>
99

10-
#include "components/timer/TimerController.h"
10+
#include "components/timer/Timer.h"
1111

1212
namespace Pinetime::Applications::Screens {
1313
class Timer : public Screen {
1414
public:
15-
Timer(Controllers::TimerController& timerController);
15+
Timer(Controllers::Timer& timerController);
1616
~Timer() override;
1717
void Refresh() override;
1818
void Reset();
@@ -24,7 +24,7 @@ namespace Pinetime::Applications::Screens {
2424
void SetTimerRunning();
2525
void SetTimerStopped();
2626
void UpdateMask();
27-
Controllers::TimerController& timerController;
27+
Controllers::Timer& timer;
2828

2929
lv_obj_t* btnPlayPause;
3030
lv_obj_t* txtPlayPause;

0 commit comments

Comments
 (0)