Merge pull request #704 from EdgeTX/nv14-doubletap
Implement tap count for NV14 TP also
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) OpenTX
|
* Copyright (C) EdgeTX
|
||||||
*
|
*
|
||||||
* Based on code named
|
* Based on code named
|
||||||
|
* opentx - https://github.com/opentx/opentx
|
||||||
* th9x - http://code.google.com/p/th9x
|
* th9x - http://code.google.com/p/th9x
|
||||||
* er9x - http://code.google.com/p/er9x
|
* er9x - http://code.google.com/p/er9x
|
||||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
@@ -42,6 +43,11 @@ volatile static bool touchEventOccured;
|
|||||||
uint8_t ft6x06[FT6x06_MAX_INSTANCE] = {0};
|
uint8_t ft6x06[FT6x06_MAX_INSTANCE] = {0};
|
||||||
static ft6x06_handle_TypeDef ft6x06_handle = {FT6206_I2C_NOT_INITIALIZED, 0, 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()
|
void I2C_FreeBus()
|
||||||
{
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
@@ -509,19 +515,34 @@ bool touchPanelEventOccured()
|
|||||||
|
|
||||||
void touchPanelRead()
|
void touchPanelRead()
|
||||||
{
|
{
|
||||||
if (!touchEventOccured)
|
if (!touchEventOccured) return;
|
||||||
return;
|
|
||||||
|
|
||||||
touchEventOccured = false;
|
touchEventOccured = false;
|
||||||
|
|
||||||
|
tmr10ms_t now = get_tmr10ms();
|
||||||
|
touchState.tapCount = 0;
|
||||||
|
|
||||||
if (ft6x06_TS_DetectTouch(TOUCH_FT6236_I2C_ADDRESS)) {
|
if (ft6x06_TS_DetectTouch(TOUCH_FT6236_I2C_ADDRESS)) {
|
||||||
handleTouch();
|
handleTouch();
|
||||||
}
|
if (touchState.event == TE_DOWN && downTime == 0) {
|
||||||
else {
|
downTime = now;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (touchState.event == TE_DOWN) {
|
if (touchState.event == TE_DOWN) {
|
||||||
touchState.event = TE_UP;
|
touchState.event = TE_UP;
|
||||||
}
|
if (now - downTime <= TAP_TIME) {
|
||||||
else {
|
if (now - tapTime > TAP_TIME) {
|
||||||
|
tapCount = 1;
|
||||||
|
} else {
|
||||||
|
tapCount++;
|
||||||
|
}
|
||||||
|
touchState.tapCount = tapCount;
|
||||||
|
tapTime = now;
|
||||||
|
} else {
|
||||||
|
touchState.tapCount = 0; // not a tap
|
||||||
|
}
|
||||||
|
downTime = 0;
|
||||||
|
} else {
|
||||||
touchState.x = LCD_WIDTH;
|
touchState.x = LCD_WIDTH;
|
||||||
touchState.y = LCD_HEIGHT;
|
touchState.y = LCD_HEIGHT;
|
||||||
touchState.event = TE_SLIDE_END;
|
touchState.event = TE_SLIDE_END;
|
||||||
|
|||||||
Reference in New Issue
Block a user