@@ -19,16 +19,24 @@ static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
19
19
20
20
Timer::Timer (Controllers::Timer& timerController) : timer {timerController} {
21
21
22
- lv_obj_t * colonLabel = lv_label_create (lv_scr_act (), nullptr );
23
- lv_obj_set_style_local_text_font (colonLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
24
- lv_obj_set_style_local_text_color (colonLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
25
- lv_label_set_text_static (colonLabel, " :" );
26
- lv_obj_align (colonLabel, lv_scr_act (), LV_ALIGN_CENTER, 0 , -29 );
27
-
22
+ lv_obj_t * colonMinutesSeconds = lv_label_create (lv_scr_act (), nullptr );
23
+ lv_obj_set_style_local_text_font (colonMinutesSeconds, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
24
+ lv_obj_set_style_local_text_color (colonMinutesSeconds, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
25
+ lv_label_set_text_static (colonMinutesSeconds, " :" );
26
+ lv_obj_align (colonMinutesSeconds, lv_scr_act (), LV_ALIGN_IN_TOP_MID, 40 , 78 );
27
+
28
+ lv_obj_t * colonHoursMinutes = lv_label_create (lv_scr_act (), nullptr );
29
+ lv_obj_set_style_local_text_font (colonHoursMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
30
+ lv_obj_set_style_local_text_color (colonHoursMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
31
+ lv_label_set_text_static (colonHoursMinutes, " :" );
32
+ lv_obj_align (colonHoursMinutes, lv_scr_act (), LV_ALIGN_IN_TOP_MID, -41 , 78 );
33
+
34
+ hourCounter.Create ();
28
35
minuteCounter.Create ();
29
36
secondCounter.Create ();
30
- lv_obj_align (minuteCounter.GetObject (), nullptr , LV_ALIGN_IN_TOP_LEFT, 0 , 0 );
31
- lv_obj_align (secondCounter.GetObject (), nullptr , LV_ALIGN_IN_TOP_RIGHT, 0 , 0 );
37
+ lv_obj_align (hourCounter.GetObject (), nullptr , LV_ALIGN_IN_TOP_LEFT, 10 , 26 );
38
+ lv_obj_align (minuteCounter.GetObject (), nullptr , LV_ALIGN_IN_TOP_MID, 0 , 26 );
39
+ lv_obj_align (secondCounter.GetObject (), nullptr , LV_ALIGN_IN_TOP_RIGHT, -10 , 26 );
32
40
33
41
highlightObjectMask = lv_objmask_create (lv_scr_act (), nullptr );
34
42
lv_obj_set_size (highlightObjectMask, 240 , 50 );
@@ -120,18 +128,21 @@ void Timer::Refresh() {
120
128
void Timer::DisplayTime () {
121
129
displaySeconds = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining ());
122
130
if (displaySeconds.IsUpdated ()) {
123
- minuteCounter.SetValue (displaySeconds.Get ().count () / 60 );
131
+ hourCounter.SetValue (displaySeconds.Get ().count () / 3600 );
132
+ minuteCounter.SetValue ((displaySeconds.Get ().count () % 3600 ) / 60 );
124
133
secondCounter.SetValue (displaySeconds.Get ().count () % 60 );
125
134
}
126
135
}
127
136
128
137
void Timer::SetTimerRunning () {
138
+ hourCounter.HideControls ();
129
139
minuteCounter.HideControls ();
130
140
secondCounter.HideControls ();
131
141
lv_label_set_text_static (txtPlayPause, " Pause" );
132
142
}
133
143
134
144
void Timer::SetTimerStopped () {
145
+ hourCounter.ShowControls ();
135
146
minuteCounter.ShowControls ();
136
147
secondCounter.ShowControls ();
137
148
lv_label_set_text_static (txtPlayPause, " Start" );
@@ -142,9 +153,11 @@ void Timer::ToggleRunning() {
142
153
DisplayTime ();
143
154
timer.StopTimer ();
144
155
SetTimerStopped ();
145
- } else if (secondCounter.GetValue () + minuteCounter.GetValue () > 0 ) {
146
- auto timerDuration = std::chrono::minutes (minuteCounter.GetValue ()) + std::chrono::seconds (secondCounter.GetValue ());
156
+ } else if (secondCounter.GetValue () + minuteCounter.GetValue () + hourCounter.GetValue () > 0 ) {
157
+ std::chrono::milliseconds timerDuration = std::chrono::hours (hourCounter.GetValue ()) + std::chrono::minutes (minuteCounter.GetValue ()) +
158
+ std::chrono::seconds (secondCounter.GetValue ());
147
159
timer.StartTimer (timerDuration);
160
+ displaySeconds = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining ());
148
161
Refresh ();
149
162
SetTimerRunning ();
150
163
}
0 commit comments