Skip to content

Commit

Permalink
Keep screen on during timer buzzing
Browse files Browse the repository at this point in the history
This prevents the motorController from buzzing infinitely while the
watch is sleeping.
  • Loading branch information
JustScott authored and vkareh committed Feb 14, 2025
1 parent 7e368b5 commit 44389c6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
16 changes: 11 additions & 5 deletions src/displayapp/screens/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions src/displayapp/screens/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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();
Expand All @@ -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;

Expand All @@ -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);
};
};
}

0 comments on commit 44389c6

Please sign in to comment.