Slide energy taken into account

This commit is contained in:
Bertrand Songis
2020-03-20 18:04:17 +01:00
parent 1e25fba4ba
commit 76bc7b5c29
4 changed files with 24 additions and 20 deletions
+1 -1
View File
@@ -282,7 +282,7 @@ long OpenTxSim::onMouseUp(FXObject*,FXSelector,void*v)
touchState.y = touchState.startY; touchState.y = touchState.startY;
} }
else { else {
touchState.event = TE_NONE; touchState.event = TE_SLIDE_END;
} }
#endif #endif
+19 -17
View File
@@ -451,8 +451,8 @@ void handleTouch()
unsigned short touchY; unsigned short touchY;
uint32_t tEvent = 0; uint32_t tEvent = 0;
ft6x06_TS_GetXY(TOUCH_FT6236_I2C_ADDRESS, &touchX, &touchY, &tEvent); ft6x06_TS_GetXY(TOUCH_FT6236_I2C_ADDRESS, &touchX, &touchY, &tEvent);
//uint32_t gesture; // uint32_t gesture;
//ft6x06_TS_GetGestureID(TOUCH_FT6236_I2C_ADDRESS, &gesture); // ft6x06_TS_GetGestureID(TOUCH_FT6236_I2C_ADDRESS, &gesture);
#if defined( LCD_DIRECTION ) && (LCD_DIRECTION == LCD_VERTICAL) #if defined( LCD_DIRECTION ) && (LCD_DIRECTION == LCD_VERTICAL)
touchX = LCD_WIDTH - touchX; touchX = LCD_WIDTH - touchX;
touchY = LCD_HEIGHT - touchY; touchY = LCD_HEIGHT - touchY;
@@ -468,20 +468,18 @@ void handleTouch()
touchState.x = touchX; touchState.x = touchX;
touchState.y = touchY; 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.startX = touchState.x;
touchState.startY = touchState.y; touchState.startY = touchState.y;
touchState.event = TE_DOWN; touchState.event = TE_DOWN;
if (g_eeGeneral.backlightMode & e_backlight_mode_keys) if (g_eeGeneral.backlightMode & e_backlight_mode_keys)
backlightOn(); // TODO is that the best place ? backlightOn(); // TODO is that the best place ?
} }
else if (touchState.event == TE_DOWN) else if (touchState.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; touchState.event = TE_SLIDE;
touchState.deltaX = (short)dx; touchState.deltaX = (short) dx;
touchState.deltaY = (short)dy; touchState.deltaY = (short) dy;
} }
else { else {
touchState.event = TE_DOWN; touchState.event = TE_DOWN;
@@ -489,11 +487,10 @@ void handleTouch()
touchState.deltaY = 0; touchState.deltaY = 0;
} }
} }
else if (touchState.event == TE_SLIDE) else if (touchState.event == TE_SLIDE) {
{
touchState.event = TE_SLIDE; //no change touchState.event = TE_SLIDE; //no change
touchState.deltaX = (short)dx; touchState.deltaX = (short) dx;
touchState.deltaY = (short)dy; touchState.deltaY = (short) dy;
} }
} }
@@ -512,19 +509,24 @@ bool touchPanelEventOccured()
return touchEventOccured; return touchEventOccured;
} }
void touchPanelRead() { void touchPanelRead()
if(!touchEventOccured) return; {
if (!touchEventOccured)
return;
touchEventOccured = false; touchEventOccured = false;
if (ft6x06_TS_DetectTouch(TOUCH_FT6236_I2C_ADDRESS)) { if (ft6x06_TS_DetectTouch(TOUCH_FT6236_I2C_ADDRESS)) {
handleTouch(); handleTouch();
} else { }
else {
if (touchState.event == TE_DOWN) { if (touchState.event == TE_DOWN) {
touchState.event = TE_UP; touchState.event = TE_UP;
} }
else { else {
touchState.x = LCD_WIDTH; touchState.x = LCD_WIDTH;
touchState.y = LCD_HEIGHT; touchState.y = LCD_HEIGHT;
touchState.event = TE_NONE; touchState.event = TE_SLIDE_END;
} }
} }
} }
+3 -1
View File
@@ -27,7 +27,7 @@ enum TouchEvent
TE_DOWN, TE_DOWN,
TE_UP, TE_UP,
TE_SLIDE, TE_SLIDE,
TE_END TE_SLIDE_END
}; };
struct TouchState struct TouchState
@@ -39,6 +39,8 @@ struct TouchState
short startY; short startY;
short deltaX; short deltaX;
short deltaY; short deltaY;
short lastDeltaX;
short lastDeltaY;
}; };
constexpr uint8_t SLIDE_RANGE = 6; constexpr uint8_t SLIDE_RANGE = 6;