From 08043c30789040e6d50af0bd6864b8b8cf95fecd Mon Sep 17 00:00:00 2001 From: codingjourney Date: Wed, 30 Oct 2024 21:43:50 +0100 Subject: common method for entering the Paused state --- src/displayapp/screens/StopWatch.cpp | 18 ++++++++++-------- src/displayapp/screens/StopWatch.h | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index 5265455b..6fa81652 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -203,11 +203,7 @@ void StopWatch::PlayPauseBtnEventHandler() { DisplayStarted(); wakeLock.Lock(); } else if (stopWatchController.IsRunning()) { - stopWatchController.Pause(); - blinkTime = xTaskGetTickCount() + blinkInterval; - DisplayPaused(); - RenderTime(); - wakeLock.Release(); + OnPause(); } } @@ -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(); +} \ No newline at end of file diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h index b0379654..26cfb43f 100644 --- a/src/displayapp/screens/StopWatch.h +++ b/src/displayapp/screens/StopWatch.h @@ -29,6 +29,8 @@ namespace Pinetime::Applications { bool OnButtonPushed() override; private: + void OnPause(); + void DisplayPaused(); void DisplayStarted(); void DisplayCleared(); -- cgit v1.2.3-70-g09d2