Skip to content

Commit 605cba9

Browse files
committed
common method for entering the Paused state
1 parent 20464e1 commit 605cba9

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/displayapp/screens/StopWatch.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,7 @@ void StopWatch::PlayPauseBtnEventHandler() {
203203
DisplayStarted();
204204
wakeLock.Lock();
205205
} else if (stopWatchController.IsRunning()) {
206-
stopWatchController.Pause();
207-
blinkTime = xTaskGetTickCount() + blinkInterval;
208-
DisplayPaused();
209-
RenderTime();
210-
wakeLock.Release();
206+
OnPause();
211207
}
212208
}
213209

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

225221
bool StopWatch::OnButtonPushed() {
226222
if (stopWatchController.IsRunning()) {
227-
stopWatchController.Pause();
228-
DisplayPaused();
229-
wakeLock.Release();
223+
OnPause();
230224
return true;
231225
}
232226
return false;
233227
}
228+
229+
void StopWatch::OnPause() {
230+
stopWatchController.Pause();
231+
blinkTime = xTaskGetTickCount() + blinkInterval;
232+
RenderTime(); // make sure displayed time is not stale
233+
DisplayPaused();
234+
wakeLock.Release();
235+
}

src/displayapp/screens/StopWatch.h

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ namespace Pinetime::Applications {
2929
bool OnButtonPushed() override;
3030

3131
private:
32+
void OnPause();
33+
3234
void DisplayPaused();
3335
void DisplayStarted();
3436
void DisplayCleared();

0 commit comments

Comments
 (0)