From f342ea3378ebfab3a97bdb0bc9404ca67d1444e8 Mon Sep 17 00:00:00 2001 From: mark9064 <30447455+mark9064@users.noreply.github.com> Date: Thu, 29 Aug 2024 16:39:55 +0100 Subject: [PATCH] Resolve paint corrupting screen scrolling --- src/displayapp/LittleVgl.cpp | 4 ++++ src/displayapp/LittleVgl.h | 1 + src/displayapp/screens/InfiniPaint.cpp | 7 ++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index c6f6f78477..f9791c302d 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -149,6 +149,10 @@ void LittleVgl::SetFullRefresh(FullRefreshDirections direction) { fullRefresh = true; } +bool LittleVgl::IsScrolling() { + return scrollDirection != LittleVgl::FullRefreshDirections::None; +} + void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { uint16_t y1, y2, width, height = 0; diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index 54505b365d..e19c9b568c 100644 --- a/src/displayapp/LittleVgl.h +++ b/src/displayapp/LittleVgl.h @@ -27,6 +27,7 @@ namespace Pinetime { void SetNewTouchPoint(int16_t x, int16_t y, bool contact); void CancelTap(); void ClearTouchState(); + bool IsScrolling(); bool GetFullRefresh() { bool returnValue = fullRefresh; diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp index 1d6be97930..958d7939fd 100644 --- a/src/displayapp/screens/InfiniPaint.cpp +++ b/src/displayapp/screens/InfiniPaint.cpp @@ -61,12 +61,17 @@ bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } bool InfiniPaint::OnTouchEvent(uint16_t x, uint16_t y) { + // If currently scrolling in or out of InfiniPaint, don't paint anything! + // Since InfiniPaint writes directly to the display bypassing LVGL, painting + // while scrolling is happening causes bad behaviour + if (lvgl.IsScrolling()) { + return false; + } lv_area_t area; area.x1 = x - (width / 2); area.y1 = y - (height / 2); area.x2 = x + (width / 2) - 1; area.y2 = y + (height / 2) - 1; - lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::None); lvgl.FlushDisplay(&area, b); return true; }