@@ -17,7 +17,8 @@ static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
17
17
}
18
18
}
19
19
20
- Timer::Timer (Controllers::Timer& timerController) : timer {timerController} {
20
+ Timer::Timer (Controllers::Timer& timerController, Controllers::MotorController& motorController)
21
+ : timer {timerController}, motorController {motorController} {
21
22
22
23
lv_obj_t * colonLabel = lv_label_create (lv_scr_act (), nullptr );
23
24
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} {
62
63
txtPlayPause = lv_label_create (lv_scr_act (), nullptr );
63
64
lv_obj_align (txtPlayPause, btnPlayPause, LV_ALIGN_CENTER, 0 , 0 );
64
65
65
- if (timer.IsRunning ()) {
66
+ if (motorController.IsRinging ()) {
67
+ SetTimerRinging ();
68
+ } else if (timer.IsRunning ()) {
66
69
SetTimerRunning ();
67
70
} else {
68
71
SetTimerStopped ();
@@ -103,7 +106,17 @@ void Timer::UpdateMask() {
103
106
}
104
107
105
108
void Timer::Refresh () {
106
- if (timer.IsRunning ()) {
109
+ if (isRinging) {
110
+ DisplayTime ();
111
+ // Stop buzzing after 10 seconds, but continue the counter
112
+ if (motorController.IsRinging () && displaySeconds.Get ().count () > 10 ) {
113
+ motorController.StopRinging ();
114
+ }
115
+ // Reset timer after 1 minute
116
+ if (displaySeconds.Get ().count () > 60 ) {
117
+ Reset ();
118
+ }
119
+ } else if (timer.IsRunning ()) {
107
120
DisplayTime ();
108
121
} else if (buttonPressing && xTaskGetTickCount () > pressTime + pdMS_TO_TICKS (150 )) {
109
122
lv_label_set_text_static (txtPlayPause, " Reset" );
@@ -129,16 +142,31 @@ void Timer::SetTimerRunning() {
129
142
minuteCounter.HideControls ();
130
143
secondCounter.HideControls ();
131
144
lv_label_set_text_static (txtPlayPause, " Pause" );
145
+ lv_obj_set_style_local_bg_color (btnPlayPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
132
146
}
133
147
134
148
void Timer::SetTimerStopped () {
149
+ isRinging = false ;
135
150
minuteCounter.ShowControls ();
136
151
secondCounter.ShowControls ();
137
152
lv_label_set_text_static (txtPlayPause, " Start" );
153
+ lv_obj_set_style_local_bg_color (btnPlayPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
154
+ }
155
+
156
+ void Timer::SetTimerRinging () {
157
+ isRinging = true ;
158
+ minuteCounter.HideControls ();
159
+ secondCounter.HideControls ();
160
+ lv_label_set_text_static (txtPlayPause, " Reset" );
161
+ lv_obj_set_style_local_bg_color (btnPlayPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
162
+ timer.SetExpiredTime ();
138
163
}
139
164
140
165
void Timer::ToggleRunning () {
141
- if (timer.IsRunning ()) {
166
+ if (isRinging) {
167
+ motorController.StopRinging ();
168
+ Reset ();
169
+ } else if (timer.IsRunning ()) {
142
170
DisplayTime ();
143
171
timer.StopTimer ();
144
172
SetTimerStopped ();
@@ -151,6 +179,7 @@ void Timer::ToggleRunning() {
151
179
}
152
180
153
181
void Timer::Reset () {
182
+ timer.ResetExpiredTime ();
154
183
DisplayTime ();
155
184
SetTimerStopped ();
156
185
}
0 commit comments