From 605cba9123cdac70b66b6dd983bb750ed31b91c0 Mon Sep 17 00:00:00 2001 From: codingjourney Date: Wed, 30 Oct 2024 21:43:50 +0100 Subject: [PATCH] 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(-) diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index 5265455bcb..6fa8165225 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 e649485693..200f0192e2 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();