Skip to content

Commit

Permalink
fixed an integer overflow bug in time rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjourney committed Nov 18, 2024
1 parent 0195a1c commit ac6b39f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/displayapp/screens/StopWatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}

Expand Down

0 comments on commit ac6b39f

Please sign in to comment.