aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJustScott <development@justscott.me>2025-02-07 15:21:57 -0600
committerJF <JF002@users.noreply.github.com>2025-12-13 21:31:50 +0100
commita4918c0e96c17d98452e150e821565ee03aaa90b (patch)
treeed0e739cee00a488413e5570db3133edd6bf28d7 /src
parent54f20ff4cb439f9997adb0e295caeb3130bfaecc (diff)
Keep screen on during timer buzzing
This prevents the motorController from buzzing infinitely while the watch is sleeping.
Diffstat (limited to 'src')
-rw-r--r--src/displayapp/screens/Timer.cpp16
-rw-r--r--src/displayapp/screens/Timer.h7
2 files changed, 16 insertions, 7 deletions
diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp
index e37bc432..02c84160 100644
--- a/src/displayapp/screens/Timer.cpp
+++ b/src/displayapp/screens/Timer.cpp
@@ -17,8 +17,8 @@ static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
}
}
-Timer::Timer(Controllers::Timer& timerController, Controllers::MotorController& motorController)
- : timer {timerController}, motorController {motorController} {
+Timer::Timer(Controllers::Timer& timerController, Controllers::MotorController& motorController, System::SystemTask& systemTask)
+ : timer {timerController}, motorController {motorController}, wakeLock(systemTask) {
lv_obj_t* colonLabel = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(colonLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
@@ -108,9 +108,15 @@ void Timer::UpdateMask() {
void Timer::Refresh() {
if (isRinging) {
DisplayTime();
- // Stop buzzing after 10 seconds, but continue the counter
- if (motorController.IsRinging() && displaySeconds.Get().count() > 10) {
- motorController.StopRinging();
+ if (motorController.IsRinging()) {
+ if (displaySeconds.Get().count() > 10) {
+ // Stop buzzing after 10 seconds, but continue the counter
+ motorController.StopRinging();
+ wakeLock.Release();
+ } else {
+ // Keep the screen awake during the first 10 seconds
+ wakeLock.Lock();
+ }
}
// Reset timer after 1 minute
if (displaySeconds.Get().count() > 60) {
diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h
index 48c4fdda..63ca2456 100644
--- a/src/displayapp/screens/Timer.h
+++ b/src/displayapp/screens/Timer.h
@@ -3,6 +3,7 @@
#include "displayapp/screens/Screen.h"
#include "components/motor/MotorController.h"
#include "systemtask/SystemTask.h"
+#include "systemtask/WakeLock.h"
#include "displayapp/LittleVgl.h"
#include "displayapp/widgets/Counter.h"
#include "utility/DirtyValue.h"
@@ -15,7 +16,7 @@ namespace Pinetime::Applications {
namespace Screens {
class Timer : public Screen {
public:
- Timer(Controllers::Timer& timerController, Controllers::MotorController& motorController);
+ Timer(Controllers::Timer& timerController, Controllers::MotorController& motorController, System::SystemTask& systemTask);
~Timer() override;
void Refresh() override;
void Reset();
@@ -32,6 +33,8 @@ namespace Pinetime::Applications {
Pinetime::Controllers::Timer& timer;
Pinetime::Controllers::MotorController& motorController;
+ Pinetime::System::WakeLock wakeLock;
+
lv_obj_t* btnPlayPause;
lv_obj_t* txtPlayPause;
@@ -58,7 +61,7 @@ namespace Pinetime::Applications {
static constexpr const char* icon = Screens::Symbols::hourGlass;
static Screens::Screen* Create(AppControllers& controllers) {
- return new Screens::Timer(controllers.timer, controllers.motorController);
+ return new Screens::Timer(controllers.timer, controllers.motorController, *controllers.systemTask);
};
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {