@@ -214,20 +214,26 @@ void SystemTask::Work() {
214214 state = SystemTaskState::Running;
215215 break ;
216216 case Messages::TouchWakeUp: {
217- if (touchHandler.ProcessTouchInfo (touchPanel.GetTouchInfo ())) {
217+ Pinetime::Controllers::TouchHandler::TouchProcessReply reply;
218+ reply = touchHandler.ProcessTouchInfo (touchPanel.GetTouchInfo (), settingsController.isWakeUpModeOn (Pinetime::Controllers::Settings::WakeUpMode::ButtonUnlocks));
219+ if (reply == Pinetime::Controllers::TouchHandler::TouchProcessReply::TouchEvent) {
218220 auto gesture = touchHandler.GestureGet ();
219221 if (settingsController.GetNotificationStatus () != Controllers::Settings::Notification::Sleep &&
220222 gesture != Pinetime::Applications::TouchEvents::None &&
221223 ((gesture == Pinetime::Applications::TouchEvents::DoubleTap &&
222224 settingsController.isWakeUpModeOn (Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) ||
223225 (gesture == Pinetime::Applications::TouchEvents::Tap &&
224226 settingsController.isWakeUpModeOn (Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
227+ touchHandler.SetIfButtonUnlocksIgnoreTouch (true );
228+ touchHandler.SetWokenBy (Pinetime::Controllers::TouchHandler::WokenBy::WakeUpAction);
225229 GoToRunning ();
226230 }
227231 }
228232 break ;
229233 }
230234 case Messages::GoToSleep:
235+ touchHandler.SetIgnoreTouchPopupHidden (true );
236+ displayApp.PushMessage (Pinetime::Applications::Display::Messages::HideIgnoreTouchPopup);
231237 if (doNotGoToSleep) {
232238 break ;
233239 }
@@ -291,24 +297,42 @@ void SystemTask::Work() {
291297 // TODO add intent of fs access icon or something
292298 break ;
293299 case Messages::OnTouchEvent:
294- if (touchHandler.ProcessTouchInfo (touchPanel.GetTouchInfo ())) {
300+ Pinetime::Controllers::TouchHandler::TouchProcessReply reply;
301+ reply = touchHandler.ProcessTouchInfo (touchPanel.GetTouchInfo (), settingsController.isWakeUpModeOn (Pinetime::Controllers::Settings::WakeUpMode::ButtonUnlocks));
302+ NRF_LOG_INFO (" [systemtask] OnTouchEvent, reply %d" , reply);
303+
304+ if (reply == Pinetime::Controllers::TouchHandler::TouchProcessReply::TouchEvent) {
295305 displayApp.PushMessage (Pinetime::Applications::Display::Messages::TouchEvent);
306+ } else if (reply == Pinetime::Controllers::TouchHandler::TouchProcessReply::IgnoreTouchPopup) {
307+ displayApp.PushMessage (Pinetime::Applications::Display::Messages::ShowIgnoreTouchPopup);
308+ touchHandler.SetIgnoreTouchPopupHidden (false );
296309 }
297310 break ;
298311 case Messages::HandleButtonEvent: {
299- Controllers::ButtonActions action = Controllers::ButtonActions::None;
300- if (nrf_gpio_pin_read (Pinetime::PinMap::Button) == 0 ) {
301- action = buttonHandler.HandleEvent (Controllers::ButtonHandler::Events::Release);
302- } else {
303- action = buttonHandler.HandleEvent (Controllers::ButtonHandler::Events::Press);
304- // This is for faster wakeup, sacrificing special longpress and doubleclick handling while sleeping
305- if (IsSleeping ()) {
306- fastWakeUpDone = true ;
307- GoToRunning ();
308- break ;
312+ // if the IgnoreTouchPopup is active the first button event unlocks the device
313+ if (!touchHandler.IsIgnoreTouchPopupHidden ()) {
314+ touchHandler.SetWokenBy (Pinetime::Controllers::TouchHandler::WokenBy::Button);
315+ touchHandler.SetIfButtonUnlocksIgnoreTouch (false );
316+ touchHandler.SetIgnoreTouchPopupHidden (true );
317+ displayApp.PushMessage (Pinetime::Applications::Display::Messages::HideIgnoreTouchPopup);
318+ }
319+ else {
320+ Controllers::ButtonActions action = Controllers::ButtonActions::None;
321+ if (nrf_gpio_pin_read (Pinetime::PinMap::Button) == 0 ) {
322+ action = buttonHandler.HandleEvent (Controllers::ButtonHandler::Events::Release);
323+ } else {
324+ action = buttonHandler.HandleEvent (Controllers::ButtonHandler::Events::Press);
325+ touchHandler.SetWokenBy (Pinetime::Controllers::TouchHandler::WokenBy::Button);
326+ touchHandler.SetIfButtonUnlocksIgnoreTouch (false );
327+ // This is for faster wakeup, sacrificing special longpress and doubleclick handling while sleeping
328+ if (IsSleeping ()) {
329+ fastWakeUpDone = true ;
330+ GoToRunning ();
331+ break ;
332+ }
309333 }
334+ HandleButtonAction (action);
310335 }
311- HandleButtonAction (action);
312336 } break ;
313337 case Messages::HandleButtonTimerEvent: {
314338 auto action = buttonHandler.HandleEvent (Controllers::ButtonHandler::Events::Timer);
@@ -328,6 +352,8 @@ void SystemTask::Work() {
328352 }
329353
330354 state = SystemTaskState::Sleeping;
355+ touchHandler.SetWokenBy (Pinetime::Controllers::TouchHandler::WokenBy::Other);
356+ touchHandler.SetIfButtonUnlocksIgnoreTouch (false );
331357 break ;
332358 case Messages::OnNewDay:
333359 // We might be sleeping (with TWI device disabled.
@@ -433,6 +459,8 @@ void SystemTask::UpdateMotion() {
433459 motionController.ShouldRaiseWake (state == SystemTaskState::Sleeping)) ||
434460 (settingsController.isWakeUpModeOn (Pinetime::Controllers::Settings::WakeUpMode::Shake) &&
435461 motionController.ShouldShakeWake (settingsController.GetShakeThreshold ()))) {
462+ touchHandler.SetWokenBy (Pinetime::Controllers::TouchHandler::WokenBy::WakeUpAction);
463+ touchHandler.SetIfButtonUnlocksIgnoreTouch (true );
436464 GoToRunning ();
437465 }
438466 }
0 commit comments