From dc9d213fc5c08fae2f89604de8e2b818660ace0f Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Sat, 11 Sep 2021 12:04:33 +1000 Subject: [PATCH 1/4] 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; From f70f247302d735f954ea8ebc2e531f49f97d38ec Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Sat, 11 Sep 2021 18:43:13 +1000 Subject: [PATCH 2/4] Catch press and hold state --- radio/src/targets/nv14/touch_driver.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/radio/src/targets/nv14/touch_driver.cpp b/radio/src/targets/nv14/touch_driver.cpp index 7823d364e..14def7ee8 100644 --- a/radio/src/targets/nv14/touch_driver.cpp +++ b/radio/src/targets/nv14/touch_driver.cpp @@ -524,7 +524,7 @@ void touchPanelRead() if (ft6x06_TS_DetectTouch(TOUCH_FT6236_I2C_ADDRESS)) { handleTouch(); - if (touchState.event == TE_DOWN) + if (touchState.event == TE_DOWN && downTime == 0) downTime = now; } else { @@ -537,9 +537,11 @@ void touchPanelRead() tapCount++; touchState.tapCount = tapCount; tapTime = now; + } else { + touchState.tapCount = 0; //not a tap } - } - else { + downTime = 0; + } else { touchState.x = LCD_WIDTH; touchState.y = LCD_HEIGHT; touchState.event = TE_SLIDE_END; From b454bb8c43468d932abb763caa9b91e8434f6f9c Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Sat, 11 Sep 2021 18:44:57 +1000 Subject: [PATCH 3/4] Formatting --- radio/src/targets/nv14/touch_driver.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/radio/src/targets/nv14/touch_driver.cpp b/radio/src/targets/nv14/touch_driver.cpp index 14def7ee8..24cac860d 100644 --- a/radio/src/targets/nv14/touch_driver.cpp +++ b/radio/src/targets/nv14/touch_driver.cpp @@ -514,8 +514,7 @@ bool touchPanelEventOccured() void touchPanelRead() { - if (!touchEventOccured) - return; + if (!touchEventOccured) return; touchEventOccured = false; @@ -524,21 +523,22 @@ void touchPanelRead() if (ft6x06_TS_DetectTouch(TOUCH_FT6236_I2C_ADDRESS)) { handleTouch(); - if (touchState.event == TE_DOWN && downTime == 0) + if (touchState.event == TE_DOWN && downTime == 0) { downTime = now; - } - else { + } + } else { if (touchState.event == TE_DOWN) { touchState.event = TE_UP; if (now - downTime <= TAP_TIME) { - if (now - tapTime > TAP_TIME) + if (now - tapTime > TAP_TIME) { tapCount = 1; - else + } else { tapCount++; + } touchState.tapCount = tapCount; tapTime = now; } else { - touchState.tapCount = 0; //not a tap + touchState.tapCount = 0; // not a tap } downTime = 0; } else { From 3d0cedc1c8f84a06c2afb62ee730bb2939d5715a Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Sat, 11 Sep 2021 18:48:56 +1000 Subject: [PATCH 4/4] Update header --- radio/src/targets/nv14/touch_driver.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/radio/src/targets/nv14/touch_driver.cpp b/radio/src/targets/nv14/touch_driver.cpp index 24cac860d..338296079 100644 --- a/radio/src/targets/nv14/touch_driver.cpp +++ b/radio/src/targets/nv14/touch_driver.cpp @@ -1,7 +1,8 @@ /* - * Copyright (C) OpenTX + * Copyright (C) EdgeTX * * Based on code named + * opentx - https://github.com/opentx/opentx * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x