From dc9d213fc5c08fae2f89604de8e2b818660ace0f Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Sat, 11 Sep 2021 12:04:33 +1000 Subject: [PATCH] Implement tap count for NV14 --- radio/src/targets/nv14/touch_driver.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/radio/src/targets/nv14/touch_driver.cpp b/radio/src/targets/nv14/touch_driver.cpp index f92d4c52a..7823d364e 100644 --- a/radio/src/targets/nv14/touch_driver.cpp +++ b/radio/src/targets/nv14/touch_driver.cpp @@ -42,6 +42,11 @@ volatile static bool touchEventOccured; uint8_t ft6x06[FT6x06_MAX_INSTANCE] = {0}; static ft6x06_handle_TypeDef ft6x06_handle = {FT6206_I2C_NOT_INITIALIZED, 0, 0}; +tmr10ms_t downTime = 0; +tmr10ms_t tapTime = 0; +short tapCount = 0; +#define TAP_TIME 25 + void I2C_FreeBus() { GPIO_InitTypeDef GPIO_InitStructure; @@ -514,12 +519,25 @@ void touchPanelRead() touchEventOccured = false; + tmr10ms_t now = get_tmr10ms(); + touchState.tapCount = 0; + if (ft6x06_TS_DetectTouch(TOUCH_FT6236_I2C_ADDRESS)) { handleTouch(); + if (touchState.event == TE_DOWN) + downTime = now; } else { if (touchState.event == TE_DOWN) { touchState.event = TE_UP; + if (now - downTime <= TAP_TIME) { + if (now - tapTime > TAP_TIME) + tapCount = 1; + else + tapCount++; + touchState.tapCount = tapCount; + tapTime = now; + } } else { touchState.x = LCD_WIDTH;