diff options
| author | codingjourney <coding@journey.sk> | 2024-11-30 22:23:31 +0100 |
|---|---|---|
| committer | JF <JF002@users.noreply.github.com> | 2025-11-04 21:25:31 +0100 |
| commit | 487205ef6a8e81fe887a1fcd72fee9c4de33c81f (patch) | |
| tree | d462c262287256b297bf7f06ba57ce55ff4164cf /src/displayapp/screens/StopWatch.cpp | |
| parent | 4de9fc9b88c1e3fc9ced4931d446386374161d61 (diff) | |
length of lap list adapting to available space
Diffstat (limited to 'src/displayapp/screens/StopWatch.cpp')
| -rw-r--r-- | src/displayapp/screens/StopWatch.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index 5d77fdcc..ef5ee6f5 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -57,7 +57,7 @@ StopWatch::StopWatch(System::SystemTask& systemTask, StopWatchController& stopWa lapText = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(lapText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray); - lv_label_set_text_static(lapText, "\n"); + lv_label_set_text_static(lapText, ""); lv_label_set_long_mode(lapText, LV_LABEL_LONG_BREAK); lv_label_set_align(lapText, LV_LABEL_ALIGN_CENTER); lv_obj_set_width(lapText, LV_HOR_RES_MAX); @@ -170,24 +170,23 @@ void StopWatch::RenderPause() { void StopWatch::RenderLaps() { lv_label_set_text(lapText, ""); - for (int i = 0; i < displayedLaps; i++) { + for (int i = displayedLaps - 1; i >= 0; i--) { std::optional<LapInfo> lap = stopWatchController.GetLapFromHistory(i); if (lap) { TimeSeparated laptime = ConvertTicksToTimeSegments(lap->timeSinceStart); char buffer[19]; if (laptime.hours == 0) { - snprintf(buffer, sizeof(buffer), "#%-3d %2d:%02d.%02d\n", + snprintf(buffer, sizeof(buffer), "\n#%-3d %2d:%02d.%02d", lap->number, laptime.mins, laptime.secs, laptime.hundredths); } else { - snprintf(buffer, sizeof(buffer), "#%-3d %3d:%02d:%02d.%02d\n", + snprintf(buffer, sizeof(buffer), "\n#%-3d %3d:%02d:%02d.%02d", lap->number, laptime.hours, laptime.mins, laptime.secs, laptime.hundredths); } lv_label_ins_text(lapText, LV_LABEL_POS_LAST, buffer); - } else { - lv_label_ins_text(lapText, LV_LABEL_POS_LAST, "\n"); } } + lv_obj_realign(lapText); } void StopWatch::SetHoursVisible(bool visible) { @@ -196,7 +195,11 @@ void StopWatch::SetHoursVisible(bool visible) { lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font); lv_obj_set_height(time, font->line_height); lv_obj_realign(msecTime); + displayedLaps = visible ? 4 : 3; hoursVisible = visible; + if (stopWatchController.GetLapFromHistory(0)) { + RenderLaps(); + } } } |
