From 5c2dba163660aaf9cf825103df53371d0007ce77 Mon Sep 17 00:00:00 2001 From: codingjourney Date: Sat, 14 Dec 2024 07:56:54 +0100 Subject: [PATCH] lap times without leading zeroes --- src/displayapp/screens/StopWatch.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index d2f4047960..026260cbfa 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -179,17 +179,24 @@ void StopWatch::RenderLaps() { if (lap) { TimeSeparated laptime = ConvertTicksToTimeSegments(lap->timeSinceStart); char buffer[19]; - if (laptime.hours == 0) { - snprintf(buffer, sizeof(buffer), "\n#%-3d %2d:%02d.%02d", lap->number, laptime.mins, laptime.secs, laptime.hundredths); - } else { - snprintf(buffer, - sizeof(buffer), - "\n#%-3d %3d:%02d:%02d.%02d", + if (laptime.hours > 0) { + snprintf(buffer, sizeof(buffer), "\n#%-3d %3d:%02d:%02d.%02d", lap->number, laptime.hours, laptime.mins, laptime.secs, laptime.hundredths); + } else if (laptime.mins > 0) { + snprintf(buffer, sizeof(buffer), "\n#%-3d %2d:%02d.%02d", + lap->number, + laptime.mins, + laptime.secs, + laptime.hundredths); + } else { + snprintf(buffer, sizeof(buffer), "\n#%-3d %2d.%02d", + lap->number, + laptime.secs, + laptime.hundredths); } lv_label_ins_text(lapText, LV_LABEL_POS_LAST, buffer); }