Attempt rework touch control

This commit is contained in:
3djc
2020-04-25 13:39:28 +02:00
parent 716650f2cd
commit b61691df1d
8 changed files with 156 additions and 95 deletions
-1
View File
@@ -185,7 +185,6 @@ bool menuModelModuleOptions(event_t event);
bool menuModelReceiverOptions(event_t event);
bool menuRadioDiagKeys(event_t event);
bool menuRadioDiagAnalogs(event_t event);
bool menuRadioDiagTouch(event_t event);
extern const MenuHandlerFunc menuTabModel[MENU_MODEL_PAGES_COUNT];
+25 -1
View File
@@ -19,6 +19,9 @@
*/
#include "opentx.h"
#if defined(RADIO_TX16S)
#include "tp_gt911.h"
#endif
constexpr coord_t LEFT_NAME_COLUMN = MENUS_MARGIN_LEFT;
constexpr coord_t RIGHT_NAME_COLUMN = LCD_W / 2;
@@ -28,6 +31,12 @@ bool menuRadioDiagAnalogs(event_t event)
{
SIMPLE_SUBMENU(STR_MENU_RADIO_ANALOGS, ICON_MODEL_SETUP, 0);
#if defined(HARDWARE_TOUCH)
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) {
touchPanelInit();
}
#endif
for (uint8_t i = 0; i < NUM_ANALOGS; i++) {
coord_t y = MENU_HEADER_HEIGHT + 1 + (i / 2) * FH;
uint8_t x = i & 1 ? LCD_W / 2 + 10 : LEFT_NAME_COLUMN;
@@ -48,9 +57,24 @@ bool menuRadioDiagAnalogs(event_t event)
#endif
}
#if (NUM_PWMSTICKS > 0) && !defined(SIMU)
#if (NUM_PWMSTICKS > 0) || defined(SIMU)
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 8 * FH, STICKS_PWM_ENABLED() ? "Sticks: PWM" : "Sticks: ANA");
#endif
#if defined(HARDWARE_TOUCH)
if (touchGT911Flag) {
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 7 * FH, "Touch panel:");
}
if (touchPanelEvent) {
uint8_t tmp,mode = 0;
gt911ReadRegister(GT911_READ_XY_REG,&mode,1); //read status
lcdDrawNumber(lcdNextPos + 1, MENU_CONTENT_TOP + 7 * FH, touchState.x);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 7 * FH, ", ");
lcdDrawNumber(lcdNextPos + 1, MENU_CONTENT_TOP + 7 * FH, touchState.y);
gt911WriteRegister(GT911_CLEARBUF_REG, &tmp, 1);
}
#endif
return true;
}
-57
View File
@@ -1,57 +0,0 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "tp_gt911.h"
bool menuRadioDiagTouch(event_t event)
{
static bool touchAvailable = false;
SIMPLE_SUBMENU(STR_MENU_RADIO_TOUCH, ICON_MODEL_SETUP, 1);
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) {
touchAvailable = touchPanelInit();
touchEventFlag = 0;
}
else if (menuEvent) {
//touchDeInit();
return false;
}
if (touchAvailable) {
lcdDrawText(LCD_W / 2, LCD_H / 2, STR_TOUCH_EXIT, CENTERED);
}
else {
lcdDrawText(LCD_W / 2, LCD_H / 2, STR_TOUCH_NOTFOUND, CENTERED);
}
if (touchEventFlag) {
uint8_t tmp,mode = 0;
GT911_RD_Reg(GT911_READ_XY_REG,&mode,1); //read status
tmp=mode&0x0f;
if((mode&0x80) && (tmp>0)) {
touchPanelDeInit();
popMenu();
}
GT911_WR_Reg(GT911_CLEARBUF_REG, &tmp, 1);
}
return true;
}
+1 -15
View File
@@ -131,12 +131,6 @@ void onHardwareAntennaSwitchConfirm(const char * result)
#define SPORT_POWER_ROWS
#endif
#if defined(HARDWARE_TOUCH)
#define DEBUG_ROW 2
#else
#define DEBUG_ROW 1
#endif
bool menuRadioHardware(event_t event)
{
MENU(STR_HARDWARE, RADIO_ICONS, menuTabGeneral, MENU_RADIO_HARDWARE, ITEM_RADIO_HARDWARE_MAX, {
@@ -168,7 +162,7 @@ bool menuRadioHardware(event_t event)
0, /* ADC filter */
READONLY_ROW /* RAS */,
SPORT_POWER_ROWS
DEBUG_ROW, /* Debug */
1, /* Debug */
});
if (menuEvent) {
@@ -417,9 +411,6 @@ bool menuRadioHardware(event_t event)
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_DEBUG);
lcdDrawText(HW_SETTINGS_COLUMN2, y, STR_ANALOGS_BTN, menuHorizontalPosition == 0 ? attr : 0);
lcdDrawText(lcdNextPos + 10, y, STR_KEYS_BTN, menuHorizontalPosition == 1 ? attr : 0);
#if defined(HARDWARE_TOUCH)
lcdDrawText(lcdNextPos + 10, y, STR_TOUCH_BTN, menuHorizontalPosition == 2 ? attr : 0);
#endif
if (attr && event == EVT_KEY_BREAK(KEY_ENTER)) {
switch (menuHorizontalPosition) {
case 0:
@@ -428,11 +419,6 @@ bool menuRadioHardware(event_t event)
case 1:
pushMenu(menuRadioDiagKeys);
break;
#if defined(HARDWARE_TOUCH)
case 2:
pushMenu(menuRadioDiagTouch);
break;
#endif
}
}
break;