touch on/off with backlight on/off is now working for TX16s, untested, but implemented for NV14
simulator for tX16s and NV14 works
This commit is contained in:
@@ -540,8 +540,9 @@ void checkBacklight()
|
|||||||
resetBacklightTimeout();
|
resetBacklightTimeout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(HARDWARE_TOUCH) && defined(PCBNV14)
|
|
||||||
if (touchPanelEventOccured() && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) {
|
#if defined(HARDWARE_TOUCH) /*&& defined(PCBNV14)*/
|
||||||
|
if (MainWindow::instance()->touchEventOccured() && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) {
|
||||||
resetBacklightTimeout();
|
resetBacklightTimeout();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -597,11 +597,16 @@ void backlightEnable(uint8_t dutyCycle = 0);
|
|||||||
#else
|
#else
|
||||||
#define BACKLIGHT_LEVEL_MIN 46
|
#define BACKLIGHT_LEVEL_MIN 46
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(SIMU)
|
||||||
|
#define BACKLIGHT_ENABLE()
|
||||||
|
#define BACKLIGHT_DISABLE()
|
||||||
|
#define isBacklightEnabled(...) true
|
||||||
|
#else
|
||||||
extern bool boardBacklightOn;
|
extern bool boardBacklightOn;
|
||||||
#define BACKLIGHT_ENABLE() {boardBacklightOn = true; backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : BACKLIGHT_LEVEL_MAX - currentBacklightBright);}
|
#define BACKLIGHT_ENABLE() {boardBacklightOn = true; backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : BACKLIGHT_LEVEL_MAX - currentBacklightBright);}
|
||||||
#define BACKLIGHT_DISABLE() {boardBacklightOn = false; backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : ((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && (g_eeGeneral.backlightMode != e_backlight_mode_off)) ? 0 : g_eeGeneral.blOffBright);}
|
#define BACKLIGHT_DISABLE() {boardBacklightOn = false; backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : ((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && (g_eeGeneral.backlightMode != e_backlight_mode_off)) ? 0 : g_eeGeneral.blOffBright);}
|
||||||
bool isBacklightEnabled();
|
bool isBacklightEnabled();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
void usbJoystickUpdate();
|
void usbJoystickUpdate();
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ short tapCount = 0;
|
|||||||
|
|
||||||
I2C_HandleTypeDef hi2c1;
|
I2C_HandleTypeDef hi2c1;
|
||||||
|
|
||||||
static TouchState internalTouchState ={};
|
static TouchState internalTouchState = {};
|
||||||
|
|
||||||
static void TOUCH_AF_ExtiStop(void)
|
static void TOUCH_AF_ExtiStop(void)
|
||||||
{
|
{
|
||||||
@@ -810,10 +810,6 @@ struct TouchState touchPanelRead()
|
|||||||
extern "C" void TOUCH_INT_EXTI_IRQHandler1(void)
|
extern "C" void TOUCH_INT_EXTI_IRQHandler1(void)
|
||||||
{
|
{
|
||||||
if (EXTI_GetITStatus(TOUCH_INT_EXTI_LINE1) != RESET) {
|
if (EXTI_GetITStatus(TOUCH_INT_EXTI_LINE1) != RESET) {
|
||||||
if (g_eeGeneral.backlightMode & e_backlight_mode_keys) {
|
|
||||||
// on touch turn the light on
|
|
||||||
resetBacklightTimeout();
|
|
||||||
}
|
|
||||||
touchEventOccured = true;
|
touchEventOccured = true;
|
||||||
EXTI_ClearITPendingBit(TOUCH_INT_EXTI_LINE1);
|
EXTI_ClearITPendingBit(TOUCH_INT_EXTI_LINE1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -553,6 +553,6 @@ extern AuxSerialRxFifo auxSerialRxFifo;
|
|||||||
|
|
||||||
// Touch panel driver
|
// Touch panel driver
|
||||||
bool touchPanelEventOccured();
|
bool touchPanelEventOccured();
|
||||||
void touchPanelRead();
|
struct TouchState touchPanelRead();
|
||||||
|
|
||||||
#endif // _BOARD_H_
|
#endif // _BOARD_H_
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ tmr10ms_t tapTime = 0;
|
|||||||
short tapCount = 0;
|
short tapCount = 0;
|
||||||
#define TAP_TIME 25
|
#define TAP_TIME 25
|
||||||
|
|
||||||
|
static TouchState internalTouchState = {};
|
||||||
|
|
||||||
void I2C_FreeBus()
|
void I2C_FreeBus()
|
||||||
{
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
@@ -468,33 +470,33 @@ void handleTouch()
|
|||||||
touchX = tmp;
|
touchX = tmp;
|
||||||
#endif
|
#endif
|
||||||
if (tEvent == FT6206_TOUCH_EVT_FLAG_CONTACT) {
|
if (tEvent == FT6206_TOUCH_EVT_FLAG_CONTACT) {
|
||||||
int dx = touchX - touchState.x;
|
int dx = touchX - internalTouchState.x;
|
||||||
int dy = touchY - touchState.y;
|
int dy = touchY - internalTouchState.y;
|
||||||
|
|
||||||
touchState.x = touchX;
|
internalTouchState.x = touchX;
|
||||||
touchState.y = touchY;
|
internalTouchState.y = touchY;
|
||||||
|
|
||||||
if (touchState.event == TE_NONE || touchState.event == TE_UP || touchState.event == TE_SLIDE_END) {
|
if (internalTouchState.event == TE_NONE || internalTouchState.event == TE_UP || internalTouchState.event == TE_SLIDE_END) {
|
||||||
touchState.startX = touchState.x;
|
internalTouchState.startX = internalTouchState.x;
|
||||||
touchState.startY = touchState.y;
|
internalTouchState.startY = internalTouchState.y;
|
||||||
touchState.event = TE_DOWN;
|
internalTouchState.event = TE_DOWN;
|
||||||
}
|
}
|
||||||
else if (touchState.event == TE_DOWN) {
|
else if (internalTouchState.event == TE_DOWN) {
|
||||||
if (dx >= SLIDE_RANGE || dx <= -SLIDE_RANGE || dy >= SLIDE_RANGE || dy <= -SLIDE_RANGE) {
|
if (dx >= SLIDE_RANGE || dx <= -SLIDE_RANGE || dy >= SLIDE_RANGE || dy <= -SLIDE_RANGE) {
|
||||||
touchState.event = TE_SLIDE;
|
internalTouchState.event = TE_SLIDE;
|
||||||
touchState.deltaX = (short) dx;
|
internalTouchState.deltaX = (short) dx;
|
||||||
touchState.deltaY = (short) dy;
|
internalTouchState.deltaY = (short) dy;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
touchState.event = TE_DOWN;
|
internalTouchState.event = TE_DOWN;
|
||||||
touchState.deltaX = 0;
|
internalTouchState.deltaX = 0;
|
||||||
touchState.deltaY = 0;
|
internalTouchState.deltaY = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (touchState.event == TE_SLIDE) {
|
else if (internalTouchState.event == TE_SLIDE) {
|
||||||
touchState.event = TE_SLIDE; //no change
|
internalTouchState.event = TE_SLIDE; //no change
|
||||||
touchState.deltaX = (short) dx;
|
internalTouchState.deltaX = (short) dx;
|
||||||
touchState.deltaY = (short) dy;
|
internalTouchState.deltaY = (short) dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -513,39 +515,40 @@ bool touchPanelEventOccured()
|
|||||||
return touchEventOccured;
|
return touchEventOccured;
|
||||||
}
|
}
|
||||||
|
|
||||||
void touchPanelRead()
|
TouchState touchPanelRead()
|
||||||
{
|
{
|
||||||
if (!touchEventOccured) return;
|
if (!touchEventOccured) return internalTouchState;
|
||||||
|
|
||||||
touchEventOccured = false;
|
touchEventOccured = false;
|
||||||
|
|
||||||
tmr10ms_t now = get_tmr10ms();
|
tmr10ms_t now = get_tmr10ms();
|
||||||
touchState.tapCount = 0;
|
internalTouchState.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) {
|
if (internalTouchState.event == TE_DOWN && downTime == 0) {
|
||||||
downTime = now;
|
downTime = now;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (touchState.event == TE_DOWN) {
|
if (internalTouchState.event == TE_DOWN) {
|
||||||
touchState.event = TE_UP;
|
internalTouchState.event = TE_UP;
|
||||||
if (now - downTime <= TAP_TIME) {
|
if (now - downTime <= TAP_TIME) {
|
||||||
if (now - tapTime > TAP_TIME) {
|
if (now - tapTime > TAP_TIME) {
|
||||||
tapCount = 1;
|
tapCount = 1;
|
||||||
} else {
|
} else {
|
||||||
tapCount++;
|
tapCount++;
|
||||||
}
|
}
|
||||||
touchState.tapCount = tapCount;
|
internalTouchState.tapCount = tapCount;
|
||||||
tapTime = now;
|
tapTime = now;
|
||||||
} else {
|
} else {
|
||||||
touchState.tapCount = 0; // not a tap
|
internalTouchState.tapCount = 0; // not a tap
|
||||||
}
|
}
|
||||||
downTime = 0;
|
downTime = 0;
|
||||||
} else {
|
} else {
|
||||||
touchState.x = LCD_WIDTH;
|
internalTouchState.x = LCD_WIDTH;
|
||||||
touchState.y = LCD_HEIGHT;
|
internalTouchState.y = LCD_HEIGHT;
|
||||||
touchState.event = TE_SLIDE_END;
|
internalTouchState.event = TE_SLIDE_END;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return internalTouchState;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ void OpenTxSimulator::touchEvent(int type, int x, int y)
|
|||||||
{
|
{
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
tmr10ms_t now = get_tmr10ms();
|
tmr10ms_t now = get_tmr10ms();
|
||||||
touchState.tapCount = 0;
|
simTouchState.tapCount = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -323,9 +323,9 @@ void OpenTxSimulator::touchEvent(int type, int x, int y)
|
|||||||
TRACE_WINDOWS("[Mouse Press] %d %d", x, y);
|
TRACE_WINDOWS("[Mouse Press] %d %d", x, y);
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
touchState.event = TE_DOWN;
|
simTouchState.event = TE_DOWN;
|
||||||
touchState.startX = touchState.x = x;
|
simTouchState.startX = simTouchState.x = x;
|
||||||
touchState.startY = touchState.y = y;
|
simTouchState.startY = simTouchState.y = y;
|
||||||
downTime = now;
|
downTime = now;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
@@ -334,20 +334,20 @@ void OpenTxSimulator::touchEvent(int type, int x, int y)
|
|||||||
TRACE_WINDOWS("[Mouse Release] %d %d", x, y);
|
TRACE_WINDOWS("[Mouse Release] %d %d", x, y);
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
if (touchState.event == TE_DOWN) {
|
if (simTouchState.event == TE_DOWN) {
|
||||||
touchState.event = TE_UP;
|
simTouchState.event = TE_UP;
|
||||||
touchState.x = touchState.startX;
|
simTouchState.x = simTouchState.startX;
|
||||||
touchState.y = touchState.startY;
|
simTouchState.y = simTouchState.startY;
|
||||||
if (now - downTime <= TAP_TIME) {
|
if (now - downTime <= TAP_TIME) {
|
||||||
if (now - tapTime > TAP_TIME)
|
if (now - tapTime > TAP_TIME)
|
||||||
tapCount = 1;
|
tapCount = 1;
|
||||||
else
|
else
|
||||||
tapCount++;
|
tapCount++;
|
||||||
touchState.tapCount = tapCount;
|
simTouchState.tapCount = tapCount;
|
||||||
tapTime = now;
|
tapTime = now;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
touchState.event = TE_SLIDE_END;
|
simTouchState.event = TE_SLIDE_END;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
@@ -356,18 +356,21 @@ void OpenTxSimulator::touchEvent(int type, int x, int y)
|
|||||||
TRACE_WINDOWS("[Mouse Move] %d %d", x, y);
|
TRACE_WINDOWS("[Mouse Move] %d %d", x, y);
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
touchState.deltaX += x - touchState.x;
|
simTouchState.deltaX += x - simTouchState.x;
|
||||||
touchState.deltaY += y - touchState.y;
|
simTouchState.deltaY += y - simTouchState.y;
|
||||||
if (touchState.event == TE_SLIDE ||
|
if (simTouchState.event == TE_SLIDE ||
|
||||||
abs(touchState.deltaX) >= SLIDE_RANGE ||
|
abs(simTouchState.deltaX) >= SLIDE_RANGE ||
|
||||||
abs(touchState.deltaY) >= SLIDE_RANGE) {
|
abs(simTouchState.deltaY) >= SLIDE_RANGE) {
|
||||||
touchState.event = TE_SLIDE;
|
simTouchState.event = TE_SLIDE;
|
||||||
touchState.x = x;
|
simTouchState.x = x;
|
||||||
touchState.y = y;
|
simTouchState.y = y;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
simTouchOccured=true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenTxSimulator::setTrainerTimeout(uint16_t ms)
|
void OpenTxSimulator::setTrainerTimeout(uint16_t ms)
|
||||||
|
|||||||
@@ -894,11 +894,22 @@ void check_intmodule_heartbeat()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
struct TouchState simTouchState = {};
|
||||||
|
bool simTouchOccured = false;
|
||||||
|
|
||||||
bool touchPanelEventOccured()
|
bool touchPanelEventOccured()
|
||||||
{
|
{
|
||||||
|
if(simTouchOccured)
|
||||||
|
{
|
||||||
|
simTouchOccured = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void touchPanelRead()
|
struct TouchState touchPanelRead()
|
||||||
{
|
{
|
||||||
|
return simTouchState;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -321,4 +321,9 @@ void simuMain();
|
|||||||
#define TRACE_SIMPGMSPACE(...)
|
#define TRACE_SIMPGMSPACE(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
extern struct TouchState simTouchState;
|
||||||
|
extern bool simTouchOccured;
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // _SIMPGMSPACE_H_
|
#endif // _SIMPGMSPACE_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user