Skip to content

Commit 44389c6

Browse files
JustScottvkareh
authored andcommitted
Keep screen on during timer buzzing
This prevents the motorController from buzzing infinitely while the watch is sleeping.
1 parent 7e368b5 commit 44389c6

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/displayapp/screens/Timer.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
1717
}
1818
}
1919

20-
Timer::Timer(Controllers::Timer& timerController, Controllers::MotorController& motorController)
21-
: timer {timerController}, motorController {motorController} {
20+
Timer::Timer(Controllers::Timer& timerController, Controllers::MotorController& motorController, System::SystemTask& systemTask)
21+
: timer {timerController}, motorController {motorController}, wakeLock(systemTask) {
2222

2323
lv_obj_t* colonLabel = lv_label_create(lv_scr_act(), nullptr);
2424
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() {
108108
void Timer::Refresh() {
109109
if (isRinging) {
110110
DisplayTime();
111-
// Stop buzzing after 10 seconds, but continue the counter
112-
if (motorController.IsRinging() && displaySeconds.Get().count() > 10) {
113-
motorController.StopRinging();
111+
if (motorController.IsRinging()) {
112+
if (displaySeconds.Get().count() > 10) {
113+
// Stop buzzing after 10 seconds, but continue the counter
114+
motorController.StopRinging();
115+
wakeLock.Release();
116+
} else {
117+
// Keep the screen awake during the first 10 seconds
118+
wakeLock.Lock();
119+
}
114120
}
115121
// Reset timer after 1 minute
116122
if (displaySeconds.Get().count() > 60) {

src/displayapp/screens/Timer.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "displayapp/screens/Screen.h"
44
#include "components/motor/MotorController.h"
55
#include "systemtask/SystemTask.h"
6+
#include "systemtask/WakeLock.h"
67
#include "displayapp/LittleVgl.h"
78
#include "displayapp/widgets/Counter.h"
89
#include "utility/DirtyValue.h"
@@ -15,7 +16,7 @@ namespace Pinetime::Applications {
1516
namespace Screens {
1617
class Timer : public Screen {
1718
public:
18-
Timer(Controllers::Timer& timerController, Controllers::MotorController& motorController);
19+
Timer(Controllers::Timer& timerController, Controllers::MotorController& motorController, System::SystemTask& systemTask);
1920
~Timer() override;
2021
void Refresh() override;
2122
void Reset();
@@ -32,6 +33,8 @@ namespace Pinetime::Applications {
3233
Pinetime::Controllers::Timer& timer;
3334
Pinetime::Controllers::MotorController& motorController;
3435

36+
Pinetime::System::WakeLock wakeLock;
37+
3538
lv_obj_t* btnPlayPause;
3639
lv_obj_t* txtPlayPause;
3740

@@ -58,7 +61,7 @@ namespace Pinetime::Applications {
5861
static constexpr const char* icon = Screens::Symbols::hourGlass;
5962

6063
static Screens::Screen* Create(AppControllers& controllers) {
61-
return new Screens::Timer(controllers.timer, controllers.motorController);
64+
return new Screens::Timer(controllers.timer, controllers.motorController, *controllers.systemTask);
6265
};
6366
};
6467
}

0 commit comments

Comments
 (0)