Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear ongoing taps when going to sleep #2108

Merged
merged 4 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/displayapp/DisplayApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ void DisplayApp::Refresh() {
while (!lv_task_handler()) {
};
}
// Clear any ongoing touch pressed events
// Without this LVGL gets stuck in the pressed state and will keep refreshing the
// display activity timer causing the screen to never sleep after timeout
lvgl.ClearTouchState();
if (msg == Messages::GoToAOD) {
lcd.LowPowerOn();
// Record idle entry time
Expand Down Expand Up @@ -468,7 +472,7 @@ void DisplayApp::Refresh() {
}
}

if (touchHandler.IsTouching()) {
if (state == States::Running && touchHandler.IsTouching()) {
currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY());
}

Expand Down
9 changes: 9 additions & 0 deletions src/displayapp/LittleVgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,22 @@ void LittleVgl::SetNewTouchPoint(int16_t x, int16_t y, bool contact) {
}
}

// Cancel an ongoing tap
// Signifies that LVGL should not handle the current tap
void LittleVgl::CancelTap() {
if (tapped) {
isCancelled = true;
touchPoint = {-1, -1};
}
}

// Clear the current tapped state
// Signifies that touch input processing is suspended
void LittleVgl::ClearTouchState() {
touchPoint = {-1, -1};
mark9064 marked this conversation as resolved.
Show resolved Hide resolved
tapped = false;
}

bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
ptr->point.x = touchPoint.x;
ptr->point.y = touchPoint.y;
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/LittleVgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Pinetime {
void SetFullRefresh(FullRefreshDirections direction);
void SetNewTouchPoint(int16_t x, int16_t y, bool contact);
void CancelTap();
void ClearTouchState();

bool GetFullRefresh() {
bool returnValue = fullRefresh;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> NoI

void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
if (pin == Pinetime::PinMap::Cst816sIrq) {
systemTask.OnTouchEvent();
systemTask.PushMessage(Pinetime::System::Messages::OnTouchEvent);
return;
}

Expand Down
1 change: 0 additions & 1 deletion src/systemtask/Messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace Pinetime {
enum class Messages : uint8_t {
GoToSleep,
GoToRunning,
TouchWakeUp,
OnNewTime,
OnNewNotification,
OnNewCall,
Expand Down
42 changes: 16 additions & 26 deletions src/systemtask/SystemTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,6 @@ void SystemTask::Work() {
case Messages::GoToRunning:
GoToRunning();
break;
case Messages::TouchWakeUp: {
if (touchHandler.ProcessTouchInfo(touchPanel.GetTouchInfo())) {
auto gesture = touchHandler.GestureGet();
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
gesture != Pinetime::Applications::TouchEvents::None &&
((gesture == Pinetime::Applications::TouchEvents::DoubleTap &&
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) ||
(gesture == Pinetime::Applications::TouchEvents::Tap &&
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
GoToRunning();
}
}
break;
}
case Messages::GoToSleep:
GoToSleep();
break;
Expand Down Expand Up @@ -260,8 +246,23 @@ void SystemTask::Work() {
// TODO add intent of fs access icon or something
break;
case Messages::OnTouchEvent:
if (touchHandler.ProcessTouchInfo(touchPanel.GetTouchInfo())) {
// Finish immediately if no new events
if (!touchHandler.ProcessTouchInfo(touchPanel.GetTouchInfo())) {
break;
}
if (state == SystemTaskState::Running) {
displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
} else {
// If asleep, check for touch panel wake triggers
auto gesture = touchHandler.GestureGet();
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
gesture != Pinetime::Applications::TouchEvents::None &&
((gesture == Pinetime::Applications::TouchEvents::DoubleTap &&
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) ||
(gesture == Pinetime::Applications::TouchEvents::Tap &&
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
GoToRunning();
}
}
break;
case Messages::HandleButtonEvent: {
Expand Down Expand Up @@ -492,17 +493,6 @@ void SystemTask::HandleButtonAction(Controllers::ButtonActions action) {
fastWakeUpDone = false;
}

void SystemTask::OnTouchEvent() {
if (state == SystemTaskState::Running) {
PushMessage(Messages::OnTouchEvent);
} else {
if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap) or
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
PushMessage(Messages::TouchWakeUp);
}
}
}

void SystemTask::PushMessage(System::Messages msg) {
if (in_isr()) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
Expand Down
2 changes: 0 additions & 2 deletions src/systemtask/SystemTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ namespace Pinetime {
void Start();
void PushMessage(Messages msg);

void OnTouchEvent();

bool IsSleepDisabled() {
return wakeLocksHeld > 0;
}
Expand Down
Loading