Clear ongoing taps when going to sleep

This commit is contained in:
mark9064 2024-08-22 16:53:18 +01:00
parent 997e4cee8c
commit 99e5fab060
3 changed files with 14 additions and 0 deletions

View file

@ -314,6 +314,10 @@ void DisplayApp::Refresh() {
} else { } else {
lcd.Sleep(); lcd.Sleep();
} }
// 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();
PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping); PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping);
state = States::Idle; state = States::Idle;
break; break;

View file

@ -248,6 +248,8 @@ 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() { void LittleVgl::CancelTap() {
if (tapped) { if (tapped) {
isCancelled = true; isCancelled = true;
@ -255,6 +257,13 @@ void LittleVgl::CancelTap() {
} }
} }
// Clear the current tapped state
// Signifies that touch input processing is suspended
void LittleVgl::ClearTouchState() {
touchPoint = {-1, -1};
tapped = false;
}
bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) { bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
ptr->point.x = touchPoint.x; ptr->point.x = touchPoint.x;
ptr->point.y = touchPoint.y; ptr->point.y = touchPoint.y;

View file

@ -26,6 +26,7 @@ namespace Pinetime {
void SetFullRefresh(FullRefreshDirections direction); void SetFullRefresh(FullRefreshDirections direction);
void SetNewTouchPoint(int16_t x, int16_t y, bool contact); void SetNewTouchPoint(int16_t x, int16_t y, bool contact);
void CancelTap(); void CancelTap();
void ClearTouchState();
bool GetFullRefresh() { bool GetFullRefresh() {
bool returnValue = fullRefresh; bool returnValue = fullRefresh;