Skip to content

Commit

Permalink
Added a variable to ignore button press during certion actions.
Browse files Browse the repository at this point in the history
I think pressing the side button as the auto snooze function is running causes a crash.
  • Loading branch information
cyberneel committed Dec 17, 2024
1 parent 1892a90 commit 1bfd33f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/displayapp/screens/Sleep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ namespace {
}

void SnoozeAlarmTaskCallback(lv_task_t* task) {
auto* screen = static_cast<Sleep*>(task->user_data);
lv_task_set_prio(task, LV_TASK_PRIO_OFF);
auto* screen = static_cast<Sleep*>(task->user_data);
screen->ignoreButtonPush = true;
screen->StopAlerting(false);
screen->UpdateDisplay();
screen->SnoozeWakeAlarm();
screen->displayState = Sleep::SleepDisplayState::Info;
screen->UpdateDisplay();
screen->ignoreButtonPush = false;
}

void PressesToStopAlarmTimeoutCallback(lv_task_t* task) {
Expand Down Expand Up @@ -555,7 +557,7 @@ void Sleep::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
}

bool Sleep::OnButtonPushed() {
if (infiniSleepController.IsAlerting()) {
if (infiniSleepController.IsAlerting() || ignoreButtonPush) {
return true;
}
if (displayState != SleepDisplayState::Info) {
Expand Down
2 changes: 2 additions & 0 deletions src/displayapp/screens/Sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ namespace Pinetime {

Controllers::InfiniSleepController& infiniSleepController;

bool ignoreButtonPush = false;

private:
System::WakeLock wakeLock;
Controllers::MotorController& motorController;
Expand Down

0 comments on commit 1bfd33f

Please sign in to comment.