Skip to content

Commit

Permalink
common method for entering the Paused state
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjourney committed Nov 6, 2024
1 parent 96fd2df commit dbd222f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/displayapp/screens/StopWatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,7 @@ void StopWatch::PlayPauseBtnEventHandler() {
DisplayStarted();
wakeLock.Lock();
} else if (stopWatchController.IsRunning()) {
stopWatchController.Pause();
blinkTime = xTaskGetTickCount() + blinkInterval;
DisplayPaused();
RenderTime();
wakeLock.Release();
OnPause();
}
}

Expand All @@ -224,10 +220,16 @@ void StopWatch::StopLapBtnEventHandler() {

bool StopWatch::OnButtonPushed() {
if (stopWatchController.IsRunning()) {
stopWatchController.Pause();
DisplayPaused();
wakeLock.Release();
OnPause();
return true;
}
return false;
}

void StopWatch::OnPause() {
stopWatchController.Pause();
blinkTime = xTaskGetTickCount() + blinkInterval;
RenderTime(); // make sure displayed time is not stale
DisplayPaused();
wakeLock.Release();
}
2 changes: 2 additions & 0 deletions src/displayapp/screens/StopWatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace Pinetime::Applications {
bool OnButtonPushed() override;

private:
void OnPause();

void DisplayPaused();
void DisplayStarted();
void DisplayCleared();
Expand Down

0 comments on commit dbd222f

Please sign in to comment.