Fix LUA telemetry (+/-/exit handling) (#7356)
Fix LUA telemetry (+/-/exit handling)
This commit is contained in:
@@ -302,7 +302,7 @@ void showAlertBox(const char * title, const char * text, const char * action , u
|
|||||||
#define LOAD_MODEL_BITMAP()
|
#define LOAD_MODEL_BITMAP()
|
||||||
|
|
||||||
#define IS_MAIN_VIEW_DISPLAYED() menuHandlers[0] == menuMainView
|
#define IS_MAIN_VIEW_DISPLAYED() menuHandlers[0] == menuMainView
|
||||||
#define IS_TELEMETRY_VIEW_DISPLAYED() menuHandlers[0] == menuViewTelemetryFrsky
|
#define IS_TELEMETRY_VIEW_DISPLAYED() menuHandlers[0] == menuViewTelemetry
|
||||||
#define IS_OTHER_VIEW_DISPLAYED() false
|
#define IS_OTHER_VIEW_DISPLAYED() false
|
||||||
|
|
||||||
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags);
|
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ inline bool isModelMenuDisplayed()
|
|||||||
void onMainViewMenu(const char * result);
|
void onMainViewMenu(const char * result);
|
||||||
void menuFirstCalib(event_t event);
|
void menuFirstCalib(event_t event);
|
||||||
void menuMainView(event_t event);
|
void menuMainView(event_t event);
|
||||||
void menuViewTelemetryFrsky(event_t event);
|
void menuViewTelemetry(event_t event);
|
||||||
void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext);
|
void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext);
|
||||||
|
|
||||||
enum MenuRadioIndexes
|
enum MenuRadioIndexes
|
||||||
|
|||||||
@@ -397,7 +397,7 @@ void menuMainView(event_t event)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
case EVT_KEY_TELEMETRY:
|
case EVT_KEY_TELEMETRY:
|
||||||
chainMenu(menuViewTelemetryFrsky);
|
chainMenu(menuViewTelemetry);
|
||||||
killEvents(event);
|
killEvents(event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -206,79 +206,3 @@ bool displayTelemetryScreen()
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum NavigationDirection {
|
|
||||||
none,
|
|
||||||
up,
|
|
||||||
down
|
|
||||||
};
|
|
||||||
#define decrTelemetryScreen() direction = up
|
|
||||||
#define incrTelemetryScreen() direction = down
|
|
||||||
|
|
||||||
#if defined(NAVIGATION_XLITE)
|
|
||||||
#define EVT_KEY_PREVIOUS_VIEW(evt) (evt == EVT_KEY_LONG(KEY_LEFT) && IS_SHIFT_PRESSED())
|
|
||||||
#define EVT_KEY_NEXT_VIEW(evt) (evt == EVT_KEY_LONG(KEY_RIGHT) && IS_SHIFT_PRESSED())
|
|
||||||
#elif defined(NAVIGATION_X7)
|
|
||||||
#define EVT_KEY_PREVIOUS_VIEW(evt) (evt == EVT_KEY_LONG(KEY_PAGE))
|
|
||||||
#define EVT_KEY_NEXT_VIEW(evt) (evt == EVT_KEY_BREAK(KEY_PAGE))
|
|
||||||
#elif defined(NAVIGATION_9X)
|
|
||||||
#define EVT_KEY_PREVIOUS_VIEW(evt) (evt == EVT_KEY_LONG(KEY_UP))
|
|
||||||
#define EVT_KEY_NEXT_VIEW(evt) (evt == EVT_KEY_LONG(KEY_DOWN))
|
|
||||||
#else
|
|
||||||
#define EVT_KEY_PREVIOUS_VIEW(evt) (evt == EVT_KEY_FIRST(KEY_UP))
|
|
||||||
#define EVT_KEY_NEXT_VIEW(evt) (evt == EVT_KEY_FIRST(KEY_DOWN))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void menuViewTelemetryFrsky(event_t event)
|
|
||||||
{
|
|
||||||
enum NavigationDirection direction = none;
|
|
||||||
|
|
||||||
if (event == EVT_KEY_FIRST(KEY_EXIT) && TELEMETRY_SCREEN_TYPE(s_frsky_view) != TELEMETRY_SCREEN_TYPE_SCRIPT) {
|
|
||||||
killEvents(event);
|
|
||||||
chainMenu(menuMainView);
|
|
||||||
}
|
|
||||||
#if defined(LUA)
|
|
||||||
else if (event == EVT_KEY_LONG(KEY_EXIT)) {
|
|
||||||
killEvents(event);
|
|
||||||
chainMenu(menuMainView);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else if (EVT_KEY_PREVIOUS_VIEW(event)) {
|
|
||||||
killEvents(event);
|
|
||||||
decrTelemetryScreen();
|
|
||||||
}
|
|
||||||
else if (EVT_KEY_NEXT_VIEW(event)) {
|
|
||||||
killEvents(event);
|
|
||||||
incrTelemetryScreen();
|
|
||||||
}
|
|
||||||
else if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
|
||||||
killEvents(event);
|
|
||||||
POPUP_MENU_ADD_ITEM(STR_RESET_TELEMETRY);
|
|
||||||
POPUP_MENU_ADD_ITEM(STR_RESET_FLIGHT);
|
|
||||||
POPUP_MENU_START(onMainViewMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0; i<=TELEMETRY_SCREEN_TYPE_MAX; i++) {
|
|
||||||
if (direction == up) {
|
|
||||||
if (s_frsky_view-- == 0)
|
|
||||||
s_frsky_view = TELEMETRY_VIEW_MAX;
|
|
||||||
}
|
|
||||||
else if (direction == down) {
|
|
||||||
if (s_frsky_view++ == TELEMETRY_VIEW_MAX)
|
|
||||||
s_frsky_view = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
direction = down;
|
|
||||||
}
|
|
||||||
if (displayTelemetryScreen()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
drawTelemetryTopBar();
|
|
||||||
lcdDrawText(2*FW, 3*FH, "No Telemetry Screens");
|
|
||||||
displayRssiLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef EVT_KEY_PREVIOUS_VIEW
|
|
||||||
#undef EVT_KEY_NEXT_VIEW
|
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ FlightModesType editFlightModes(coord_t x, coord_t y, event_t event, FlightModes
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define IS_MAIN_VIEW_DISPLAYED() menuHandlers[0] == menuMainView
|
#define IS_MAIN_VIEW_DISPLAYED() menuHandlers[0] == menuMainView
|
||||||
#define IS_TELEMETRY_VIEW_DISPLAYED() menuHandlers[0] == menuViewTelemetryFrsky
|
#define IS_TELEMETRY_VIEW_DISPLAYED() menuHandlers[0] == menuViewTelemetry
|
||||||
#define IS_OTHER_VIEW_DISPLAYED() (menuHandlers[0] == menuMainViewChannelsMonitor || menuHandlers[0] == menuChannelsView)
|
#define IS_OTHER_VIEW_DISPLAYED() (menuHandlers[0] == menuMainViewChannelsMonitor || menuHandlers[0] == menuChannelsView)
|
||||||
|
|
||||||
#endif // _GUI_H_
|
#endif // _GUI_H_
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ void menuFirstCalib(event_t event);
|
|||||||
void menuMainViewChannelsMonitor(event_t event);
|
void menuMainViewChannelsMonitor(event_t event);
|
||||||
void menuChannelsView(event_t event);
|
void menuChannelsView(event_t event);
|
||||||
void menuMainView(event_t event);
|
void menuMainView(event_t event);
|
||||||
void menuViewTelemetryFrsky(event_t event);
|
void menuViewTelemetry(event_t event);
|
||||||
void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext);
|
void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext);
|
||||||
void menuModelNotes(event_t event);
|
void menuModelNotes(event_t event);
|
||||||
void menuStatisticsView(event_t event);
|
void menuStatisticsView(event_t event);
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ void menuMainView(event_t event)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EVT_KEY_LONG(KEY_PAGE):
|
case EVT_KEY_LONG(KEY_PAGE):
|
||||||
chainMenu(menuViewTelemetryFrsky);
|
chainMenu(menuViewTelemetry);
|
||||||
killEvents(event);
|
killEvents(event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -200,65 +200,3 @@ bool displayTelemetryScreen()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum NavigationDirection {
|
|
||||||
none,
|
|
||||||
up,
|
|
||||||
down
|
|
||||||
};
|
|
||||||
|
|
||||||
#define decrTelemetryScreen() direction = up
|
|
||||||
#define incrTelemetryScreen() direction = down
|
|
||||||
|
|
||||||
void menuViewTelemetryFrsky(event_t event)
|
|
||||||
{
|
|
||||||
enum NavigationDirection direction = none;
|
|
||||||
|
|
||||||
switch (event) {
|
|
||||||
case EVT_KEY_FIRST(KEY_EXIT):
|
|
||||||
case EVT_KEY_LONG(KEY_EXIT):
|
|
||||||
killEvents(event);
|
|
||||||
chainMenu(menuMainView);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EVT_KEY_LONG(KEY_PAGE):
|
|
||||||
killEvents(event);
|
|
||||||
// no break;
|
|
||||||
|
|
||||||
case EVT_KEY_FIRST(KEY_UP):
|
|
||||||
decrTelemetryScreen();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EVT_KEY_BREAK(KEY_PAGE):
|
|
||||||
case EVT_KEY_FIRST(KEY_DOWN):
|
|
||||||
incrTelemetryScreen();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EVT_KEY_LONG(KEY_ENTER):
|
|
||||||
killEvents(event);
|
|
||||||
POPUP_MENU_ADD_ITEM(STR_RESET_TELEMETRY);
|
|
||||||
POPUP_MENU_ADD_ITEM(STR_RESET_FLIGHT);
|
|
||||||
POPUP_MENU_START(onMainViewMenu);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0; i<=TELEMETRY_SCREEN_TYPE_MAX; i++) {
|
|
||||||
if (direction == up) {
|
|
||||||
if (s_frsky_view-- == 0)
|
|
||||||
s_frsky_view = TELEMETRY_VIEW_MAX;
|
|
||||||
}
|
|
||||||
else if (direction == down) {
|
|
||||||
if (s_frsky_view++ == TELEMETRY_VIEW_MAX)
|
|
||||||
s_frsky_view = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
direction = down;
|
|
||||||
}
|
|
||||||
if (displayTelemetryScreen()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
drawTelemetryTopBar();
|
|
||||||
lcdDrawText(8*FW, 3*FH, "No Telemetry Screens");
|
|
||||||
displayRssiLine();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ set(GUI_SRC
|
|||||||
../common/stdlcd/radio_hardware.cpp
|
../common/stdlcd/radio_hardware.cpp
|
||||||
../common/stdlcd/radio_version.cpp
|
../common/stdlcd/radio_version.cpp
|
||||||
../common/stdlcd/radio_trainer.cpp
|
../common/stdlcd/radio_trainer.cpp
|
||||||
|
../common/stdlcd/view_telemetry.cpp
|
||||||
model_curve_edit.cpp
|
model_curve_edit.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
extern bool displayTelemetryScreen();
|
||||||
|
extern void displayRssiLine();
|
||||||
|
|
||||||
|
enum NavigationDirection {
|
||||||
|
NAVIGATION_DIRECTION_NONE,
|
||||||
|
NAVIGATION_DIRECTION_UP,
|
||||||
|
NAVIGATION_DIRECTION_DOWN
|
||||||
|
};
|
||||||
|
#define decrTelemetryScreen() direction = NAVIGATION_DIRECTION_UP
|
||||||
|
#define incrTelemetryScreen() direction = NAVIGATION_DIRECTION_DOWN
|
||||||
|
|
||||||
|
#if defined(NAVIGATION_XLITE)
|
||||||
|
#define EVT_KEY_PREVIOUS_VIEW(evt) (evt == EVT_KEY_LONG(KEY_LEFT) && IS_SHIFT_PRESSED())
|
||||||
|
#define EVT_KEY_NEXT_VIEW(evt) (evt == EVT_KEY_LONG(KEY_RIGHT) && IS_SHIFT_PRESSED())
|
||||||
|
#elif defined(NAVIGATION_X7) || defined(NAVIGATION_X9D)
|
||||||
|
#define EVT_KEY_PREVIOUS_VIEW(evt) (evt == EVT_KEY_LONG(KEY_PAGE))
|
||||||
|
#define EVT_KEY_NEXT_VIEW(evt) (evt == EVT_KEY_BREAK(KEY_PAGE))
|
||||||
|
#elif defined(NAVIGATION_9X)
|
||||||
|
#define EVT_KEY_PREVIOUS_VIEW(evt) (evt == EVT_KEY_LONG(KEY_UP))
|
||||||
|
#define EVT_KEY_NEXT_VIEW(evt) (evt == EVT_KEY_LONG(KEY_DOWN))
|
||||||
|
#else
|
||||||
|
#define EVT_KEY_PREVIOUS_VIEW(evt) (evt == EVT_KEY_FIRST(KEY_UP))
|
||||||
|
#define EVT_KEY_NEXT_VIEW(evt) (evt == EVT_KEY_FIRST(KEY_DOWN))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void menuViewTelemetry(event_t event)
|
||||||
|
{
|
||||||
|
enum NavigationDirection direction = NAVIGATION_DIRECTION_NONE;
|
||||||
|
|
||||||
|
if (event == EVT_KEY_FIRST(KEY_EXIT) && TELEMETRY_SCREEN_TYPE(s_frsky_view) != TELEMETRY_SCREEN_TYPE_SCRIPT) {
|
||||||
|
killEvents(event);
|
||||||
|
chainMenu(menuMainView);
|
||||||
|
}
|
||||||
|
#if defined(LUA)
|
||||||
|
else if (event == EVT_KEY_LONG(KEY_EXIT)) {
|
||||||
|
killEvents(event);
|
||||||
|
chainMenu(menuMainView);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else if (EVT_KEY_PREVIOUS_VIEW(event)) {
|
||||||
|
killEvents(event);
|
||||||
|
decrTelemetryScreen();
|
||||||
|
}
|
||||||
|
else if (EVT_KEY_NEXT_VIEW(event)) {
|
||||||
|
killEvents(event);
|
||||||
|
incrTelemetryScreen();
|
||||||
|
}
|
||||||
|
else if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||||
|
killEvents(event);
|
||||||
|
POPUP_MENU_ADD_ITEM(STR_RESET_TELEMETRY);
|
||||||
|
POPUP_MENU_ADD_ITEM(STR_RESET_FLIGHT);
|
||||||
|
POPUP_MENU_START(onMainViewMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<=TELEMETRY_SCREEN_TYPE_MAX; i++) {
|
||||||
|
if (direction == NAVIGATION_DIRECTION_UP) {
|
||||||
|
if (s_frsky_view-- == 0)
|
||||||
|
s_frsky_view = TELEMETRY_VIEW_MAX;
|
||||||
|
}
|
||||||
|
else if (direction == NAVIGATION_DIRECTION_DOWN) {
|
||||||
|
if (s_frsky_view++ == TELEMETRY_VIEW_MAX)
|
||||||
|
s_frsky_view = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
direction = NAVIGATION_DIRECTION_DOWN;
|
||||||
|
}
|
||||||
|
if (displayTelemetryScreen()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
drawTelemetryTopBar();
|
||||||
|
lcdDrawText(LCD_W / 2, 3 * FH, "No Telemetry Screens", CENTERED);
|
||||||
|
displayRssiLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef EVT_KEY_PREVIOUS_VIEW
|
||||||
|
#undef EVT_KEY_NEXT_VIEW
|
||||||
@@ -952,7 +952,7 @@ bool luaDoOneRunPermanentScript(event_t evt, int i, uint32_t scriptType)
|
|||||||
TelemetryScriptData & script = g_model.screens[sid.reference-SCRIPT_TELEMETRY_FIRST].script;
|
TelemetryScriptData & script = g_model.screens[sid.reference-SCRIPT_TELEMETRY_FIRST].script;
|
||||||
filename = script.file;
|
filename = script.file;
|
||||||
#endif
|
#endif
|
||||||
if ((scriptType & RUN_TELEM_FG_SCRIPT) && (menuHandlers[0]==menuViewTelemetryFrsky && sid.reference==SCRIPT_TELEMETRY_FIRST+s_frsky_view)) {
|
if ((scriptType & RUN_TELEM_FG_SCRIPT) && (menuHandlers[0]==menuViewTelemetry && sid.reference==SCRIPT_TELEMETRY_FIRST+s_frsky_view)) {
|
||||||
lua_rawgeti(lsScripts, LUA_REGISTRYINDEX, sid.run);
|
lua_rawgeti(lsScripts, LUA_REGISTRYINDEX, sid.run);
|
||||||
lua_pushunsigned(lsScripts, evt);
|
lua_pushunsigned(lsScripts, evt);
|
||||||
inputsCount = 1;
|
inputsCount = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user