Skip to content

Commit 60a717b

Browse files
committed
Make it so special actions can be input while sleeping, like in #480
1 parent 887c409 commit 60a717b

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/systemtask/SystemTask.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,16 +336,17 @@ void SystemTask::Work() {
336336
displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
337337
break;
338338
case Messages::HandleButtonEvent: {
339-
// This is for faster wakeup, sacrificing special longpress and doubleclick handling while sleeping
340339
Controllers::ButtonActions action;
341340
if (nrf_gpio_pin_read(Pinetime::PinMap::Button) == 0) {
342341
action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Release);
343342
} else {
343+
action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Press);
344+
// This is for faster wakeup, sacrificing special longpress and doubleclick handling while sleeping
344345
if (IsSleeping()) {
346+
fastWakeUpDone = true;
345347
GoToRunning();
346348
break;
347349
}
348-
action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Press);
349350
}
350351
HandleButtonAction(action);
351352
} break;
@@ -448,7 +449,8 @@ void SystemTask::HandleButtonAction(Controllers::ButtonActions action) {
448449

449450
switch (action) {
450451
case Actions::Click:
451-
if (!isGoingToSleep) {
452+
// If the first action after fast wakeup is a click, it should be ignored.
453+
if (!fastWakeUpDone && !isGoingToSleep) {
452454
displayApp.PushMessage(Applications::Display::Messages::ButtonPushed);
453455
}
454456
break;
@@ -462,8 +464,10 @@ void SystemTask::HandleButtonAction(Controllers::ButtonActions action) {
462464
displayApp.PushMessage(Applications::Display::Messages::ButtonLongerPressed);
463465
break;
464466
default:
465-
break;
467+
return;
466468
}
469+
470+
fastWakeUpDone = false;
467471
}
468472

469473
void SystemTask::GoToRunning() {

src/systemtask/SystemTask.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ namespace Pinetime {
140140
bool doNotGoToSleep = false;
141141

142142
void HandleButtonAction(Controllers::ButtonActions action);
143+
bool fastWakeUpDone = false;
144+
143145
void GoToRunning();
144146
void UpdateMotion();
145147
bool stepCounterMustBeReset = false;

0 commit comments

Comments
 (0)