Skip to content

Commit b5bef6c

Browse files
committed
fixed an integer overflow bug in time rendering
1 parent c656ff7 commit b5bef6c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/displayapp/screens/StopWatch.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ using namespace Pinetime::Controllers;
88

99
namespace {
1010
TimeSeparated ConvertTicksToTimeSegments(const TickType_t timeElapsed) {
11-
// Centiseconds
12-
const int timeElapsedCentis = timeElapsed * 100 / configTICK_RATE_HZ;
11+
const int timeElapsedSecs = timeElapsed / configTICK_RATE_HZ;
12+
const int timeElapsedFraction = timeElapsed % configTICK_RATE_HZ;
1313

14-
const int hundredths = (timeElapsedCentis % 100);
15-
const int secs = (timeElapsedCentis / 100) % 60;
16-
const int mins = ((timeElapsedCentis / 100) / 60) % 60;
17-
const int hours = ((timeElapsedCentis / 100) / 60) / 60;
14+
const int hundredths = timeElapsedFraction * 100 / configTICK_RATE_HZ;
15+
const int secs = (timeElapsedSecs) % 60;
16+
const int mins = (timeElapsedSecs / 60) % 60;
17+
const int hours = (timeElapsedSecs / 60) / 60;
1818
return TimeSeparated {hours, mins, secs, hundredths};
1919
}
2020

0 commit comments

Comments
 (0)