aboutsummaryrefslogtreecommitdiffstats
path: root/src/displayapp/screens/Timer.cpp
diff options
context:
space:
mode:
authorRiku Isokoski <riksu9000@gmail.com>2023-04-11 12:18:49 +0300
committerRiku Isokoski <riksu9000@gmail.com>2023-04-16 14:33:23 +0000
commit40f7e1c7be6882e01058b5ccf64d5005c6105346 (patch)
tree7117de9dc371404da75efd10813d724b5e0205a3 /src/displayapp/screens/Timer.cpp
parent661ffbeb1eea68ec0cd63b4db537515f1d1772c8 (diff)
TimerController: Rename to Timer
Diffstat (limited to 'src/displayapp/screens/Timer.cpp')
-rw-r--r--src/displayapp/screens/Timer.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp
index df78a5a0..d9488740 100644
--- a/src/displayapp/screens/Timer.cpp
+++ b/src/displayapp/screens/Timer.cpp
@@ -17,7 +17,7 @@ static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
}
}
-Timer::Timer(Controllers::TimerController& timerController) : timerController {timerController} {
+Timer::Timer(Controllers::Timer& timerController) : timer {timerController} {
lv_obj_t* colonLabel = lv_label_create(lv_scr_act(), nullptr);
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() {
buttonPressing = false;
// A click event is processed before a release event,
// so the release event would override the "Pause" text without this check
- if (!timerController.IsRunning()) {
+ if (!timer.IsRunning()) {
lv_label_set_text_static(txtPlayPause, "Start");
}
maskPosition = 0;
@@ -103,8 +103,8 @@ void Timer::UpdateMask() {
}
void Timer::Refresh() {
- if (timerController.IsRunning()) {
- auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timerController.GetTimeRemaining());
+ if (timer.IsRunning()) {
+ auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
minuteCounter.SetValue(secondsRemaining.count() / 60);
secondCounter.SetValue(secondsRemaining.count() % 60);
} else if (buttonPressing && xTaskGetTickCount() > pressTime + pdMS_TO_TICKS(150)) {
@@ -132,15 +132,15 @@ void Timer::SetTimerStopped() {
}
void Timer::ToggleRunning() {
- if (timerController.IsRunning()) {
- auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timerController.GetTimeRemaining());
+ if (timer.IsRunning()) {
+ auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
minuteCounter.SetValue(secondsRemaining.count() / 60);
secondCounter.SetValue(secondsRemaining.count() % 60);
- timerController.StopTimer();
+ timer.StopTimer();
SetTimerStopped();
} else if (secondCounter.GetValue() + minuteCounter.GetValue() > 0) {
auto timerDuration = std::chrono::minutes(minuteCounter.GetValue()) + std::chrono::seconds(secondCounter.GetValue());
- timerController.StartTimer(timerDuration);
+ timer.StartTimer(timerDuration);
Refresh();
SetTimerRunning();
}