Improve menu handling

This commit is contained in:
3djc
2020-11-24 08:57:16 +01:00
parent 2dfa8a80ab
commit e2f4805725
18 changed files with 43 additions and 13 deletions
+8 -1
View File
@@ -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();
}
@@ -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();
}
+2 -4
View File
@@ -18,8 +18,7 @@
* GNU General Public License for more details.
*/
#ifndef _OPENTX_H_
#define _OPENTX_H_
#pragma once
#include <stdlib.h>
#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_
+2 -1
View File
@@ -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) {
+10 -6
View File
@@ -18,8 +18,7 @@
* GNU General Public License for more details.
*/
#ifndef _GHOST_H_
#define _GHOST_H_
#pragma once
#include <inttypes.h>
#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_
+1
View File
@@ -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;
+1
View File
@@ -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)
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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."
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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"