aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/stopwatch/StopWatchController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/stopwatch/StopWatchController.cpp')
-rw-r--r--src/components/stopwatch/StopWatchController.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/components/stopwatch/StopWatchController.cpp b/src/components/stopwatch/StopWatchController.cpp
index 311bccc7..64261055 100644
--- a/src/components/stopwatch/StopWatchController.cpp
+++ b/src/components/stopwatch/StopWatchController.cpp
@@ -14,8 +14,8 @@ void StopWatchController::Start() {
}
void StopWatchController::Pause() {
+ timeElapsedPreviously = GetElapsedTime();
currentState = StopWatchStates::Paused;
- timeElapsedPreviously += xTaskGetTickCount() - startTime;
}
void StopWatchController::Clear() {
@@ -55,7 +55,8 @@ TickType_t StopWatchController::GetElapsedTime() {
if (!IsRunning()) {
return timeElapsedPreviously;
}
- return timeElapsedPreviously + (xTaskGetTickCount() - startTime);
+ TickType_t delta = xTaskGetTickCount() - startTime;
+ return (timeElapsedPreviously + delta) % elapsedTimeBoundary;
}
bool StopWatchController::IsRunning() {