From 76bc7b5c2956e65e3a0d715c932018401a8b90ef Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 20 Mar 2020 18:04:17 +0100 Subject: [PATCH] Slide energy taken into account --- radio/src/simu.cpp | 2 +- radio/src/targets/nv14/touch_driver.cpp | 36 +++++++++++++------------ radio/src/thirdparty/libopenui | 2 +- radio/src/touch.h | 4 ++- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/radio/src/simu.cpp b/radio/src/simu.cpp index 20f5cfd0c..9e18ef0f9 100644 --- a/radio/src/simu.cpp +++ b/radio/src/simu.cpp @@ -282,7 +282,7 @@ long OpenTxSim::onMouseUp(FXObject*,FXSelector,void*v) touchState.y = touchState.startY; } else { - touchState.event = TE_NONE; + touchState.event = TE_SLIDE_END; } #endif diff --git a/radio/src/targets/nv14/touch_driver.cpp b/radio/src/targets/nv14/touch_driver.cpp index 9e019eaa1..72234dd0d 100644 --- a/radio/src/targets/nv14/touch_driver.cpp +++ b/radio/src/targets/nv14/touch_driver.cpp @@ -451,8 +451,8 @@ void handleTouch() unsigned short touchY; uint32_t tEvent = 0; ft6x06_TS_GetXY(TOUCH_FT6236_I2C_ADDRESS, &touchX, &touchY, &tEvent); - //uint32_t gesture; - //ft6x06_TS_GetGestureID(TOUCH_FT6236_I2C_ADDRESS, &gesture); + // uint32_t gesture; + // ft6x06_TS_GetGestureID(TOUCH_FT6236_I2C_ADDRESS, &gesture); #if defined( LCD_DIRECTION ) && (LCD_DIRECTION == LCD_VERTICAL) touchX = LCD_WIDTH - touchX; touchY = LCD_HEIGHT - touchY; @@ -468,20 +468,18 @@ void handleTouch() touchState.x = touchX; touchState.y = touchY; - if (touchState.event == TE_NONE || touchState.event == TE_UP) - { + if (touchState.event == TE_NONE || touchState.event == TE_UP) { touchState.startX = touchState.x; touchState.startY = touchState.y; touchState.event = TE_DOWN; if (g_eeGeneral.backlightMode & e_backlight_mode_keys) backlightOn(); // TODO is that the best place ? } - else if (touchState.event == TE_DOWN) - { - if ((dx >= SLIDE_RANGE) || (dx <= -SLIDE_RANGE) || (dy >= SLIDE_RANGE)|| (dy <= -SLIDE_RANGE)) { + else if (touchState.event == TE_DOWN) { + if (dx >= SLIDE_RANGE || dx <= -SLIDE_RANGE || dy >= SLIDE_RANGE || dy <= -SLIDE_RANGE) { touchState.event = TE_SLIDE; - touchState.deltaX = (short)dx; - touchState.deltaY = (short)dy; + touchState.deltaX = (short) dx; + touchState.deltaY = (short) dy; } else { touchState.event = TE_DOWN; @@ -489,11 +487,10 @@ void handleTouch() touchState.deltaY = 0; } } - else if (touchState.event == TE_SLIDE) - { + else if (touchState.event == TE_SLIDE) { touchState.event = TE_SLIDE; //no change - touchState.deltaX = (short)dx; - touchState.deltaY = (short)dy; + touchState.deltaX = (short) dx; + touchState.deltaY = (short) dy; } } @@ -512,19 +509,24 @@ bool touchPanelEventOccured() return touchEventOccured; } -void touchPanelRead() { - if(!touchEventOccured) return; +void touchPanelRead() +{ + if (!touchEventOccured) + return; + touchEventOccured = false; + if (ft6x06_TS_DetectTouch(TOUCH_FT6236_I2C_ADDRESS)) { handleTouch(); - } else { + } + else { if (touchState.event == TE_DOWN) { touchState.event = TE_UP; } else { touchState.x = LCD_WIDTH; touchState.y = LCD_HEIGHT; - touchState.event = TE_NONE; + touchState.event = TE_SLIDE_END; } } } diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index d0634734b..2b515b888 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit d0634734b4a4edf7505368333daff0a118cb2f17 +Subproject commit 2b515b888a440c575049b219f26784ed59f6cf26 diff --git a/radio/src/touch.h b/radio/src/touch.h index 76f912bd6..31bf94f58 100644 --- a/radio/src/touch.h +++ b/radio/src/touch.h @@ -27,7 +27,7 @@ enum TouchEvent TE_DOWN, TE_UP, TE_SLIDE, - TE_END + TE_SLIDE_END }; struct TouchState @@ -39,6 +39,8 @@ struct TouchState short startY; short deltaX; short deltaY; + short lastDeltaX; + short lastDeltaY; }; constexpr uint8_t SLIDE_RANGE = 6;