From 1808634f0e041ed1c85b69a967207c2cff812d81 Mon Sep 17 00:00:00 2001 From: mark9064 <30447455+mark9064@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:53:18 +0100 Subject: [PATCH] Clear ongoing taps when going to sleep --- src/displayapp/DisplayApp.cpp | 4 ++++ src/displayapp/LittleVgl.cpp | 9 +++++++++ src/displayapp/LittleVgl.h | 1 + 3 files changed, 14 insertions(+) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 98a28258..5d33f76e 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -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 diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index c70a0856..c6f6f784 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -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() { if (tapped) { 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) { ptr->point.x = touchPoint.x; ptr->point.y = touchPoint.y; diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index 9a15ae15..54505b36 100644 --- a/src/displayapp/LittleVgl.h +++ b/src/displayapp/LittleVgl.h @@ -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;