aboutsummaryrefslogtreecommitdiffstats
path: root/src/displayapp/screens/Timer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp/screens/Timer.cpp')
-rw-r--r--src/displayapp/screens/Timer.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp
index 6f086e02..e37bc432 100644
--- a/src/displayapp/screens/Timer.cpp
+++ b/src/displayapp/screens/Timer.cpp
@@ -17,7 +17,8 @@ static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
}
}
-Timer::Timer(Controllers::Timer& timerController) : timer {timerController} {
+Timer::Timer(Controllers::Timer& timerController, Controllers::MotorController& motorController)
+ : timer {timerController}, motorController {motorController} {
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);
@@ -62,7 +63,9 @@ Timer::Timer(Controllers::Timer& timerController) : timer {timerController} {
// Create the label as a child of the button so it stays centered by default
txtPlayPause = lv_label_create(btnPlayPause, nullptr);
- if (timer.IsRunning()) {
+ if (motorController.IsRinging()) {
+ SetTimerRinging();
+ } else if (timer.IsRunning()) {
SetTimerRunning();
} else {
SetTimerStopped();
@@ -103,7 +106,17 @@ void Timer::UpdateMask() {
}
void Timer::Refresh() {
- if (timer.IsRunning()) {
+ if (isRinging) {
+ DisplayTime();
+ // Stop buzzing after 10 seconds, but continue the counter
+ if (motorController.IsRinging() && displaySeconds.Get().count() > 10) {
+ motorController.StopRinging();
+ }
+ // Reset timer after 1 minute
+ if (displaySeconds.Get().count() > 60) {
+ Reset();
+ }
+ } else if (timer.IsRunning()) {
DisplayTime();
} else if (buttonPressing && xTaskGetTickCount() - pressTime > pdMS_TO_TICKS(150)) {
lv_label_set_text_static(txtPlayPause, "Reset");
@@ -130,16 +143,30 @@ void Timer::SetTimerRunning() {
minuteCounter.HideControls();
secondCounter.HideControls();
lv_label_set_text_static(txtPlayPause, "Pause");
+ lv_obj_set_style_local_bg_color(btnPlayPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
}
void Timer::SetTimerStopped() {
+ isRinging = false;
minuteCounter.ShowControls();
secondCounter.ShowControls();
lv_label_set_text_static(txtPlayPause, "Start");
+ lv_obj_set_style_local_bg_color(btnPlayPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
+}
+
+void Timer::SetTimerRinging() {
+ isRinging = true;
+ minuteCounter.HideControls();
+ secondCounter.HideControls();
+ lv_label_set_text_static(txtPlayPause, "Reset");
+ lv_obj_set_style_local_bg_color(btnPlayPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
}
void Timer::ToggleRunning() {
- if (timer.IsRunning()) {
+ if (isRinging) {
+ motorController.StopRinging();
+ Reset();
+ } else if (timer.IsRunning()) {
DisplayTime();
timer.StopTimer();
SetTimerStopped();
@@ -152,6 +179,7 @@ void Timer::ToggleRunning() {
}
void Timer::Reset() {
+ timer.ResetExpiredTime();
DisplayTime();
SetTimerStopped();
}