diff options
| author | codingjourney <coding@journey.sk> | 2024-11-18 18:26:52 +0100 |
|---|---|---|
| committer | JF <JF002@users.noreply.github.com> | 2025-11-04 21:25:31 +0100 |
| commit | 5c2d4a515112f8ba6a23f34d59c8a481368a1e79 (patch) | |
| tree | 30367265ac9a6142f2fde12c1b5e2971a85ed4cb /src/displayapp/screens | |
| parent | af84ec254987f95ead28c78775dfb1da69380de2 (diff) | |
fixed an integer overflow bug in time rendering
Diffstat (limited to 'src/displayapp/screens')
| -rw-r--r-- | src/displayapp/screens/StopWatch.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index 25b0ad77..710c4d44 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -8,13 +8,13 @@ using namespace Pinetime::Controllers; namespace { TimeSeparated ConvertTicksToTimeSegments(const TickType_t timeElapsed) { - // Centiseconds - const int timeElapsedCentis = timeElapsed * 100 / configTICK_RATE_HZ; + const int timeElapsedSecs = timeElapsed / configTICK_RATE_HZ; + const int timeElapsedFraction = timeElapsed % configTICK_RATE_HZ; - const int hundredths = (timeElapsedCentis % 100); - const int secs = (timeElapsedCentis / 100) % 60; - const int mins = ((timeElapsedCentis / 100) / 60) % 60; - const int hours = ((timeElapsedCentis / 100) / 60) / 60; + const int hundredths = timeElapsedFraction * 100 / configTICK_RATE_HZ; + const int secs = (timeElapsedSecs) % 60; + const int mins = (timeElapsedSecs / 60) % 60; + const int hours = (timeElapsedSecs / 60) / 60; return TimeSeparated {hours, mins, secs, hundredths}; } |
