feat: Add options to disable radio and model menu tabs (#3484)

* Add options to disable radio and model menu tabs.
- Update radio and model data structs
- UI for color LCD radios
- Convert existing 'noGlobalFunctions' property.
- Language strings.

* Make 'theme' control specific to color LCD radios.

* Add B&W radio UI.

* Simplify code, reduce compiled code size.
Fix page count display on model select tab.
Fix GVARS for 212x64 radios.

* Collapse timer sections if timer is off.

* Remove 'Use global functions' checkbox from B&W model setup.

* Make preflight checks, throttle and view options sections expand & collapse (default collapsed).

* Fix build.

* Add view options to companion data classes, save and load values in YAML files.
Fix scrolling for radio setup view options.

* Add Companion UI for view option settings.

* Remove 'Mixes' from list of tabs that can be hidden.

* Updated Companion UI from elecpower.

* Use view options flags to enable/disable functionality:
- skip heli mixer logic if heli not enabled
- Remove heli, gvars and telemetry options from source selection if not enabled

* Remove 'flight mode', 'curve' and 'global variable' settings from input & mix editors if option disabled.

* Rename 'View Options' to 'Enabled Features'.
Put GVAR option under Flight Mode and indent text.
Make relationship between FM and GV more obvious.

* Remove global variable option dependency on flight modes.
Hide FM1-FM8 in global variables if flight modes hidden.

* Hide 'Custom Mixer Scripts' in source selection menu popup if disabled.

* Add translation strings for Hebrew language file.

* Fix typo. Add comment for double call to setCurrentTab.
This commit is contained in:
philmoz
2023-05-22 20:08:16 +10:00
committed by GitHub
parent 04359757c4
commit 5327c890f2
98 changed files with 2459 additions and 452 deletions
+165 -34
View File
@@ -91,6 +91,7 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_EXTENDED_TRIMS,
ITEM_MODEL_SETUP_DISPLAY_TRIMS,
ITEM_MODEL_SETUP_TRIM_INC,
ITEM_MODEL_SETUP_THROTTLE_LABEL,
ITEM_MODEL_SETUP_THROTTLE_REVERSED,
ITEM_MODEL_SETUP_THROTTLE_TRACE,
ITEM_MODEL_SETUP_THROTTLE_TRIM,
@@ -106,7 +107,6 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_POTS_WARNING,
#endif
ITEM_MODEL_SETUP_BEEP_CENTER,
ITEM_MODEL_SETUP_USE_GLOBAL_FUNCTIONS,
ITEM_MODEL_SETUP_USE_JITTER_FILTER,
#if defined(PXX2)
ITEM_MODEL_SETUP_REGISTRATION_ID,
@@ -198,6 +198,21 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_TRAINER_PPM_PARAMS,
#endif
ITEM_VIEW_OPTIONS_LABEL,
ITEM_VIEW_OPTIONS_RADIO_TAB,
ITEM_VIEW_OPTIONS_GF,
ITEM_VIEW_OPTIONS_TRAINER,
ITEM_VIEW_OPTIONS_MODEL_TAB,
CASE_HELI(ITEM_VIEW_OPTIONS_HELI)
CASE_FLIGHT_MODES(ITEM_VIEW_OPTIONS_FM)
ITEM_VIEW_OPTIONS_CURVES,
ITEM_VIEW_OPTIONS_LS,
ITEM_VIEW_OPTIONS_SF,
#if defined(LUA_MODEL_SCRIPTS)
ITEM_VIEW_OPTIONS_CUSTOM_SCRIPTS,
#endif
ITEM_VIEW_OPTIONS_TELEMETRY,
#if defined(USBJ_EX)
ITEM_MODEL_SETUP_USBJOYSTICK_LABEL,
ITEM_MODEL_SETUP_USBJOYSTICK_MODE,
@@ -206,9 +221,39 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_USBJOYSTICK_CH_BUTTON,
ITEM_MODEL_SETUP_USBJOYSTICK_APPLY,
#endif
ITEM_MODEL_SETUP_LINES_COUNT
};
PACK(struct ExpandState {
uint8_t preflight:1;
uint8_t throttle:1;
uint8_t viewOpt:1;
});
struct ExpandState expandState;
uint8_t PREFLIGHT_ROW(uint8_t value)
{
if (expandState.preflight)
return value;
return HIDDEN_ROW;
}
uint8_t THROTTLE_ROW(uint8_t value)
{
if (expandState.throttle)
return value;
return HIDDEN_ROW;
}
uint8_t VIEWOPT_ROW(uint8_t value)
{
if (expandState.viewOpt)
return value;
return HIDDEN_ROW;
}
#define MODEL_SETUP_2ND_COLUMN (LCD_W-11*FW)
#define MODEL_SETUP_SET_FAILSAFE_OFS 7*FW-2
@@ -248,9 +293,14 @@ enum MenuModelSetupItems {
#define MAX_SWITCH_PER_LINE (getSwitchWarningsCount() > 5 ? 4 : 5)
#if defined(PCBXLITE)
#define SW_WARN_ROWS uint8_t(NAVIGATION_LINE_BY_LINE|getSwitchWarningsCount()), uint8_t(getSwitchWarningsCount() > 4 ? TITLE_ROW : HIDDEN_ROW) // X-Lite needs an additional column for full line selection (<])
// X-Lite needs an additional column for full line selection (<])
#define SW_WARN_ROWS \
PREFLIGHT_ROW(uint8_t(NAVIGATION_LINE_BY_LINE|getSwitchWarningsCount())), \
PREFLIGHT_ROW(uint8_t(getSwitchWarningsCount() > 4 ? TITLE_ROW : HIDDEN_ROW))
#else
#define SW_WARN_ROWS uint8_t(NAVIGATION_LINE_BY_LINE|(getSwitchWarningsCount()-1)), uint8_t(getSwitchWarningsCount() > MAX_SWITCH_PER_LINE ? TITLE_ROW : HIDDEN_ROW)
#define SW_WARN_ROWS \
PREFLIGHT_ROW(uint8_t(NAVIGATION_LINE_BY_LINE|(getSwitchWarningsCount()-1))), \
PREFLIGHT_ROW(uint8_t(getSwitchWarningsCount() > MAX_SWITCH_PER_LINE ? TITLE_ROW : HIDDEN_ROW))
#endif
inline uint8_t MODULE_TYPE_ROWS(int moduleIdx)
@@ -272,13 +322,20 @@ inline uint8_t MODULE_SUBTYPE_ROWS(int moduleIdx)
return HIDDEN_ROW;
}
#define POT_WARN_ROWS ((g_model.potsWarnMode) ? (uint8_t)(NUM_POTS+NUM_SLIDERS) : (uint8_t)0)
inline uint8_t TIMER_ROW(uint8_t timer, uint8_t value)
{
if (g_model.timers[timer].mode > 0)
return value;
return HIDDEN_ROW;
}
#define POT_WARN_ROWS PREFLIGHT_ROW(((g_model.potsWarnMode) ? (uint8_t)(NUM_POTS+NUM_SLIDERS) : (uint8_t)0))
#define TIMER_ROWS(x) \
1, 0, \
(uint8_t)((g_model.timers[x].start) ? 2 : 1), \
0, 0, \
g_model.timers[x].countdownBeep != COUNTDOWN_SILENT ? (uint8_t)1 \
: (uint8_t)0
1, TIMER_ROW(x,0), \
TIMER_ROW(x,(uint8_t)((g_model.timers[x].start) ? 2 : 1)), \
TIMER_ROW(x,0), TIMER_ROW(x,0), \
TIMER_ROW(x,g_model.timers[x].countdownBeep != COUNTDOWN_SILENT ? (uint8_t)1 : (uint8_t)0)
#define EXTRA_MODULE_ROWS
@@ -453,7 +510,7 @@ void editTimerCountdown(int timerIdx, coord_t y, LcdFlags attr, event_t event)
POT_WARN_ROWS, /* Pot warning */
#else
#define WARN_ROWS \
NUM_SWITCHES - 1, /* Switch warning */
PREFLIGHT_ROW((NUM_SWITCHES - 1), /* Switch warning */
#endif
#if defined(USBJ_EX)
@@ -479,6 +536,23 @@ inline uint8_t USB_JOYSTICK_APPLYROW()
static const char* _fct_sw_start[] = { STR_CHAR_UP, STR_CHAR_DOWN, "=" };
#endif
uint8_t viewOptChoice(coord_t y, const char* title, uint8_t value, uint8_t attr, event_t event)
{
lcdDrawText(INDENT_WIDTH-1, y, title);
return editChoice(96, y, nullptr, STR_ADCFILTERVALUES, value, 0, 2, attr, event);
}
uint8_t expandableSection(coord_t y, const char* title, uint8_t value, uint8_t attr, event_t event)
{
lcdDrawTextAlignedLeft(y, title);
lcdDrawText(120, y, value ? STR_CHAR_UP : STR_CHAR_DOWN, attr);
if (attr && (event == EVT_KEY_BREAK(KEY_ENTER))) {
value = !value;
s_editMode = 0;
}
return value;
}
void menuModelSetup(event_t event)
{
int8_t old_editMode = s_editMode;
@@ -498,20 +572,20 @@ void menuModelSetup(event_t event)
1, // Extended trims
0, // Show trims
0, // Trims step
0, // Throttle reverse
0, // Throttle trace source
0, // Throttle trim
0, // Throttle trim switch
0, // Throttle section
THROTTLE_ROW(0), // Throttle reverse
THROTTLE_ROW(0), // Throttle trace source
THROTTLE_ROW(0), // Throttle trim
THROTTLE_ROW(0), // Throttle trim switch
LABEL(PreflightCheck),
0, // Checklist
0, // Throttle warning
0, // Custom position for throttle warning enable
0, // Custom position for throttle warning value
0, // Preflight section
PREFLIGHT_ROW(0), // Checklist
PREFLIGHT_ROW(0), // Throttle warning
PREFLIGHT_ROW(0), // Custom position for throttle warning enable
PREFLIGHT_ROW(0), // Custom position for throttle warning value
WARN_ROWS
NUM_STICKS + NUM_POTS + NUM_SLIDERS - 1, // Center beeps
0, // Global functions
0, // ADC Jitter filter
@@ -525,7 +599,21 @@ void menuModelSetup(event_t event)
TRAINER_ROWS,
USB_JOYSTICK_ROWS
// View options
0,
VIEWOPT_ROW(LABEL(RadioMenuTabs)),
VIEWOPT_ROW(0),
VIEWOPT_ROW(0),
VIEWOPT_ROW(LABEL(ModelMenuTabs)),
CASE_HELI(VIEWOPT_ROW(0))
CASE_FLIGHT_MODES(VIEWOPT_ROW(0))
VIEWOPT_ROW(0),
VIEWOPT_ROW(0),
VIEWOPT_ROW(0),
CASE_LUA_MODEL_SCRIPTS(VIEWOPT_ROW(0))
VIEWOPT_ROW(0),
USB_JOYSTICK_ROWS,
});
MENU_CHECK(menuTabModel, MENU_MODEL_SETUP, HEADER_LINE + ITEM_MODEL_SETUP_LINES_COUNT);
@@ -788,13 +876,18 @@ void menuModelSetup(event_t event)
g_model.trimInc = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_TRIMINC, STR_VTRIMINC, g_model.trimInc, -2, 2, attr, event);
break;
case ITEM_MODEL_SETUP_THROTTLE_LABEL:
expandState.throttle = expandableSection(y, STR_THROTTLE_LABEL, expandState.throttle, attr, event);
break;
case ITEM_MODEL_SETUP_THROTTLE_REVERSED:
g_model.throttleReversed = editCheckBox(g_model.throttleReversed, MODEL_SETUP_2ND_COLUMN, y, STR_THROTTLEREVERSE, attr, event );
lcdDrawText(INDENT_WIDTH, y, STR_THROTTLEREVERSE);
g_model.throttleReversed = editCheckBox(g_model.throttleReversed, MODEL_SETUP_2ND_COLUMN+20, y, nullptr, attr, event );
break;
case ITEM_MODEL_SETUP_THROTTLE_TRACE:
{
lcdDrawTextAlignedLeft(y, STR_TTRACE);
lcdDrawText(INDENT_WIDTH, y, STR_TTRACE);
if (attr)
CHECK_INCDEC_MODELVAR_ZERO_CHECK(
event, g_model.thrTraceSrc,
@@ -802,23 +895,24 @@ void menuModelSetup(event_t event)
isThrottleSourceAvailable);
uint8_t idx = throttleSource2Source(g_model.thrTraceSrc);
drawSource(MODEL_SETUP_2ND_COLUMN, y, idx, attr);
drawSource(MODEL_SETUP_2ND_COLUMN+20, y, idx, attr);
break;
}
case ITEM_MODEL_SETUP_THROTTLE_TRIM:
g_model.thrTrim = editCheckBox(g_model.thrTrim, MODEL_SETUP_2ND_COLUMN, y, STR_TTRIM, attr, event);
lcdDrawText(INDENT_WIDTH, y, STR_TTRIM);
g_model.thrTrim = editCheckBox(g_model.thrTrim, MODEL_SETUP_2ND_COLUMN+20, y, nullptr, attr, event);
break;
case ITEM_MODEL_SETUP_THROTTLE_TRIM_SWITCH:
lcdDrawTextAlignedLeft(y, STR_TTRIM_SW);
lcdDrawText(INDENT_WIDTH, y, STR_TTRIM_SW);
if (attr)
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.thrTrimSw, NUM_TRIMS - 1);
drawSource(MODEL_SETUP_2ND_COLUMN, y, g_model.getThrottleStickTrimSource(), attr);
drawSource(MODEL_SETUP_2ND_COLUMN+20, y, g_model.getThrottleStickTrimSource(), attr);
break;
case ITEM_MODEL_SETUP_PREFLIGHT_LABEL:
lcdDrawTextAlignedLeft(y, STR_PREFLIGHT);
expandState.preflight = expandableSection(y, STR_PREFLIGHT, expandState.preflight, attr, event);
break;
case ITEM_MODEL_SETUP_CHECKLIST_DISPLAY:
@@ -1008,12 +1102,6 @@ void menuModelSetup(event_t event)
}
break;
case ITEM_MODEL_SETUP_USE_GLOBAL_FUNCTIONS:
lcdDrawTextAlignedLeft(y, STR_USE_GLOBAL_FUNCS);
drawCheckBox(MODEL_SETUP_2ND_COLUMN, y, !g_model.noGlobalFunctions, attr);
if (attr) g_model.noGlobalFunctions = !checkIncDecModel(event, !g_model.noGlobalFunctions, 0, 1);
break;
case ITEM_MODEL_SETUP_USE_JITTER_FILTER:
g_model.jitterFilter = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_JITTER_FILTER, STR_ADCFILTERVALUES, g_model.jitterFilter, 0, 2, attr, event);
break;
@@ -2101,6 +2189,49 @@ void menuModelSetup(event_t event)
break;
#endif
case ITEM_VIEW_OPTIONS_LABEL:
expandState.viewOpt = expandableSection(y, STR_VIEW_OPTIONS, expandState.viewOpt, attr, event);
break;
case ITEM_VIEW_OPTIONS_RADIO_TAB:
lcdDrawText(INDENT_WIDTH-2, y, TR_RADIO_MENU_TABS);
break;
case ITEM_VIEW_OPTIONS_GF:
g_model.radioGFDisabled = viewOptChoice(y, STR_MENUSPECIALFUNCS, g_model.radioGFDisabled, attr, event);
break;
case ITEM_VIEW_OPTIONS_TRAINER:
g_model.radioTrainerDisabled = viewOptChoice(y, STR_MENUTRAINER, g_model.radioTrainerDisabled, attr, event);
break;
case ITEM_VIEW_OPTIONS_MODEL_TAB:
lcdDrawText(INDENT_WIDTH-2, y, TR_MODEL_MENU_TABS);
break;
#if defined(HELI)
case ITEM_VIEW_OPTIONS_HELI:
g_model.modelHeliDisabled = viewOptChoice(y, STR_MENUHELISETUP, g_model.modelHeliDisabled, attr, event);
break;
#endif
#if defined(FLIGHT_MODES)
case ITEM_VIEW_OPTIONS_FM:
g_model.modelFMDisabled = viewOptChoice(y, STR_MENUFLIGHTMODES, g_model.modelFMDisabled, attr, event);
break;
#endif
case ITEM_VIEW_OPTIONS_CURVES:
g_model.modelCurvesDisabled = viewOptChoice(y, STR_MENUCURVES, g_model.modelCurvesDisabled, attr, event);
break;
case ITEM_VIEW_OPTIONS_LS:
g_model.modelLSDisabled = viewOptChoice(y, STR_MENULOGICALSWITCHES, g_model.modelLSDisabled, attr, event);
break;
case ITEM_VIEW_OPTIONS_SF:
g_model.modelSFDisabled = viewOptChoice(y, STR_MENUCUSTOMFUNC, g_model.modelSFDisabled, attr, event);
break;
#if defined(LUA_MODEL_SCRIPTS)
case ITEM_VIEW_OPTIONS_CUSTOM_SCRIPTS:
g_model.modelCustomScriptsDisabled = viewOptChoice(y, STR_MENUCUSTOMSCRIPTS, g_model.modelCustomScriptsDisabled, attr, event);
break;
#endif
case ITEM_VIEW_OPTIONS_TELEMETRY:
g_model.modelTelemetryDisabled = viewOptChoice(y, STR_MENUTELEMETRY, g_model.modelTelemetryDisabled, attr, event);
break;
#if defined(USBJ_EX)
case ITEM_MODEL_SETUP_USBJOYSTICK_LABEL:
lcdDrawTextAlignedLeft(y, STR_USBJOYSTICK_LABEL);