From b221cc1731722b419a43a89ab75f5685ebf6282f Mon Sep 17 00:00:00 2001 From: Peetz0r Date: Sat, 17 Apr 2021 23:47:53 +0200 Subject: [PATCH] Stopwatch: improve variable naming msec => hundredths --- src/displayapp/screens/StopWatch.cpp | 10 +++++----- src/displayapp/screens/StopWatch.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index 1de6ff7f..371b4e6c 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -16,10 +16,10 @@ namespace { TimeSeparated_t convertTicksToTimeSegments(const TickType_t timeElapsed) { const int timeElapsedMillis = (static_cast(timeElapsed) / static_cast(configTICK_RATE_HZ)) * 1000; - const int milliSecs = (timeElapsedMillis % 1000) / 10; // Get only the first two digits and ignore the last + const int hundredths = (timeElapsedMillis % 1000) / 10; // Get only the first two digits and ignore the last const int secs = (timeElapsedMillis / 1000) % 60; const int mins = (timeElapsedMillis / 1000) / 60; - return TimeSeparated_t {mins, secs, milliSecs}; + return TimeSeparated_t {mins, secs, hundredths}; } TickType_t calculateDelta(const TickType_t startTime, const TickType_t currentTime) { @@ -141,14 +141,14 @@ bool StopWatch::Refresh() { currentTimeSeparated = convertTicksToTimeSegments((oldTimeElapsed + timeElapsed)); lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs); - lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.msecs); + lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.hundredths); if (lapPressed == true) { if (lapBuffer[1]) { - lv_label_set_text_fmt(lapOneText, "#2%d %2d:%02d.%02d", (lapNr - 1), lapBuffer[1]->mins, lapBuffer[1]->secs, lapBuffer[1]->msecs); + lv_label_set_text_fmt(lapOneText, "#2%d %2d:%02d.%02d", (lapNr - 1), lapBuffer[1]->mins, lapBuffer[1]->secs, lapBuffer[1]->hundredths); } if (lapBuffer[0]) { - lv_label_set_text_fmt(lapTwoText, "#2%d %2d:%02d.%02d", lapNr, lapBuffer[0]->mins, lapBuffer[0]->secs, lapBuffer[0]->msecs); + lv_label_set_text_fmt(lapTwoText, "#2%d %2d:%02d.%02d", lapNr, lapBuffer[0]->mins, lapBuffer[0]->secs, lapBuffer[0]->hundredths); } // Reset the bool to avoid setting the text in each cycle until there is a change lapPressed = false; diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h index b882cab5..ff604361 100644 --- a/src/displayapp/screens/StopWatch.h +++ b/src/displayapp/screens/StopWatch.h @@ -18,7 +18,7 @@ namespace Pinetime::Applications::Screens { struct TimeSeparated_t { int mins; int secs; - int msecs; + int hundredths; }; // A simple buffer to hold the latest two laps @@ -66,7 +66,7 @@ namespace Pinetime::Applications::Screens { StopWatch(DisplayApp* app); ~StopWatch() override; bool Refresh() override; - + void playPauseBtnEventHandler(lv_event_t event); void stopLapBtnEventHandler(lv_event_t event);