From e2f48057257c6a24fc003615160bb564fc820409 Mon Sep 17 00:00:00 2001 From: 3djc Date: Tue, 24 Nov 2020 08:57:16 +0100 Subject: [PATCH] Improve menu handling --- radio/src/gui/480x272/radio_ghost_menu.cpp | 9 ++++++++- radio/src/gui/common/stdlcd/radio_ghost_menu.cpp | 9 ++++++++- radio/src/opentx.h | 6 ++---- radio/src/telemetry/ghost.cpp | 3 ++- radio/src/telemetry/ghost.h | 16 ++++++++++------ radio/src/translations.cpp | 1 + radio/src/translations.h | 1 + radio/src/translations/cz.h.txt | 1 + radio/src/translations/de.h.txt | 1 + radio/src/translations/en.h.txt | 1 + radio/src/translations/es.h.txt | 1 + radio/src/translations/fi.h.txt | 1 + radio/src/translations/fr.h.txt | 1 + radio/src/translations/it.h.txt | 1 + radio/src/translations/nl.h.txt | 1 + radio/src/translations/pl.h.txt | 1 + radio/src/translations/pt.h.txt | 1 + radio/src/translations/se.h.txt | 1 + 18 files changed, 43 insertions(+), 13 deletions(-) diff --git a/radio/src/gui/480x272/radio_ghost_menu.cpp b/radio/src/gui/480x272/radio_ghost_menu.cpp index 5425c57bd..8516ffdee 100644 --- a/radio/src/gui/480x272/radio_ghost_menu.cpp +++ b/radio/src/gui/480x272/radio_ghost_menu.cpp @@ -25,6 +25,8 @@ bool menuGhostModuleConfig(event_t event) switch (event) { case EVT_ENTRY: memclear(&reusableBuffer.ghostMenu, sizeof(reusableBuffer.ghostMenu)); + strAppend((char *) &reusableBuffer.ghostMenu.line[1].menuText, STR_WAITING_FOR_MODULE, 0); + reusableBuffer.ghostMenu.line[1].lineFlags = GHST_LINE_FLAGS_VALUE_EDIT; reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE; reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_OPEN; moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL; @@ -65,7 +67,12 @@ bool menuGhostModuleConfig(event_t event) break; } - if (reusableBuffer.ghostMenu.menuAction == GHST_MENU_CTRL_CLOSE) { + if (reusableBuffer.ghostMenu.menuStatus == GHST_MENU_STATUS_UNOPENED) { // Handles situation where module is plugged after tools start + reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE; + reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_OPEN; + moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL; + } + else if (reusableBuffer.ghostMenu.menuStatus == GHST_MENU_STATUS_CLOSING) { popMenu(); } diff --git a/radio/src/gui/common/stdlcd/radio_ghost_menu.cpp b/radio/src/gui/common/stdlcd/radio_ghost_menu.cpp index 0ae5affac..df482b2d7 100644 --- a/radio/src/gui/common/stdlcd/radio_ghost_menu.cpp +++ b/radio/src/gui/common/stdlcd/radio_ghost_menu.cpp @@ -25,6 +25,8 @@ void menuGhostModuleConfig(event_t event) switch (event) { case EVT_ENTRY: memclear(&reusableBuffer.ghostMenu, sizeof(reusableBuffer.ghostMenu)); + strAppend((char *) &reusableBuffer.ghostMenu.line[1].menuText, STR_WAITING_FOR_MODULE, 0); + reusableBuffer.ghostMenu.line[1].lineFlags = GHST_LINE_FLAGS_VALUE_EDIT; reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE; reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_OPEN; moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL; @@ -78,7 +80,12 @@ void menuGhostModuleConfig(event_t event) break; } - if (reusableBuffer.ghostMenu.menuAction == GHST_MENU_CTRL_CLOSE) { + if (reusableBuffer.ghostMenu.menuStatus == GHST_MENU_STATUS_UNOPENED) { // Handles situation where module is plugged after tools start + reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE; + reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_OPEN; + moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL; + } + else if (reusableBuffer.ghostMenu.menuStatus == GHST_MENU_STATUS_CLOSING) { popMenu(); } diff --git a/radio/src/opentx.h b/radio/src/opentx.h index fe42cdd5c..52a51719b 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -18,8 +18,7 @@ * GNU General Public License for more details. */ -#ifndef _OPENTX_H_ -#define _OPENTX_H_ +#pragma once #include #include "definitions.h" @@ -1131,7 +1130,7 @@ union ReusableBuffer #if defined(GHOST) struct { GhostMenuData line[GHST_MENU_LINES + 1]; - uint8_t menuFlags; + uint8_t menuStatus; uint8_t menuAction; uint8_t buttonAction; } ghostMenu; @@ -1341,4 +1340,3 @@ inline bool isAsteriskDisplayed() #include "thirdparty/libACCESS/libAccess.h" #endif -#endif // _OPENTX_H_ diff --git a/radio/src/telemetry/ghost.cpp b/radio/src/telemetry/ghost.cpp index 7a9653bb4..78c22ba8f 100755 --- a/radio/src/telemetry/ghost.cpp +++ b/radio/src/telemetry/ghost.cpp @@ -195,7 +195,8 @@ void processGhostTelemetryFrame() packet = (GhostMenuFrame * ) telemetryRxBuffer; lineData = (GhostMenuData *) &reusableBuffer.ghostMenu.line[packet->lineIndex]; lineData->splitLine = 0; - reusableBuffer.ghostMenu.menuFlags = packet->menuFlags; + reusableBuffer.ghostMenu.menuStatus = packet->menuStatus; + TRACE("menuStatus: %x",reusableBuffer.ghostMenu.menuStatus); lineData->lineFlags = packet->lineFlags; for (uint8_t i = 0; i < GHST_MENU_CHARS; i++) { if (packet->menuText[i] == 0x7C) { diff --git a/radio/src/telemetry/ghost.h b/radio/src/telemetry/ghost.h index ae8c63465..0a3195835 100755 --- a/radio/src/telemetry/ghost.h +++ b/radio/src/telemetry/ghost.h @@ -18,8 +18,7 @@ * GNU General Public License for more details. */ -#ifndef _GHOST_H_ -#define _GHOST_H_ +#pragma once #include #include "dataconstants.h" @@ -143,6 +142,12 @@ enum GhostMenuControl GHST_MENU_CTRL_REDRAW = 0X04, }; +enum GhostMenuStatus +{ + GHST_MENU_STATUS_UNOPENED = 0x00, + GHST_MENU_STATUS_OPENED = 0x01, + GHST_MENU_STATUS_CLOSING = 0x02, +}; enum GhostFrames { @@ -159,8 +164,8 @@ struct GhostMenuFrame uint8_t address; uint8_t length ; uint8_t packetId; - uint8_t menuFlags; // GHST_MENU_CTRL - uint8_t lineFlags; // Carat states, Inverse, Bold for each of Menu Label, and Value + uint8_t menuStatus; // GhostMenuStatus + uint8_t lineFlags; // GhostLineFlags uint8_t lineIndex; // 0 = first line unsigned char menuText[GHST_MENU_CHARS]; uint8_t crc; @@ -168,10 +173,9 @@ struct GhostMenuFrame struct GhostMenuData { - uint8_t menuFlags; // Update Line, Clear Menu, etc. + uint8_t menuStatus; // Update Line, Clear Menu, etc. uint8_t lineFlags; // Carat states, Inverse, Bold for each of Menu Label, and Value uint8_t splitLine; // Store beginning of Value substring char menuText[GHST_MENU_CHARS + 1]; }; -#endif // _GHOST_H_ diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 5cc6b5141..48d01b4bc 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -360,6 +360,7 @@ const char STR_SPECTRUM_ANALYSER_EXT[] = TR_SPECTRUM_ANALYSER_EXT; const char STR_SPECTRUM_ANALYSER_INT[] = TR_SPECTRUM_ANALYSER_INT; const char STR_WAITING_FOR_RX[] = TR_WAITING_FOR_RX; const char STR_WAITING_FOR_TX[] = TR_WAITING_FOR_TX; +const char STR_WAITING_FOR_MODULE[] = TR_WAITING_FOR_MODULE; const char STR_WARN_5VOLTS[] = TR_WARN_5VOLTS; const char STR_CAT_NOT_EMPTY[] = TR_CAT_NOT_EMPTY; const char STR_WARNING[] = TR_WARNING; diff --git a/radio/src/translations.h b/radio/src/translations.h index b5770fbf5..73c843389 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -544,6 +544,7 @@ extern const char STR_SPECTRUM_ANALYSER_EXT[]; extern const char STR_SPECTRUM_ANALYSER_INT[]; extern const char STR_WAITING_FOR_RX[]; extern const char STR_WAITING_FOR_TX[]; +extern const char STR_WAITING_FOR_MODULE[]; extern const char STR_WARN_5VOLTS[]; #if defined(SDCARD) diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index 18824b89e..c33d13e2c 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -704,6 +704,7 @@ #define TR_NO_SDCARD "Není SD karta" #define TR_WAITING_FOR_RX "Čekám na RX..." #define TR_WAITING_FOR_TX "Čekám na TX..." +#define TR_WAITING_FOR_MODULE TR("Waiting module", "Waiting for module...") #define TR_NO_TOOLS TR("Nejsou k dispozici", "Žádné nástroje k dispozici") #define TR_NORMAL "Normální" #define TR_NOT_INVERTED "Neinvert" diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index b3be56a75..0a226f144 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -706,6 +706,7 @@ #define TR_NO_SDCARD "Keine SD-Karte" #define TR_WAITING_FOR_RX "Waiting for RX..." #define TR_WAITING_FOR_TX "Waiting for TX..." +#define TR_WAITING_FOR_MODULE TR("Waiting module", "Waiting for module...") #define TR_NO_TOOLS "No tools available" #define TR_NORMAL "Normal" #define TR_NOT_INVERTED "Not inv" diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 3da18fe66..0f1313a97 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -710,6 +710,7 @@ #define TR_NO_SDCARD "No SD card" #define TR_WAITING_FOR_RX "Waiting for RX..." #define TR_WAITING_FOR_TX "Waiting for TX..." +#define TR_WAITING_FOR_MODULE TR("Waiting module", "Waiting for module...") #define TR_NO_TOOLS "No tools available" #define TR_NORMAL "Normal" #define TR_NOT_INVERTED "Not inv" diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index 2ede6bba4..bb11d0887 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -707,6 +707,7 @@ #define TR_NO_SDCARD "No SDCARD" #define TR_WAITING_FOR_RX "Esperando a RX..." #define TR_WAITING_FOR_TX "Esperando a TX..." +#define TR_WAITING_FOR_MODULE TR("Waiting module", "Waiting for module...") #define TR_NO_TOOLS "No hay utils" #define TR_NORMAL "Normal" #define TR_NOT_INVERTED "No inv" diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index b2cf9f79c..01bc6cf34 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -723,6 +723,7 @@ #define TR_NO_SDCARD "No SDCARD" #define TR_WAITING_FOR_RX "Waiting for RX..." #define TR_WAITING_FOR_TX "Waiting for TX..." +#define TR_WAITING_FOR_MODULE TR("Waiting module", "Waiting for module...") #define TR_NO_TOOLS "No tools available" #define TR_NORMAL "Normal" #define TR_NOT_INVERTED "Not inv" diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 5725219be..012117498 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -726,6 +726,7 @@ #define TR_NO_SDCARD "Carte SD indisponible" #define TR_WAITING_FOR_RX "Attente du RX..." #define TR_WAITING_FOR_TX "Attente du TX..." +#define TR_WAITING_FOR_MODULE TR("Waiting module", "Waiting for module...") #define TR_NO_TOOLS "Pas d'outils dispo" #define TR_NORMAL "Normal" #define TR_NOT_INVERTED "Non inv" diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index 4b0f83550..42cfb023a 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -725,6 +725,7 @@ #define TR_NO_SDCARD "No SDCard" #define TR_WAITING_FOR_RX "Attendo la RX..." #define TR_WAITING_FOR_TX "Attendo la TX..." +#define TR_WAITING_FOR_MODULE TR("Waiting module", "Waiting for module...") #define TR_NO_TOOLS "Tools non disp." #define TR_NORMAL "Normale" #define TR_NOT_INVERTED "No inv." diff --git a/radio/src/translations/nl.h.txt b/radio/src/translations/nl.h.txt index 5288cc49e..e1b1d91ba 100644 --- a/radio/src/translations/nl.h.txt +++ b/radio/src/translations/nl.h.txt @@ -711,6 +711,7 @@ #define TR_NO_SDCARD "Geen SD-Kaart" #define TR_WAITING_FOR_RX "Waiting for RX..." #define TR_WAITING_FOR_TX "Waiting for TX..." +#define TR_WAITING_FOR_MODULE TR("Waiting module", "Waiting for module...") #define TR_NO_TOOLS "No tools available" #define TR_NORMAL "Normal" #define TR_NOT_INVERTED "Not inv" diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 342114fcf..5dbc0af26 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -724,6 +724,7 @@ #define TR_NO_SDCARD "Brak karty SD" #define TR_WAITING_FOR_RX "Waiting for RX..." #define TR_WAITING_FOR_TX "Waiting for TX..." +#define TR_WAITING_FOR_MODULE TR("Waiting module", "Waiting for module...") #define TR_NO_TOOLS "No tools available" #define TR_NORMAL "Normal" #define TR_NOT_INVERTED "Not inv" diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index d0f4649ea..ae9cb9a7d 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -725,6 +725,7 @@ #define TR_NO_SDCARD "Sem SDCARD" #define TR_WAITING_FOR_RX "Waiting for RX..." #define TR_WAITING_FOR_TX "Waiting for TX..." +#define TR_WAITING_FOR_MODULE TR("Waiting module", "Waiting for module...") #define TR_NO_TOOLS "No tools available" #define TR_NORMAL "Normal" #define TR_NOT_INVERTED "Not inv" diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index 1bf474532..910c6f78d 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -723,6 +723,7 @@ #define TR_NO_SDCARD "SDCARD saknas" #define TR_WAITING_FOR_RX "Waiting for RX..." #define TR_WAITING_FOR_TX "Waiting for TX..." +#define TR_WAITING_FOR_MODULE TR("Waiting module", "Waiting for module...") #define TR_NO_TOOLS "No tools available" #define TR_NORMAL "Normal" #define TR_NOT_INVERTED "Not inv"