From 7066ff5aba3d2643a35ba98379ff24143da99c3c Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Thu, 23 Feb 2023 13:28:04 +0200 Subject: touchhandler: Remove LVGL dependency Move LVGL specific code to the LittleVgl class --- src/displayapp/LittleVgl.cpp | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'src/displayapp/LittleVgl.cpp') diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index cc1223fb..1326c566 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -179,15 +179,34 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { lv_disp_flush_ready(&disp_drv); } -void LittleVgl::SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) { - tap_x = x; - tap_y = y; - tapped = contact; +void LittleVgl::SetNewTouchPoint(int16_t x, int16_t y, bool contact) { + if (contact) { + if (!isCancelled) { + touchPoint = {x, y}; + tapped = true; + } + } else { + if (isCancelled) { + touchPoint = {-1, -1}; + tapped = false; + isCancelled = false; + } else { + touchPoint = {x, y}; + tapped = false; + } + } +} + +void LittleVgl::CancelTap() { + if (tapped) { + isCancelled = true; + touchPoint = {-1, -1}; + } } bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) { - ptr->point.x = tap_x; - ptr->point.y = tap_y; + ptr->point.x = touchPoint.x; + ptr->point.y = touchPoint.y; if (tapped) { ptr->state = LV_INDEV_STATE_PR; } else { -- cgit v1.2.3-70-g09d2