@@ -57,7 +57,7 @@ StopWatch::StopWatch(System::SystemTask& systemTask, StopWatchController& stopWa
5757
5858 lapText = lv_label_create (lv_scr_act (), nullptr );
5959 lv_obj_set_style_local_text_color (lapText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
60- lv_label_set_text_static (lapText, " \n " );
60+ lv_label_set_text_static (lapText, " " );
6161 lv_label_set_long_mode (lapText, LV_LABEL_LONG_BREAK);
6262 lv_label_set_align (lapText, LV_LABEL_ALIGN_CENTER);
6363 lv_obj_set_width (lapText, LV_HOR_RES_MAX);
@@ -170,24 +170,23 @@ void StopWatch::RenderPause() {
170170
171171void StopWatch::RenderLaps () {
172172 lv_label_set_text (lapText, " " );
173- for (int i = 0 ; i < displayedLaps ; i++ ) {
173+ for (int i = displayedLaps - 1 ; i >= 0 ; i-- ) {
174174 std::optional<LapInfo> lap = stopWatchController.GetLapFromHistory (i);
175175
176176 if (lap) {
177177 TimeSeparated laptime = ConvertTicksToTimeSegments (lap->timeSinceStart );
178178 char buffer[19 ];
179179 if (laptime.hours == 0 ) {
180- snprintf (buffer, sizeof (buffer), " #%-3d %2d:%02d.%02d\n " ,
180+ snprintf (buffer, sizeof (buffer), " \n #%-3d %2d:%02d.%02d" ,
181181 lap->number , laptime.mins , laptime.secs , laptime.hundredths );
182182 } else {
183- snprintf (buffer, sizeof (buffer), " #%-3d %3d:%02d:%02d.%02d\n " ,
183+ snprintf (buffer, sizeof (buffer), " \n #%-3d %3d:%02d:%02d.%02d" ,
184184 lap->number , laptime.hours , laptime.mins , laptime.secs , laptime.hundredths );
185185 }
186186 lv_label_ins_text (lapText, LV_LABEL_POS_LAST, buffer);
187- } else {
188- lv_label_ins_text (lapText, LV_LABEL_POS_LAST, " \n " );
189187 }
190188 }
189+ lv_obj_realign (lapText);
191190}
192191
193192void StopWatch::SetHoursVisible (bool visible) {
@@ -196,7 +195,11 @@ void StopWatch::SetHoursVisible(bool visible) {
196195 lv_obj_set_style_local_text_font (time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font);
197196 lv_obj_set_height (time, font->line_height );
198197 lv_obj_realign (msecTime);
198+ displayedLaps = visible ? 4 : 3 ;
199199 hoursVisible = visible;
200+ if (stopWatchController.GetLapFromHistory (0 )) {
201+ RenderLaps ();
202+ }
200203 }
201204}
202205
0 commit comments