@@ -12,8 +12,9 @@ namespace {
1212
1313 const int hundredths = (timeElapsedCentis % 100 );
1414 const int secs = (timeElapsedCentis / 100 ) % 60 ;
15- const int mins = (timeElapsedCentis / 100 ) / 60 ;
16- return TimeSeparated_t {mins, secs, hundredths};
15+ const int mins = ((timeElapsedCentis / 100 ) / 60 ) % 60 ;
16+ const int hours = ((timeElapsedCentis / 100 ) / 60 ) / 60 ;
17+ return TimeSeparated_t {hours, mins, secs, hundredths};
1718 }
1819
1920 void play_pause_event_handler (lv_obj_t * obj, lv_event_t event) {
@@ -110,6 +111,12 @@ void StopWatch::SetInterfaceStopped() {
110111 lv_label_set_text_static (time, " 00:00" );
111112 lv_label_set_text_static (msecTime, " 00" );
112113
114+ if (isHoursLabelUpdated) {
115+ lv_obj_set_style_local_text_font (time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
116+ lv_obj_realign (time);
117+ isHoursLabelUpdated = false ;
118+ }
119+
113120 lv_label_set_text_static (lapText, " " );
114121 lv_label_set_text_static (txtPlayPause, Symbols::play);
115122 lv_label_set_text_static (txtStopLap, Symbols::lapsFlag);
@@ -146,7 +153,16 @@ void StopWatch::Refresh() {
146153 laps[lapsDone] = oldTimeElapsed + xTaskGetTickCount () - startTime;
147154
148155 TimeSeparated_t currentTimeSeparated = convertTicksToTimeSegments (laps[lapsDone]);
149- lv_label_set_text_fmt (time, " %02d:%02d" , currentTimeSeparated.mins , currentTimeSeparated.secs );
156+ if (currentTimeSeparated.hours == 0 ) {
157+ lv_label_set_text_fmt (time, " %02d:%02d" , currentTimeSeparated.mins , currentTimeSeparated.secs );
158+ } else {
159+ lv_label_set_text_fmt (time, " %02d:%02d:%02d" , currentTimeSeparated.hours , currentTimeSeparated.mins , currentTimeSeparated.secs );
160+ if (!isHoursLabelUpdated) {
161+ lv_obj_set_style_local_text_font (time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
162+ lv_obj_realign (time);
163+ isHoursLabelUpdated = true ;
164+ }
165+ }
150166 lv_label_set_text_fmt (msecTime, " %02d" , currentTimeSeparated.hundredths );
151167 } else if (currentState == States::Halted) {
152168 const TickType_t currentTime = xTaskGetTickCount ();
@@ -183,7 +199,11 @@ void StopWatch::stopLapBtnEventHandler() {
183199 }
184200 TimeSeparated_t times = convertTicksToTimeSegments (laps[i]);
185201 char buffer[16 ];
186- sprintf (buffer, " #%2d %2d:%02d.%02d\n " , i + 1 , times.mins , times.secs , times.hundredths );
202+ if (times.hours == 0 ) {
203+ sprintf (buffer, " #%2d %2d:%02d.%02d\n " , i + 1 , times.mins , times.secs , times.hundredths );
204+ } else {
205+ sprintf (buffer, " #%2d %2d:%02d:%02d.%02d\n " , i + 1 , times.hours , times.mins , times.secs , times.hundredths );
206+ }
187207 lv_label_ins_text (lapText, LV_LABEL_POS_LAST, buffer);
188208 }
189209 } else if (currentState == States::Halted) {
0 commit comments