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:
@@ -144,8 +144,8 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
#define CURSOR_ON_LINE() (0)
|
||||
#endif
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow);
|
||||
void check_simple(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t menuTabSize, vertpos_t maxrow);
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow);
|
||||
void check_simple(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, vertpos_t maxrow);
|
||||
void check_submenu_simple(event_t event, uint8_t maxrow);
|
||||
|
||||
void title(const char * s);
|
||||
|
||||
@@ -77,16 +77,21 @@ void menuRadioPowerMeter(event_t event);
|
||||
void menuRadioCalibration(event_t event);
|
||||
void menuGhostModuleConfig(event_t event);
|
||||
|
||||
static const MenuHandlerFunc menuTabGeneral[MENU_RADIO_PAGES_COUNT] = {
|
||||
extern bool radioGFEnabled();
|
||||
extern bool radioTrainerEnabled();
|
||||
|
||||
static const MenuHandler menuTabGeneral[MENU_RADIO_PAGES_COUNT] = {
|
||||
#if defined(RADIO_TOOLS)
|
||||
menuRadioTools,
|
||||
{ menuRadioTools, nullptr },
|
||||
#endif
|
||||
CASE_SDCARD(menuRadioSdManager)
|
||||
menuRadioSetup,
|
||||
menuRadioSpecialFunctions,
|
||||
menuRadioTrainer,
|
||||
menuRadioHardware,
|
||||
menuRadioVersion
|
||||
#if defined(SDCARD)
|
||||
{ menuRadioSdManager, nullptr },
|
||||
#endif
|
||||
{ menuRadioSetup, nullptr },
|
||||
{ menuRadioSpecialFunctions, radioGFEnabled },
|
||||
{ menuRadioTrainer, radioTrainerEnabled },
|
||||
{ menuRadioHardware, nullptr },
|
||||
{ menuRadioVersion, nullptr }
|
||||
};
|
||||
|
||||
enum MenuModelIndexes {
|
||||
@@ -135,22 +140,34 @@ void menuModelGVarOne(event_t event);
|
||||
void menuModelUSBJoystick(event_t event);
|
||||
#endif
|
||||
|
||||
static const MenuHandlerFunc menuTabModel[] = {
|
||||
menuModelSelect,
|
||||
menuModelSetup,
|
||||
CASE_HELI(menuModelHeli)
|
||||
CASE_FLIGHT_MODES(menuModelFlightModesAll)
|
||||
menuModelExposAll,
|
||||
menuModelMixAll,
|
||||
menuModelLimits,
|
||||
menuModelCurvesAll,
|
||||
menuModelLogicalSwitches,
|
||||
menuModelSpecialFunctions,
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
menuModelCustomScripts,
|
||||
extern bool modelHeliEnabled();
|
||||
extern bool modelFMEnabled();
|
||||
extern bool modelCurvesEnabled();
|
||||
extern bool modelLSEnabled();
|
||||
extern bool modelSFEnabled();
|
||||
extern bool modelCustomScriptsEnabled();
|
||||
extern bool modelTelemetryEnabled();
|
||||
|
||||
static const MenuHandler menuTabModel[] = {
|
||||
{ menuModelSelect, nullptr },
|
||||
{ menuModelSetup, nullptr },
|
||||
#if defined(HELI)
|
||||
{ menuModelHeli, modelHeliEnabled },
|
||||
#endif
|
||||
menuModelTelemetry,
|
||||
menuModelDisplay,
|
||||
#if defined(FLIGHT_MODES)
|
||||
{ menuModelFlightModesAll, modelFMEnabled },
|
||||
#endif
|
||||
{ menuModelExposAll, nullptr },
|
||||
{ menuModelMixAll, nullptr },
|
||||
{ menuModelLimits, nullptr },
|
||||
{ menuModelCurvesAll, modelCurvesEnabled },
|
||||
{ menuModelLogicalSwitches, modelLSEnabled },
|
||||
{ menuModelSpecialFunctions, modelSFEnabled },
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
{ menuModelCustomScripts, modelCustomScriptsEnabled },
|
||||
#endif
|
||||
{ menuModelTelemetry, modelTelemetryEnabled },
|
||||
{ menuModelDisplay, nullptr }
|
||||
};
|
||||
|
||||
void menuStatisticsView(event_t event);
|
||||
|
||||
@@ -48,6 +48,13 @@ enum ExposFields {
|
||||
EXPO_FIELD_MAX
|
||||
};
|
||||
|
||||
uint8_t FM_ROW(uint8_t value)
|
||||
{
|
||||
if (modelFMEnabled())
|
||||
return value;
|
||||
return HIDDEN_ROW;
|
||||
}
|
||||
|
||||
void menuModelExpoOne(event_t event)
|
||||
{
|
||||
#if defined(KEYS_GPIO_REG_MDL)
|
||||
@@ -71,7 +78,9 @@ void menuModelExpoOne(event_t event)
|
||||
|
||||
uint8_t old_editMode = s_editMode;
|
||||
|
||||
SUBMENU(STR_MENUINPUTS, EXPO_FIELD_MAX, {0, 0, 0, ed->srcRaw >= MIXSRC_FIRST_TELEM ? (uint8_t)0 : (uint8_t)HIDDEN_ROW, 0, 0, LABEL(Curve), 1, CASE_FLIGHT_MODES(LABEL(Flight Mode)) CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/});
|
||||
SUBMENU(STR_MENUINPUTS, EXPO_FIELD_MAX,
|
||||
{0, 0, 0, ed->srcRaw >= MIXSRC_FIRST_TELEM ? (uint8_t)0 : (uint8_t)HIDDEN_ROW, 0, 0, LABEL(Curve), 1,
|
||||
CASE_FLIGHT_MODES(FM_ROW(LABEL(Flight Mode))) CASE_FLIGHT_MODES(FM_ROW((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE)) 0 /*, ...*/});
|
||||
|
||||
int8_t sub = menuVerticalPosition;
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ enum MixFields {
|
||||
MIX_FIELD_COUNT
|
||||
};
|
||||
|
||||
extern uint8_t FM_ROW(uint8_t);
|
||||
|
||||
void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
|
||||
{
|
||||
const int gaugeWidth = 33;
|
||||
@@ -107,22 +109,23 @@ void menuModelMixOne(event_t event)
|
||||
|
||||
uint8_t old_editMode = s_editMode;
|
||||
|
||||
SUBMENU(STR_MIXES, MIX_FIELD_COUNT, {0, 0, 0, 0, 0, 1, CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
|
||||
SUBMENU(STR_MIXES, MIX_FIELD_COUNT,
|
||||
{0, 0, 0, 0, 0, 1, CASE_FLIGHT_MODES(FM_ROW((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE)) 0, 0 /*, ...*/});
|
||||
|
||||
int8_t sub = menuVerticalPosition;
|
||||
int8_t editMode = s_editMode;
|
||||
|
||||
for (int k=0; k<LCD_LINES-1; k++) {
|
||||
coord_t y;
|
||||
if (k >= LCD_LINES-1)
|
||||
y = 1 + (k-LCD_LINES+2)*FH;
|
||||
else
|
||||
y = 1 + (k+1)*FH;
|
||||
int8_t i = k;
|
||||
|
||||
i += menuVerticalOffset;
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1;
|
||||
|
||||
for (int k=0; k<NUM_BODY_LINES; k++) {
|
||||
int i = k + menuVerticalOffset;
|
||||
for (int j=0; j<=i; ++j) {
|
||||
if (j<(int)DIM(mstate_tab) && mstate_tab[j] == HIDDEN_ROW) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
LcdFlags attr = (sub==i ? (editMode>0 ? BLINK|INVERS : INVERS) : 0);
|
||||
|
||||
switch(i) {
|
||||
case MIX_FIELD_NAME:
|
||||
editSingleName(MIXES_2ND_COLUMN, y, STR_MIXNAME, md2->name,
|
||||
@@ -205,5 +208,6 @@ void menuModelMixOne(event_t event)
|
||||
md2->speedDown = EDIT_DELAY(0, y, event, attr, STR_SLOWDOWN, md2->speedDown);
|
||||
break;
|
||||
}
|
||||
y += FH;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ void menuModelSelect(event_t event)
|
||||
|
||||
#if defined(KEYS_GPIO_REG_PAGEDN)
|
||||
case EVT_KEY_FIRST(KEY_PAGEUP):
|
||||
chainMenu(menuTabModel[DIM(menuTabModel)-1]);
|
||||
chainMenu(menuTabModel[DIM(menuTabModel)-1].menuFunc);
|
||||
killEvents(event);
|
||||
break;
|
||||
|
||||
@@ -224,7 +224,7 @@ void menuModelSelect(event_t event)
|
||||
break;
|
||||
#elif defined(KEYS_GPIO_REG_PAGE)
|
||||
case EVT_KEY_LONG(KEY_PAGE):
|
||||
chainMenu(menuTabModel[DIM(menuTabModel)-1]);
|
||||
chainMenu(menuTabModel[DIM(menuTabModel)-1].menuFunc);
|
||||
killEvents(event);
|
||||
break;
|
||||
|
||||
@@ -242,7 +242,7 @@ void menuModelSelect(event_t event)
|
||||
if ((!IS_ROTARY_RIGHT(event) && !IS_ROTARY_LEFT(event)) || s_editMode < 0) {
|
||||
#endif
|
||||
if (sub == g_eeGeneral.currModel) {
|
||||
chainMenu((IS_ROTARY_RIGHT(event) || event == EVT_KEY_FIRST(KEY_RIGHT)) ? menuModelSetup : menuTabModel[DIM(menuTabModel)-1]);
|
||||
chainMenu((IS_ROTARY_RIGHT(event) || event == EVT_KEY_FIRST(KEY_RIGHT)) ? menuModelSetup : menuTabModel[DIM(menuTabModel)-1].menuFunc);
|
||||
}
|
||||
else {
|
||||
AUDIO_WARNING2();
|
||||
@@ -291,12 +291,14 @@ void menuModelSelect(event_t event)
|
||||
lcdDrawNumber(lcdLastRightPos+3, 0, reusableBuffer.modelsel.eepromfree, LEFT);
|
||||
#endif
|
||||
|
||||
extern uint8_t menuSize(const MenuHandler*, uint8_t);
|
||||
uint8_t sz = menuSize(menuTabModel, DIM(menuTabModel));
|
||||
#if defined(NAVIGATION_X7)
|
||||
drawScreenIndex(MENU_MODEL_SELECT, DIM(menuTabModel), 0);
|
||||
drawScreenIndex(MENU_MODEL_SELECT, sz, 0);
|
||||
#elif defined(ROTARY_ENCODER_NAVIGATION)
|
||||
drawScreenIndex(MENU_MODEL_SELECT, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? ((IS_ROTARY_ENCODER_NAVIGATION_ENABLE() && s_editMode < 0) ? INVERS|BLINK : INVERS) : 0);
|
||||
drawScreenIndex(MENU_MODEL_SELECT, sz, (sub == g_eeGeneral.currModel) ? ((IS_ROTARY_ENCODER_NAVIGATION_ENABLE() && s_editMode < 0) ? INVERS|BLINK : INVERS) : 0);
|
||||
#else
|
||||
drawScreenIndex(MENU_MODEL_SELECT, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? INVERS : 0);
|
||||
drawScreenIndex(MENU_MODEL_SELECT, sz, (sub == g_eeGeneral.currModel) ? INVERS : 0);
|
||||
#endif
|
||||
|
||||
title(STR_MENUMODELSEL);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -106,6 +106,18 @@ enum {
|
||||
CASE_ROTARY_ENCODER(ITEM_RADIO_SETUP_ROTARY_ENC_MODE)
|
||||
ITEM_RADIO_SETUP_STICK_MODE_LABELS,
|
||||
ITEM_RADIO_SETUP_STICK_MODE,
|
||||
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,
|
||||
CASE_LUA_MODEL_SCRIPTS(ITEM_VIEW_OPTIONS_CUSTOM_SCRIPTS)
|
||||
ITEM_VIEW_OPTIONS_TELEMETRY,
|
||||
ITEM_RADIO_SETUP_MAX
|
||||
};
|
||||
|
||||
@@ -115,6 +127,12 @@ enum {
|
||||
#define COL_TX_MODE LABEL(TX_MODE)
|
||||
#endif
|
||||
|
||||
uint8_t viewOptCheckBox(coord_t y, const char* title, uint8_t value, uint8_t attr, event_t event)
|
||||
{
|
||||
lcdDrawText(INDENT_WIDTH, y, title);
|
||||
return !editCheckBox(!value, 110, y, nullptr, attr, event ) ;
|
||||
}
|
||||
|
||||
void menuRadioSetup(event_t event)
|
||||
{
|
||||
#if defined(RTCLOCK)
|
||||
@@ -180,7 +198,9 @@ void menuRadioSetup(event_t event)
|
||||
0, // USB mode
|
||||
CASE_JACK_DETECT(0) // Jack mode
|
||||
CASE_ROTARY_ENCODER(0)
|
||||
0, COL_TX_MODE, 0, 1/*to force edit mode*/});
|
||||
0, COL_TX_MODE, 0,
|
||||
LABEL(ViewOptions), LABEL(RadioMenuTabs), 0, 0, LABEL(ModelMenuTabs), CASE_HELI(0) CASE_FLIGHT_MODES(0) 0, 0, 0, CASE_LUA_MODEL_SCRIPTS(0) 0,
|
||||
1/*to force edit mode*/});
|
||||
|
||||
if (event == EVT_ENTRY) {
|
||||
reusableBuffer.generalSettings.stickMode = g_eeGeneral.stickMode;
|
||||
@@ -701,6 +721,49 @@ void menuRadioSetup(event_t event)
|
||||
waitKeysReleased();
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_VIEW_OPTIONS_LABEL:
|
||||
lcdDrawTextAlignedLeft(y, STR_VIEW_OPTIONS);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_RADIO_TAB:
|
||||
lcdDrawText(INDENT_WIDTH-2, y, TR_RADIO_MENU_TABS);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_GF:
|
||||
g_eeGeneral.radioGFDisabled = viewOptCheckBox(y, STR_MENUSPECIALFUNCS, g_eeGeneral.radioGFDisabled, attr, event);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_TRAINER:
|
||||
g_eeGeneral.radioTrainerDisabled = viewOptCheckBox(y, STR_MENUTRAINER, g_eeGeneral.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_eeGeneral.modelHeliDisabled = viewOptCheckBox(y, STR_MENUHELISETUP, g_eeGeneral.modelHeliDisabled, attr, event);
|
||||
break;
|
||||
#endif
|
||||
#if defined(FLIGHT_MODES)
|
||||
case ITEM_VIEW_OPTIONS_FM:
|
||||
g_eeGeneral.modelFMDisabled = viewOptCheckBox(y, STR_MENUFLIGHTMODES, g_eeGeneral.modelFMDisabled, attr, event);
|
||||
break;
|
||||
#endif
|
||||
case ITEM_VIEW_OPTIONS_CURVES:
|
||||
g_eeGeneral.modelCurvesDisabled = viewOptCheckBox(y, STR_MENUCURVES, g_eeGeneral.modelCurvesDisabled, attr, event);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_LS:
|
||||
g_eeGeneral.modelLSDisabled = viewOptCheckBox(y, STR_MENULOGICALSWITCHES, g_eeGeneral.modelLSDisabled, attr, event);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_SF:
|
||||
g_eeGeneral.modelSFDisabled = viewOptCheckBox(y, STR_MENUCUSTOMFUNC, g_eeGeneral.modelSFDisabled, attr, event);
|
||||
break;
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
case ITEM_VIEW_OPTIONS_CUSTOM_SCRIPTS:
|
||||
g_eeGeneral.modelCustomScriptsDisabled = viewOptCheckBox(y, STR_MENUCUSTOMSCRIPTS, g_eeGeneral.modelCustomScriptsDisabled, attr, event);
|
||||
break;
|
||||
#endif
|
||||
case ITEM_VIEW_OPTIONS_TELEMETRY:
|
||||
g_eeGeneral.modelTelemetryDisabled = viewOptCheckBox(y, STR_MENUTELEMETRY, g_eeGeneral.modelTelemetryDisabled, attr, event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ void menuMainView(event_t event)
|
||||
break;
|
||||
|
||||
case EVT_KEY_GENERAL_MENU:
|
||||
pushMenu(menuTabGeneral[0]);
|
||||
pushMenu(menuTabGeneral[0].menuFunc);
|
||||
killEvents(event);
|
||||
break;
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int
|
||||
|
||||
// TRACE("editGVarFieldValue(val=%d min=%d max=%d)", value, min, max);
|
||||
|
||||
if (invers && event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
if (modelGVEnabled() && invers && event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
s_editMode = !s_editMode;
|
||||
if (attr & PREC1)
|
||||
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode)*10 : delta);
|
||||
|
||||
@@ -164,8 +164,8 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
#define CURSOR_ON_LINE() (menuHorizontalPosition<0)
|
||||
|
||||
#define CHECK_FLAG_NO_SCREEN_INDEX 1
|
||||
void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow, uint8_t flags=0);
|
||||
void check_simple(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t menuTabSize, vertpos_t maxrow);
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow, uint8_t flags=0);
|
||||
void check_simple(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, vertpos_t maxrow);
|
||||
void check_submenu_simple(event_t event, uint8_t maxrow);
|
||||
|
||||
void title(const char * s);
|
||||
|
||||
@@ -21,25 +21,29 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
const MenuHandlerFunc menuTabModel[] = {
|
||||
menuModelSelect,
|
||||
menuModelSetup,
|
||||
CASE_HELI(menuModelHeli)
|
||||
CASE_FLIGHT_MODES(menuModelFlightModesAll)
|
||||
menuModelExposAll,
|
||||
menuModelMixAll,
|
||||
menuModelLimits,
|
||||
menuModelCurvesAll,
|
||||
const MenuHandler menuTabModel[] = {
|
||||
{ menuModelSelect, nullptr },
|
||||
{ menuModelSetup, nullptr },
|
||||
#if defined(HELI)
|
||||
{ menuModelHeli, modelHeliEnabled },
|
||||
#endif
|
||||
#if defined(FLIGHT_MODES)
|
||||
{ menuModelFlightModesAll, modelFMEnabled },
|
||||
#endif
|
||||
{ menuModelExposAll, nullptr },
|
||||
{ menuModelMixAll, nullptr },
|
||||
{ menuModelLimits, nullptr },
|
||||
{ menuModelCurvesAll, modelCurvesEnabled },
|
||||
#if defined(GVARS) && defined(FLIGHT_MODES)
|
||||
CASE_GVARS(menuModelGVars)
|
||||
{ menuModelGVars, modelGVEnabled },
|
||||
#endif
|
||||
menuModelLogicalSwitches,
|
||||
menuModelSpecialFunctions,
|
||||
{ menuModelLogicalSwitches, modelLSEnabled },
|
||||
{ menuModelSpecialFunctions, modelSFEnabled },
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
menuModelCustomScripts,
|
||||
{ menuModelCustomScripts, modelCustomScriptsEnabled },
|
||||
#endif
|
||||
menuModelTelemetry,
|
||||
menuModelDisplay
|
||||
{ menuModelTelemetry, modelTelemetryEnabled },
|
||||
{ menuModelDisplay, nullptr }
|
||||
};
|
||||
|
||||
uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const char * str, uint8_t delay)
|
||||
|
||||
@@ -21,16 +21,16 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
const MenuHandlerFunc menuTabGeneral[MENU_RADIO_PAGES_COUNT] = {
|
||||
const MenuHandler menuTabGeneral[MENU_RADIO_PAGES_COUNT] = {
|
||||
#if defined(RADIO_TOOLS)
|
||||
menuRadioTools,
|
||||
{ menuRadioTools, nullptr },
|
||||
#endif
|
||||
menuRadioSdManager,
|
||||
menuRadioSetup,
|
||||
menuRadioSpecialFunctions,
|
||||
menuRadioTrainer,
|
||||
menuRadioHardware,
|
||||
menuRadioVersion
|
||||
{ menuRadioSdManager, nullptr },
|
||||
{ menuRadioSetup, nullptr },
|
||||
{ menuRadioSpecialFunctions, radioGFEnabled },
|
||||
{ menuRadioTrainer, radioTrainerEnabled },
|
||||
{ menuRadioHardware, nullptr },
|
||||
{ menuRadioVersion, nullptr }
|
||||
};
|
||||
|
||||
void menuRadioSpecialFunctions(event_t event)
|
||||
|
||||
@@ -79,7 +79,7 @@ void menuRadioSpectrumAnalyser(event_t event);
|
||||
void menuRadioPowerMeter(event_t event);
|
||||
void menuGhostModuleConfig(event_t event);
|
||||
|
||||
extern const MenuHandlerFunc menuTabGeneral[MENU_RADIO_PAGES_COUNT];
|
||||
extern const MenuHandler menuTabGeneral[MENU_RADIO_PAGES_COUNT];
|
||||
|
||||
enum MenuModelIndexes {
|
||||
MENU_MODEL_SELECT,
|
||||
@@ -126,6 +126,6 @@ void menuModelDisplay(event_t event);
|
||||
void menuModelUSBJoystick(event_t event);
|
||||
#endif
|
||||
|
||||
extern const MenuHandlerFunc menuTabModel[MENU_MODEL_PAGES_COUNT];
|
||||
extern const MenuHandler menuTabModel[MENU_MODEL_PAGES_COUNT];
|
||||
|
||||
#endif // _MENUS_H_
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
static int numFlightModes() { return modelFMEnabled() ? MAX_FLIGHT_MODES : 1; }
|
||||
|
||||
void editGVarValue(coord_t x, coord_t y, event_t event, uint8_t gvar, uint8_t flightMode, LcdFlags flags)
|
||||
{
|
||||
FlightModeData * fm = &g_model.flightModeData[flightMode];
|
||||
@@ -75,7 +77,7 @@ void menuModelGVarOne(event_t event)
|
||||
|
||||
uint8_t old_editMode = s_editMode;
|
||||
|
||||
SIMPLE_SUBMENU(STR_GVARS, GVAR_FIELD_LAST);
|
||||
SIMPLE_SUBMENU(STR_GVARS, modelFMEnabled() ? GVAR_FIELD_LAST : GVAR_FIELD_FM0+1);
|
||||
|
||||
for (int i=0; i<NUM_BODY_LINES; i++) {
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1 + i * FH;
|
||||
@@ -112,7 +114,10 @@ void menuModelGVarOne(event_t event)
|
||||
break;
|
||||
|
||||
default:
|
||||
drawStringWithIndex(0, y, STR_FM, k-GVAR_FIELD_FM0);
|
||||
if (modelFMEnabled())
|
||||
drawStringWithIndex(0, y, STR_FM, k-GVAR_FIELD_FM0);
|
||||
else
|
||||
lcdDrawText(0, y, STR_VALUE);
|
||||
editGVarValue(GVAR_2ND_COLUMN, y, event, s_currIdx, k-GVAR_FIELD_FM0, LEFT|attr);
|
||||
break;
|
||||
}
|
||||
@@ -135,14 +140,19 @@ void onGVARSMenu(const char * result)
|
||||
}
|
||||
}
|
||||
|
||||
#define GVARS_COLUMNS (NAVIGATION_LINE_BY_LINE|(MAX_FLIGHT_MODES-1))
|
||||
#define GVARS_FM_COLUMN(p) (7*FW - 7 + (p)*20)
|
||||
|
||||
uint8_t colCount() {
|
||||
if (modelFMEnabled())
|
||||
return NAVIGATION_LINE_BY_LINE | (MAX_FLIGHT_MODES - 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void menuModelGVars(event_t event)
|
||||
{
|
||||
tmr10ms_t tmr10ms = get_tmr10ms();
|
||||
const char * menuTitle;
|
||||
bool after2seconds = (tmr10ms - menuEntryTime > 200); /*2 seconds*/
|
||||
bool after2seconds = modelFMEnabled() && (tmr10ms - menuEntryTime > 200); /*2 seconds*/
|
||||
|
||||
if (after2seconds) {
|
||||
menuTitle = STR_GVARS;
|
||||
@@ -154,7 +164,8 @@ void menuModelGVars(event_t event)
|
||||
menuTitle = STR_MENU_GLOBAL_VARS;
|
||||
}
|
||||
|
||||
MENU_FLAGS(menuTitle, menuTabModel, MENU_MODEL_GVARS, after2seconds ? CHECK_FLAG_NO_SCREEN_INDEX : 0, MAX_GVARS, { GVARS_COLUMNS, GVARS_COLUMNS, GVARS_COLUMNS, GVARS_COLUMNS, GVARS_COLUMNS, GVARS_COLUMNS, GVARS_COLUMNS, GVARS_COLUMNS, GVARS_COLUMNS });
|
||||
MENU_FLAGS(menuTitle, menuTabModel, MENU_MODEL_GVARS, after2seconds ? CHECK_FLAG_NO_SCREEN_INDEX : 0, MAX_GVARS,
|
||||
{ colCount(), colCount(), colCount(), colCount(), colCount(), colCount(), colCount(), colCount(), colCount() });
|
||||
|
||||
int sub = menuVerticalPosition;
|
||||
|
||||
@@ -164,7 +175,7 @@ void menuModelGVars(event_t event)
|
||||
|
||||
drawGVarName(0, y, i, (sub==i && menuHorizontalPosition<0) ? INVERS : 0);
|
||||
|
||||
for (int j=0; j<MAX_FLIGHT_MODES; j++) {
|
||||
for (int j=0; j<numFlightModes(); j++) {
|
||||
FlightModeData * fm = &g_model.flightModeData[j];
|
||||
gvar_t v = fm->gvars[i];
|
||||
|
||||
@@ -185,7 +196,7 @@ void menuModelGVars(event_t event)
|
||||
}
|
||||
}
|
||||
|
||||
if (menuHorizontalPosition<0 && event==EVT_KEY_LONG(KEY_ENTER)) {
|
||||
if ((menuHorizontalPosition<0 || !modelFMEnabled()) && event==EVT_KEY_LONG(KEY_ENTER)) {
|
||||
killEvents(event);
|
||||
POPUP_MENU_ADD_ITEM(STR_EDIT);
|
||||
POPUP_MENU_ADD_ITEM(STR_CLEAR);
|
||||
|
||||
@@ -48,6 +48,13 @@ enum ExposFields {
|
||||
|
||||
#define CURVE_ROWS 1
|
||||
|
||||
uint8_t FM_ROW(uint8_t value)
|
||||
{
|
||||
if (modelFMEnabled())
|
||||
return value;
|
||||
return HIDDEN_ROW;
|
||||
}
|
||||
|
||||
void menuModelExpoOne(event_t event)
|
||||
{
|
||||
if (event == EVT_KEY_LONG(KEY_MENU)) {
|
||||
@@ -61,7 +68,9 @@ void menuModelExpoOne(event_t event)
|
||||
|
||||
uint8_t old_editMode = s_editMode;
|
||||
|
||||
SUBMENU(STR_MENUINPUTS, EXPO_FIELD_MAX, {0, 0, 0, ed->srcRaw >= MIXSRC_FIRST_TELEM ? (uint8_t)0 : (uint8_t)HIDDEN_ROW, 0, 0, CURVE_ROWS, CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/});
|
||||
SUBMENU(STR_MENUINPUTS, EXPO_FIELD_MAX,
|
||||
{0, 0, 0, ed->srcRaw >= MIXSRC_FIRST_TELEM ? (uint8_t)0 : (uint8_t)HIDDEN_ROW, 0, 0, CURVE_ROWS,
|
||||
CASE_FLIGHT_MODES(FM_ROW((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE)) 0 /*, ...*/});
|
||||
|
||||
SET_SCROLLBAR_X(EXPO_ONE_2ND_COLUMN+10*FW);
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ enum MixFields {
|
||||
MIX_FIELD_COUNT
|
||||
};
|
||||
|
||||
extern uint8_t FM_ROW(uint8_t);
|
||||
|
||||
void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
|
||||
{
|
||||
const int gaugeWidth = 33;
|
||||
@@ -97,14 +99,21 @@ void menuModelMixOne(event_t event)
|
||||
|
||||
uint8_t old_editMode = s_editMode;
|
||||
|
||||
SUBMENU(STR_MIXES, MIX_FIELD_COUNT, {0, 0, 0, 0, 0, 1, CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
|
||||
SUBMENU(STR_MIXES, MIX_FIELD_COUNT,
|
||||
{0, 0, 0, 0, 0, 1, CASE_FLIGHT_MODES(FM_ROW((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE)) 0, 0 /*, ...*/});
|
||||
|
||||
int8_t sub = menuVerticalPosition;
|
||||
int8_t editMode = s_editMode;
|
||||
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1;
|
||||
|
||||
for (uint8_t k=0; k<NUM_BODY_LINES; k++) {
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1 + k*FH;
|
||||
int i = k + menuVerticalOffset;
|
||||
for (int j=0; j<=i; ++j) {
|
||||
if (j<(int)DIM(mstate_tab) && mstate_tab[j] == HIDDEN_ROW) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
LcdFlags attr = (sub==i ? INVERS | (editMode>0 ? BLINK : 0) : 0);
|
||||
switch (i) {
|
||||
case MIX_FIELD_NAME:
|
||||
@@ -189,5 +198,6 @@ void menuModelMixOne(event_t event)
|
||||
md2->speedDown = EDIT_DELAY(y, event, attr, STR_SLOWDOWN, md2->speedDown);
|
||||
break;
|
||||
}
|
||||
y += FH;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ void menuModelSelect(event_t event)
|
||||
|
||||
case EVT_KEY_BREAK(KEY_PAGE):
|
||||
case EVT_KEY_LONG(KEY_PAGE):
|
||||
chainMenu(event == EVT_KEY_BREAK(KEY_PAGE) ? menuModelSetup : menuTabModel[DIM(menuTabModel)-1]);
|
||||
chainMenu(event == EVT_KEY_BREAK(KEY_PAGE) ? menuModelSetup : menuTabModel[DIM(menuTabModel)-1].menuFunc);
|
||||
killEvents(event);
|
||||
break;
|
||||
|
||||
@@ -249,7 +249,8 @@ void menuModelSelect(event_t event)
|
||||
lcdDrawText(lcdLastRightPos + 3, 0, STR_FREE);
|
||||
#endif
|
||||
|
||||
drawScreenIndex(MENU_MODEL_SELECT, DIM(menuTabModel), 0);
|
||||
extern uint8_t menuSize(const MenuHandler*, uint8_t);
|
||||
drawScreenIndex(MENU_MODEL_SELECT, menuSize(menuTabModel, DIM(menuTabModel)), 0);
|
||||
lcdDrawFilledRect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT);
|
||||
|
||||
title(STR_MENUMODELSEL);
|
||||
|
||||
@@ -95,7 +95,6 @@ enum MenuModelSetupItems {
|
||||
ITEM_MODEL_SETUP_POTS_WARNING2,
|
||||
#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,
|
||||
@@ -158,6 +157,22 @@ enum MenuModelSetupItems {
|
||||
ITEM_MODEL_SETUP_TRAINER_CHANNELS,
|
||||
ITEM_MODEL_SETUP_TRAINER_PPM_PARAMS,
|
||||
|
||||
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)
|
||||
CASE_GVARS(ITEM_VIEW_OPTIONS_GV)
|
||||
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,
|
||||
@@ -166,6 +181,7 @@ enum MenuModelSetupItems {
|
||||
ITEM_MODEL_SETUP_USBJOYSTICK_CH_BUTTON,
|
||||
ITEM_MODEL_SETUP_USBJOYSTICK_APPLY,
|
||||
#endif
|
||||
|
||||
ITEM_MODEL_SETUP_LINES_COUNT
|
||||
};
|
||||
|
||||
@@ -173,6 +189,35 @@ enum MenuModelSetupItems {
|
||||
#define MODEL_SETUP_3RD_COLUMN (MODEL_SETUP_2ND_COLUMN+6*FW)
|
||||
#define MODEL_SETUP_SET_FAILSAFE_OFS 10*FW-2
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void copySelection(char * dst, const char * src, uint8_t size)
|
||||
{
|
||||
if (memcmp(src, "---", 3) == 0)
|
||||
@@ -323,13 +368,18 @@ void editTimerCountdown(int timerIdx, coord_t y, LcdFlags attr, event_t event)
|
||||
#define TRAINER_ROWS LABEL(Trainer), 0, TRAINER_CHANNELS_ROW, TRAINER_PPM_PARAMS_ROW
|
||||
#endif
|
||||
|
||||
inline uint8_t TIMER_ROW(uint8_t timer, uint8_t value)
|
||||
{
|
||||
if (g_model.timers[timer].mode > 0)
|
||||
return value;
|
||||
return HIDDEN_ROW;
|
||||
}
|
||||
|
||||
#define TIMER_ROWS(x) \
|
||||
1 | NAVIGATION_LINE_BY_LINE, 0, \
|
||||
(uint8_t)(((g_model.timers[x].start) ? 2 : 1) | \
|
||||
NAVIGATION_LINE_BY_LINE), \
|
||||
0, 0, \
|
||||
g_model.timers[x].countdownBeep != COUNTDOWN_SILENT ? (uint8_t)1 \
|
||||
: (uint8_t)0
|
||||
1 | NAVIGATION_LINE_BY_LINE, TIMER_ROW(x,0), \
|
||||
TIMER_ROW(x,(uint8_t)((g_model.timers[x].start) ? 2 : 1) | NAVIGATION_LINE_BY_LINE), \
|
||||
TIMER_ROW(x,0), TIMER_ROW(x,0), \
|
||||
TIMER_ROW(x,g_model.timers[x].countdownBeep != COUNTDOWN_SILENT ? (uint8_t)1 : (uint8_t)0)
|
||||
|
||||
inline uint8_t EXTERNAL_MODULE_TYPE_ROW()
|
||||
{
|
||||
@@ -347,12 +397,19 @@ inline uint8_t EXTERNAL_MODULE_TYPE_ROW()
|
||||
#define TIMERS_ROWS TIMER_ROWS(0), TIMER_ROWS(1), TIMER_ROWS(2)
|
||||
#endif
|
||||
#if defined(PCBX9E)
|
||||
#define SW_WARN_ROWS uint8_t(NAVIGATION_LINE_BY_LINE|(getSwitchWarningsCount()-1)), uint8_t(getSwitchWarningsCount() > 8 ? TITLE_ROW : HIDDEN_ROW), uint8_t(getSwitchWarningsCount() > 16 ? TITLE_ROW : HIDDEN_ROW)
|
||||
#define POT_WARN_ROWS uint8_t(g_model.potsWarnMode ? NAVIGATION_LINE_BY_LINE|(NUM_POTS+NUM_SLIDERS) : 0), uint8_t(g_model.potsWarnMode ? TITLE_ROW : HIDDEN_ROW)
|
||||
#define SW_WARN_ROWS \
|
||||
PREFLIGHT_ROW(uint8_t(NAVIGATION_LINE_BY_LINE|(getSwitchWarningsCount()-1))), \
|
||||
PREFLIGHT_ROW(uint8_t(getSwitchWarningsCount() > 8 ? TITLE_ROW : HIDDEN_ROW)), \
|
||||
PREFLIGHT_ROW(uint8_t(getSwitchWarningsCount() > 16 ? TITLE_ROW : HIDDEN_ROW))
|
||||
#define POT_WARN_ROWS \
|
||||
PREFLIGHT_ROW(uint8_t(g_model.potsWarnMode ? NAVIGATION_LINE_BY_LINE|(NUM_POTS+NUM_SLIDERS) : 0)), \
|
||||
PREFLIGHT_ROW(uint8_t(g_model.potsWarnMode ? TITLE_ROW : HIDDEN_ROW))
|
||||
#define TOPLCD_ROWS 0,
|
||||
#else
|
||||
#define SW_WARN_ROWS uint8_t(NAVIGATION_LINE_BY_LINE|getSwitchWarningsCount())
|
||||
#define POT_WARN_ROWS uint8_t(g_model.potsWarnMode ? NAVIGATION_LINE_BY_LINE|(NUM_POTS+NUM_SLIDERS) : 0)
|
||||
#define SW_WARN_ROWS \
|
||||
PREFLIGHT_ROW(uint8_t(NAVIGATION_LINE_BY_LINE|getSwitchWarningsCount()))
|
||||
#define POT_WARN_ROWS \
|
||||
PREFLIGHT_ROW(uint8_t(g_model.potsWarnMode ? NAVIGATION_LINE_BY_LINE|(NUM_POTS+NUM_SLIDERS) : 0))
|
||||
#define TOPLCD_ROWS
|
||||
#endif
|
||||
|
||||
@@ -424,6 +481,26 @@ inline uint8_t USB_JOYSTICK_APPLYROW()
|
||||
#define USB_JOYSTICK_ROWS
|
||||
#endif
|
||||
|
||||
uint8_t viewOptChoice(coord_t y, const char* title, uint8_t value, uint8_t attr, event_t event, bool globalState)
|
||||
{
|
||||
lcdDrawText(INDENT_WIDTH*2, y, title);
|
||||
uint8_t rv = editChoice(MODEL_SETUP_2ND_COLUMN, y, nullptr, STR_ADCFILTERVALUES, value, 0, 2, attr, event);
|
||||
if (rv == OVERRIDE_GLOBAL)
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN + 40, y, STR_ADCFILTERVALUES[globalState == 0 ? 2 : 1]);
|
||||
return rv;
|
||||
}
|
||||
|
||||
uint8_t expandableSection(coord_t y, const char* title, uint8_t value, uint8_t attr, event_t event)
|
||||
{
|
||||
lcdDrawTextAlignedLeft(y, title);
|
||||
lcdDrawText(200, 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)
|
||||
{
|
||||
horzpos_t l_posHorz = menuHorizontalPosition;
|
||||
@@ -446,24 +523,22 @@ void menuModelSetup(event_t event)
|
||||
0, // Show trims
|
||||
0, // Trims step
|
||||
|
||||
LABEL(Throttle),
|
||||
0, // Thrxottle 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
|
||||
SW_WARN_ROWS, // Switch warning
|
||||
POT_WARN_ROWS, // Pot warning
|
||||
|
||||
NAVIGATION_LINE_BY_LINE | (NUM_STICKS+NUM_POTS+NUM_SLIDERS-1), // Center beeps
|
||||
|
||||
0, // Global functions
|
||||
|
||||
0, // ADC Jitter filter
|
||||
|
||||
REGISTRATION_ID_ROWS
|
||||
@@ -504,6 +579,21 @@ void menuModelSetup(event_t event)
|
||||
|
||||
TRAINER_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))
|
||||
CASE_GVARS(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
|
||||
});
|
||||
|
||||
@@ -693,7 +783,7 @@ void menuModelSetup(event_t event)
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_SETUP_THROTTLE_LABEL:
|
||||
lcdDrawTextAlignedLeft(y, STR_THROTTLE_LABEL);
|
||||
expandState.throttle = expandableSection(y, STR_THROTTLE_LABEL, expandState.throttle, attr, event);
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_SETUP_THROTTLE_REVERSED:
|
||||
@@ -726,7 +816,7 @@ void menuModelSetup(event_t event)
|
||||
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:
|
||||
@@ -937,12 +1027,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;
|
||||
@@ -1814,6 +1898,54 @@ 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, y, TR_RADIO_MENU_TABS);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_GF:
|
||||
g_model.radioGFDisabled = viewOptChoice(y, STR_MENUSPECIALFUNCS, g_model.radioGFDisabled, attr, event, g_eeGeneral.radioGFDisabled);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_TRAINER:
|
||||
g_model.radioTrainerDisabled = viewOptChoice(y, STR_MENUTRAINER, g_model.radioTrainerDisabled, attr, event, g_eeGeneral.radioTrainerDisabled);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_MODEL_TAB:
|
||||
lcdDrawText(INDENT_WIDTH, 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, g_eeGeneral.modelHeliDisabled);
|
||||
break;
|
||||
#endif
|
||||
#if defined(FLIGHT_MODES)
|
||||
case ITEM_VIEW_OPTIONS_FM:
|
||||
g_model.modelFMDisabled = viewOptChoice(y, STR_MENUFLIGHTMODES, g_model.modelFMDisabled, attr, event, g_eeGeneral.modelFMDisabled);
|
||||
break;
|
||||
#endif
|
||||
case ITEM_VIEW_OPTIONS_CURVES:
|
||||
g_model.modelCurvesDisabled = viewOptChoice(y, STR_MENUCURVES, g_model.modelCurvesDisabled, attr, event, g_eeGeneral.modelCurvesDisabled);
|
||||
break;
|
||||
#if defined(GVARS)
|
||||
case ITEM_VIEW_OPTIONS_GV:
|
||||
g_model.modelGVDisabled = viewOptChoice(y, STR_MENU_GLOBAL_VARS, g_model.modelGVDisabled, attr, event, g_eeGeneral.modelGVDisabled);
|
||||
break;
|
||||
#endif
|
||||
case ITEM_VIEW_OPTIONS_LS:
|
||||
g_model.modelLSDisabled = viewOptChoice(y, STR_MENULOGICALSWITCHES, g_model.modelLSDisabled, attr, event, g_eeGeneral.modelLSDisabled);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_SF:
|
||||
g_model.modelSFDisabled = viewOptChoice(y, STR_MENUCUSTOMFUNC, g_model.modelSFDisabled, attr, event, g_eeGeneral.modelSFDisabled);
|
||||
break;
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
case ITEM_VIEW_OPTIONS_CUSTOM_SCRIPTS:
|
||||
g_model.modelCustomScriptsDisabled = viewOptChoice(y, STR_MENUCUSTOMSCRIPTS, g_model.modelCustomScriptsDisabled, attr, event, g_eeGeneral.modelCustomScriptsDisabled);
|
||||
break;
|
||||
#endif
|
||||
case ITEM_VIEW_OPTIONS_TELEMETRY:
|
||||
g_model.modelTelemetryDisabled = viewOptChoice(y, STR_MENUTELEMETRY, g_model.modelTelemetryDisabled, attr, event, g_eeGeneral.modelTelemetryDisabled);
|
||||
break;
|
||||
|
||||
#if defined(USBJ_EX)
|
||||
case ITEM_MODEL_SETUP_USBJOYSTICK_LABEL:
|
||||
lcdDrawTextAlignedLeft(y, STR_USBJOYSTICK_LABEL);
|
||||
|
||||
@@ -99,9 +99,28 @@ enum MenuRadioSetupItems {
|
||||
CASE_ROTARY_ENCODER(ITEM_RADIO_SETUP_ROTARY_ENC_MODE)
|
||||
ITEM_RADIO_SETUP_STICK_MODE_LABELS,
|
||||
ITEM_RADIO_SETUP_STICK_MODE,
|
||||
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)
|
||||
CASE_GVARS(ITEM_VIEW_OPTIONS_GV)
|
||||
ITEM_VIEW_OPTIONS_CURVES,
|
||||
ITEM_VIEW_OPTIONS_LS,
|
||||
ITEM_VIEW_OPTIONS_SF,
|
||||
CASE_LUA_MODEL_SCRIPTS(ITEM_VIEW_OPTIONS_CUSTOM_SCRIPTS)
|
||||
ITEM_VIEW_OPTIONS_TELEMETRY,
|
||||
ITEM_RADIO_SETUP_MAX
|
||||
};
|
||||
|
||||
uint8_t viewOptCheckBox(coord_t y, const char* title, uint8_t value, uint8_t attr, event_t event)
|
||||
{
|
||||
lcdDrawText(INDENT_WIDTH*2, y, title);
|
||||
return !editCheckBox(!value, RADIO_SETUP_2ND_COLUMN, y, nullptr, attr, event );
|
||||
}
|
||||
|
||||
void menuRadioSetup(event_t event)
|
||||
{
|
||||
#if defined(RTCLOCK)
|
||||
@@ -181,6 +200,7 @@ void menuRadioSetup(event_t event)
|
||||
CASE_ROTARY_ENCODER(0) // Invert rotary encoder
|
||||
LABEL(TX_MODE),
|
||||
0, // sticks mode
|
||||
LABEL(ViewOptions), LABEL(RadioMenuTabs), 0, 0, LABEL(ModelMenuTabs), CASE_HELI(0) CASE_FLIGHT_MODES(0) CASE_GVARS(0) 0, 0, 0, CASE_LUA_MODEL_SCRIPTS(0) 0,
|
||||
1 /*to force edit mode*/
|
||||
});
|
||||
|
||||
@@ -196,6 +216,11 @@ void menuRadioSetup(event_t event)
|
||||
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH;
|
||||
uint8_t k = i + menuVerticalOffset;
|
||||
for (int j = 0; j <= k; j++) {
|
||||
if (mstate_tab[j] == HIDDEN_ROW)
|
||||
k++;
|
||||
}
|
||||
|
||||
uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS);
|
||||
uint8_t attr = (sub == k ? blink : 0);
|
||||
|
||||
@@ -631,6 +656,54 @@ void menuRadioSetup(event_t event)
|
||||
waitKeysReleased();
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_VIEW_OPTIONS_LABEL:
|
||||
lcdDrawTextAlignedLeft(y, STR_VIEW_OPTIONS);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_RADIO_TAB:
|
||||
lcdDrawText(INDENT_WIDTH, y, TR_RADIO_MENU_TABS);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_GF:
|
||||
g_eeGeneral.radioGFDisabled = viewOptCheckBox(y, STR_MENUSPECIALFUNCS, g_eeGeneral.radioGFDisabled, attr, event);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_TRAINER:
|
||||
g_eeGeneral.radioTrainerDisabled = viewOptCheckBox(y, STR_MENUTRAINER, g_eeGeneral.radioTrainerDisabled, attr, event);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_MODEL_TAB:
|
||||
lcdDrawText(INDENT_WIDTH, y, TR_MODEL_MENU_TABS);
|
||||
break;
|
||||
#if defined(HELI)
|
||||
case ITEM_VIEW_OPTIONS_HELI:
|
||||
g_eeGeneral.modelHeliDisabled = viewOptCheckBox(y, STR_MENUHELISETUP, g_eeGeneral.modelHeliDisabled, attr, event);
|
||||
break;
|
||||
#endif
|
||||
#if defined(FLIGHT_MODES)
|
||||
case ITEM_VIEW_OPTIONS_FM:
|
||||
g_eeGeneral.modelFMDisabled = viewOptCheckBox(y, STR_MENUFLIGHTMODES, g_eeGeneral.modelFMDisabled, attr, event);
|
||||
break;
|
||||
#endif
|
||||
case ITEM_VIEW_OPTIONS_CURVES:
|
||||
g_eeGeneral.modelCurvesDisabled = viewOptCheckBox(y, STR_MENUCURVES, g_eeGeneral.modelCurvesDisabled, attr, event);
|
||||
break;
|
||||
#if defined(GVARS)
|
||||
case ITEM_VIEW_OPTIONS_GV:
|
||||
g_model.modelGVDisabled = viewOptCheckBox(y, STR_MENU_GLOBAL_VARS, g_model.modelGVDisabled, attr, event);
|
||||
break;
|
||||
#endif
|
||||
case ITEM_VIEW_OPTIONS_LS:
|
||||
g_eeGeneral.modelLSDisabled = viewOptCheckBox(y, STR_MENULOGICALSWITCHES, g_eeGeneral.modelLSDisabled, attr, event);
|
||||
break;
|
||||
case ITEM_VIEW_OPTIONS_SF:
|
||||
g_eeGeneral.modelSFDisabled = viewOptCheckBox(y, STR_MENUCUSTOMFUNC, g_eeGeneral.modelSFDisabled, attr, event);
|
||||
break;
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
case ITEM_VIEW_OPTIONS_CUSTOM_SCRIPTS:
|
||||
g_eeGeneral.modelCustomScriptsDisabled = viewOptCheckBox(y, STR_MENUCUSTOMSCRIPTS, g_eeGeneral.modelCustomScriptsDisabled, attr, event);
|
||||
break;
|
||||
#endif
|
||||
case ITEM_VIEW_OPTIONS_TELEMETRY:
|
||||
g_eeGeneral.modelTelemetryDisabled = viewOptCheckBox(y, STR_MENUTELEMETRY, g_eeGeneral.modelTelemetryDisabled, attr, event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ void menuMainView(event_t event)
|
||||
break;
|
||||
|
||||
case EVT_KEY_LONG(KEY_MENU):
|
||||
pushMenu(menuTabGeneral[0]);
|
||||
pushMenu(menuTabGeneral[0].menuFunc);
|
||||
killEvents(event);
|
||||
break;
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int
|
||||
|
||||
// TRACE("editGVarFieldValue(val=%d min=%d max=%d)", value, min, max);
|
||||
|
||||
if (invers && event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
if (modelGVEnabled() && invers && event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
s_editMode = !s_editMode;
|
||||
if (attr & PREC1) {
|
||||
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode)*10 : delta);
|
||||
|
||||
@@ -29,9 +29,11 @@
|
||||
|
||||
void CurveParam::LongPressHandler(void* data)
|
||||
{
|
||||
int8_t* value = (int8_t*)data;
|
||||
if (*value != 0) {
|
||||
ModelCurvesPage::pushEditCurve(abs(*value) - 1);
|
||||
if (modelCurvesEnabled()) {
|
||||
int8_t* value = (int8_t*)data;
|
||||
if (*value != 0) {
|
||||
ModelCurvesPage::pushEditCurve(abs(*value) - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +55,7 @@ CurveParam::CurveParam(Window* parent, const rect_t& rect, CurveRef* ref,
|
||||
lv_obj_set_style_flex_cross_place(lvobj, LV_FLEX_ALIGN_CENTER, 0);
|
||||
lv_obj_set_size(lvobj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
|
||||
new Choice(this, rect_t{}, STR_VCURVETYPE, 0, CURVE_REF_CUSTOM,
|
||||
new Choice(this, rect_t{}, STR_VCURVETYPE, 0, modelCurvesEnabled() ? CURVE_REF_CUSTOM : CURVE_REF_FUNC,
|
||||
GET_DEFAULT(ref->type), [=](int32_t newValue) {
|
||||
ref->type = newValue;
|
||||
ref->value = 0;
|
||||
|
||||
@@ -73,12 +73,14 @@ GVarNumberEdit::GVarNumberEdit(Window* parent, const rect_t& rect, int32_t vmin,
|
||||
|
||||
#if defined(GVARS)
|
||||
// The GVAR button
|
||||
m_gvBtn = new TextButton(this, rect_t{}, STR_GV, [=]() {
|
||||
switchGVarMode();
|
||||
return GV_IS_GV_VALUE(getValue(), vmin, vmax);
|
||||
});
|
||||
m_gvBtn->check(GV_IS_GV_VALUE(getValue(), vmin, vmax));
|
||||
lv_obj_set_height(m_gvBtn->getLvObj(), lv_obj_get_height(gvar_field->getLvObj()));
|
||||
if (modelGVEnabled()) {
|
||||
m_gvBtn = new TextButton(this, rect_t{}, STR_GV, [=]() {
|
||||
switchGVarMode();
|
||||
return GV_IS_GV_VALUE(getValue(), vmin, vmax);
|
||||
});
|
||||
m_gvBtn->check(GV_IS_GV_VALUE(getValue(), vmin, vmax));
|
||||
lv_obj_set_height(m_gvBtn->getLvObj(), lv_obj_get_height(gvar_field->getLvObj()));
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_obj_add_event_cb(lvobj, GVarNumberEdit::value_changed,
|
||||
@@ -90,18 +92,20 @@ GVarNumberEdit::GVarNumberEdit(Window* parent, const rect_t& rect, int32_t vmin,
|
||||
|
||||
void GVarNumberEdit::switchGVarMode()
|
||||
{
|
||||
int32_t value = getValue();
|
||||
setValue(
|
||||
GV_IS_GV_VALUE(value, vmin, vmax)
|
||||
? ((textFlags & PREC1)
|
||||
? GET_GVAR_PREC1(value, vmin, vmax, mixerCurrentFlightMode)
|
||||
: GET_GVAR(value, vmin, vmax, mixerCurrentFlightMode))
|
||||
: GV_GET_GV1_VALUE(vmin, vmax));
|
||||
if (modelGVEnabled()) {
|
||||
int32_t value = getValue();
|
||||
setValue(
|
||||
GV_IS_GV_VALUE(value, vmin, vmax)
|
||||
? ((textFlags & PREC1)
|
||||
? GET_GVAR_PREC1(value, vmin, vmax, mixerCurrentFlightMode)
|
||||
: GET_GVAR(value, vmin, vmax, mixerCurrentFlightMode))
|
||||
: GV_GET_GV1_VALUE(vmin, vmax));
|
||||
|
||||
m_gvBtn->check(GV_IS_GV_VALUE(value, vmin, vmax));
|
||||
m_gvBtn->check(GV_IS_GV_VALUE(value, vmin, vmax));
|
||||
|
||||
// update field type based on value
|
||||
update();
|
||||
// update field type based on value
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void GVarNumberEdit::setSuffix(std::string value)
|
||||
|
||||
@@ -67,7 +67,9 @@ InputEditAdvanced::InputEditAdvanced(uint8_t input_n, uint8_t index) :
|
||||
});
|
||||
|
||||
// Flight modes
|
||||
line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_FLMODE, 0, COLOR_THEME_PRIMARY1);
|
||||
new FMMatrix<ExpoData>(line, rect_t{}, input);
|
||||
if (modelFMEnabled()) {
|
||||
line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_FLMODE, 0, COLOR_THEME_PRIMARY1);
|
||||
new FMMatrix<ExpoData>(line, rect_t{}, input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ void InputMixButton::setSource(mixsrc_t idx)
|
||||
|
||||
void InputMixButton::setFlightModes(uint16_t modes)
|
||||
{
|
||||
if (!modelFMEnabled()) return;
|
||||
if (modes == fm_modes) return;
|
||||
fm_modes = modes;
|
||||
|
||||
|
||||
@@ -40,32 +40,72 @@
|
||||
ModelMenu::ModelMenu():
|
||||
TabsGroup(ICON_MODEL)
|
||||
{
|
||||
build();
|
||||
}
|
||||
|
||||
void ModelMenu::build()
|
||||
{
|
||||
_modelHeliEnabled = modelHeliEnabled();
|
||||
_modelFMEnabled = modelFMEnabled();
|
||||
_modelCurvesEnabled = modelCurvesEnabled();
|
||||
_modelGVEnabled = modelGVEnabled();
|
||||
_modelLSEnabled = modelLSEnabled();
|
||||
_modelSFEnabled = modelSFEnabled();
|
||||
_modelCustomScriptsEnabled = modelCustomScriptsEnabled();
|
||||
_modelTelemetryEnabled = modelTelemetryEnabled();
|
||||
|
||||
addTab(new ModelSetupPage());
|
||||
#if defined(HELI)
|
||||
addTab(new ModelHeliPage());
|
||||
if (_modelHeliEnabled)
|
||||
addTab(new ModelHeliPage());
|
||||
#endif
|
||||
#if defined(FLIGHT_MODES)
|
||||
addTab(new ModelFlightModesPage());
|
||||
if (_modelFMEnabled)
|
||||
addTab(new ModelFlightModesPage());
|
||||
#endif
|
||||
addTab(new ModelInputsPage());
|
||||
addTab(new ModelMixesPage());
|
||||
addTab(new ModelOutputsPage());
|
||||
addTab(new ModelCurvesPage());
|
||||
if (_modelCurvesEnabled)
|
||||
addTab(new ModelCurvesPage());
|
||||
#if defined(GVARS)
|
||||
addTab(new ModelGVarsPage());
|
||||
if (_modelGVEnabled)
|
||||
addTab(new ModelGVarsPage());
|
||||
#endif
|
||||
addTab(new ModelLogicalSwitchesPage());
|
||||
addTab(new SpecialFunctionsPage(g_model.customFn));
|
||||
if (_modelLSEnabled)
|
||||
addTab(new ModelLogicalSwitchesPage());
|
||||
if (_modelSFEnabled)
|
||||
addTab(new SpecialFunctionsPage(g_model.customFn));
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
addTab(new ModelMixerScriptsPage());
|
||||
if (_modelCustomScriptsEnabled)
|
||||
addTab(new ModelMixerScriptsPage());
|
||||
#endif
|
||||
addTab(new ModelTelemetryPage());
|
||||
if (_modelTelemetryEnabled)
|
||||
addTab(new ModelTelemetryPage());
|
||||
|
||||
#if defined(PCBNV14) || defined(PCBPL18)
|
||||
addGoToMonitorsButton();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ModelMenu::checkEvents()
|
||||
{
|
||||
TabsGroup::checkEvents();
|
||||
|
||||
if (_modelHeliEnabled != modelHeliEnabled() ||
|
||||
_modelFMEnabled != modelFMEnabled() ||
|
||||
_modelCurvesEnabled != modelCurvesEnabled() ||
|
||||
_modelGVEnabled != modelGVEnabled() ||
|
||||
_modelLSEnabled != modelLSEnabled() ||
|
||||
_modelSFEnabled != modelSFEnabled() ||
|
||||
_modelCustomScriptsEnabled != modelCustomScriptsEnabled() ||
|
||||
_modelTelemetryEnabled != modelTelemetryEnabled()) {
|
||||
removeAllTabs();
|
||||
build();
|
||||
setCurrentTab(0);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelMenu::onEvent(event_t event)
|
||||
{
|
||||
#if defined(HARDWARE_KEYS)
|
||||
|
||||
@@ -26,19 +26,30 @@
|
||||
|
||||
class ModelMenu : public TabsGroup
|
||||
{
|
||||
public:
|
||||
ModelMenu();
|
||||
public:
|
||||
ModelMenu();
|
||||
|
||||
void onEvent(event_t event);
|
||||
void onEvent(event_t event) override;
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() const override { return "ModelMenu"; }
|
||||
std::string getName() const override { return "ModelMenu"; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
#if defined(PCBNV14) || defined(PCBPL18)
|
||||
protected:
|
||||
void addGoToMonitorsButton(void);
|
||||
void addGoToMonitorsButton(void);
|
||||
#endif
|
||||
bool _modelHeliEnabled = true;
|
||||
bool _modelFMEnabled = true;
|
||||
bool _modelCurvesEnabled = true;
|
||||
bool _modelGVEnabled = true;
|
||||
bool _modelLSEnabled = true;
|
||||
bool _modelSFEnabled = true;
|
||||
bool _modelCustomScriptsEnabled = true;
|
||||
bool _modelTelemetryEnabled = true;
|
||||
|
||||
void build();
|
||||
void checkEvents() override;
|
||||
};
|
||||
|
||||
#endif // _MENU_MODEL_H_
|
||||
|
||||
@@ -35,17 +35,44 @@
|
||||
RadioMenu::RadioMenu():
|
||||
TabsGroup(ICON_RADIO)
|
||||
{
|
||||
addTab(new RadioToolsPage());
|
||||
addTab(new RadioSdManagerPage());
|
||||
addTab(new RadioSetupPage());
|
||||
addTab(new ThemeSetupPage());
|
||||
addTab(new SpecialFunctionsPage(g_eeGeneral.customFn));
|
||||
addTab(new RadioTrainerPage());
|
||||
addTab(new RadioHardwarePage());
|
||||
addTab(new RadioVersionPage());
|
||||
build();
|
||||
}
|
||||
|
||||
RadioMenu::~RadioMenu()
|
||||
{
|
||||
storageCheck(true);
|
||||
storageCheck(true);
|
||||
}
|
||||
|
||||
void RadioMenu::build()
|
||||
{
|
||||
_radioThemesEnabled = radioThemesEnabled();
|
||||
_radioGFEnabled = radioGFEnabled();
|
||||
_radioTrainerEnabled = radioTrainerEnabled();
|
||||
|
||||
addTab(new RadioToolsPage());
|
||||
addTab(new RadioSdManagerPage());
|
||||
addTab(new RadioSetupPage());
|
||||
if (_radioThemesEnabled)
|
||||
addTab(new ThemeSetupPage());
|
||||
if (_radioGFEnabled)
|
||||
addTab(new SpecialFunctionsPage(g_eeGeneral.customFn));
|
||||
if (_radioTrainerEnabled)
|
||||
addTab(new RadioTrainerPage());
|
||||
addTab(new RadioHardwarePage());
|
||||
addTab(new RadioVersionPage());
|
||||
}
|
||||
|
||||
void RadioMenu::checkEvents()
|
||||
{
|
||||
TabsGroup::checkEvents();
|
||||
|
||||
if (_radioThemesEnabled != radioThemesEnabled() ||
|
||||
_radioGFEnabled != radioGFEnabled() ||
|
||||
_radioTrainerEnabled != radioTrainerEnabled()) {
|
||||
removeAllTabs();
|
||||
build();
|
||||
// Need to set current tab twice to work properly. TODO: can this be fixed?
|
||||
setCurrentTab(0);
|
||||
setCurrentTab(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,14 @@ class RadioMenu: public TabsGroup {
|
||||
public:
|
||||
RadioMenu();
|
||||
~RadioMenu();
|
||||
|
||||
protected:
|
||||
bool _radioThemesEnabled = true;
|
||||
bool _radioGFEnabled = true;
|
||||
bool _radioTrainerEnabled = true;
|
||||
|
||||
void build();
|
||||
void checkEvents() override;
|
||||
};
|
||||
|
||||
#endif // _MENU_RADIO_H_
|
||||
|
||||
@@ -68,9 +68,11 @@ void MixEditAdvanced::buildBody(FormWindow* form)
|
||||
new Choice(line, rect_t{}, STR_VMLTPX, 0, 2, GET_SET_DEFAULT(mix->mltpx));
|
||||
|
||||
// Flight modes
|
||||
line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_FLMODE, 0, COLOR_THEME_PRIMARY1);
|
||||
new FMMatrix<MixData>(line, rect_t{}, mix);
|
||||
if (modelFMEnabled()) {
|
||||
line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_FLMODE, 0, COLOR_THEME_PRIMARY1);
|
||||
new FMMatrix<MixData>(line, rect_t{}, mix);
|
||||
}
|
||||
|
||||
// Trim
|
||||
line = form->newLine(&grid);
|
||||
|
||||
@@ -63,7 +63,8 @@ class GVarStyle
|
||||
lv_style_set_bg_color(&fmContStyleChecked, makeLvColor(COLOR_THEME_SECONDARY3));
|
||||
|
||||
lv_style_init(&fmLabelStyle);
|
||||
lv_style_set_height(&fmLabelStyle, PAGE_LINE_HEIGHT - 6);
|
||||
if (modelFMEnabled())
|
||||
lv_style_set_height(&fmLabelStyle, PAGE_LINE_HEIGHT - 6);
|
||||
lv_style_set_width(&fmLabelStyle, GVAR_VAL_W);
|
||||
lv_style_set_text_font(&fmLabelStyle, getFont(FONT(XS)));
|
||||
lv_style_set_text_color(&fmLabelStyle, makeLvColor(COLOR_THEME_SECONDARY1));
|
||||
@@ -81,7 +82,7 @@ class GVarStyle
|
||||
lv_style_set_pad_top(&fmValueStyleSmall, 3);
|
||||
|
||||
lv_style_init(&fmNameStyle);
|
||||
lv_style_set_width(&fmNameStyle, GVAR_NAME_SIZE);
|
||||
lv_style_set_width(&fmNameStyle, modelFMEnabled() ? GVAR_NAME_SIZE : GVAR_NAME_SIZE * 2);
|
||||
lv_style_set_text_font(&fmNameStyle, getFont(FONT(STD)));
|
||||
lv_style_set_text_color(&fmNameStyle, makeLvColor(COLOR_THEME_SECONDARY1));
|
||||
lv_style_set_text_align(&fmNameStyle, LV_TEXT_ALIGN_LEFT);
|
||||
@@ -136,7 +137,9 @@ class GVarButton : public Button
|
||||
setHeight(BTN_H);
|
||||
lv_obj_set_flex_flow(lvobj, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_style_pad_all(lvobj, 0, LV_PART_MAIN);
|
||||
lv_obj_set_flex_align(lvobj, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND);
|
||||
lv_obj_set_flex_align(lvobj, modelFMEnabled() ? LV_FLEX_ALIGN_CENTER : LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND);
|
||||
if (!modelFMEnabled())
|
||||
padLeft(8);
|
||||
|
||||
lv_obj_add_event_cb(lvobj, GVarButton::on_draw,
|
||||
LV_EVENT_DRAW_MAIN_BEGIN, nullptr);
|
||||
@@ -156,18 +159,30 @@ class GVarButton : public Button
|
||||
}
|
||||
|
||||
protected:
|
||||
bool init = false;
|
||||
uint8_t gvarIdx;
|
||||
uint8_t currentFlightMode = 0; // used for invalidation
|
||||
lv_obj_t* fmCont[MAX_FLIGHT_MODES];
|
||||
lv_obj_t* valueTexts[MAX_FLIGHT_MODES];
|
||||
gvar_t values[MAX_FLIGHT_MODES];
|
||||
|
||||
int numFlightModes() { return modelFMEnabled() ? MAX_FLIGHT_MODES : 1; }
|
||||
|
||||
void checkEvents()
|
||||
{
|
||||
Button::checkEvents();
|
||||
if (init) {
|
||||
uint8_t newFM = getFlightMode();
|
||||
if (currentFlightMode != newFM) {
|
||||
lv_obj_add_state(fmCont[newFM], LV_STATE_CHECKED);
|
||||
lv_obj_clear_state(fmCont[currentFlightMode], LV_STATE_CHECKED);
|
||||
if (modelFMEnabled()) {
|
||||
uint8_t newFM = getFlightMode();
|
||||
if (currentFlightMode != newFM) {
|
||||
lv_obj_add_state(fmCont[newFM], LV_STATE_CHECKED);
|
||||
lv_obj_clear_state(fmCont[currentFlightMode], LV_STATE_CHECKED);
|
||||
|
||||
currentFlightMode = newFM;
|
||||
currentFlightMode = newFM;
|
||||
}
|
||||
}
|
||||
for (int flightMode = 0; flightMode < MAX_FLIGHT_MODES; flightMode++) {
|
||||
|
||||
for (int flightMode = 0; flightMode < numFlightModes(); flightMode++) {
|
||||
FlightModeData* fmData = &g_model.flightModeData[flightMode];
|
||||
if (values[flightMode] != fmData->gvars[gvarIdx]) {
|
||||
updateValueText(flightMode);
|
||||
@@ -176,14 +191,6 @@ class GVarButton : public Button
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
bool init = false;
|
||||
uint8_t gvarIdx;
|
||||
uint8_t currentFlightMode = 0; // used for invalidation
|
||||
lv_obj_t* fmCont[MAX_FLIGHT_MODES];
|
||||
lv_obj_t* valueTexts[MAX_FLIGHT_MODES];
|
||||
gvar_t values[MAX_FLIGHT_MODES];
|
||||
|
||||
void build()
|
||||
{
|
||||
if (init) return;
|
||||
@@ -196,35 +203,42 @@ class GVarButton : public Button
|
||||
gvarStyle.setNameStyle(lbl);
|
||||
lv_label_set_text(lbl, getGVarString(gvarIdx));
|
||||
|
||||
lv_obj_t* container = lv_obj_create(lvobj);
|
||||
lv_obj_set_width(container, GVAR_VAL_W * GVAR_COLS);
|
||||
lv_obj_set_height(container, GVAR_H);
|
||||
lv_obj_set_style_pad_all(container, 0, LV_PART_MAIN);
|
||||
lv_obj_add_flag(container, LV_OBJ_FLAG_EVENT_BUBBLE);
|
||||
if (modelFMEnabled()) {
|
||||
lv_obj_t* container = lv_obj_create(lvobj);
|
||||
lv_obj_set_width(container, GVAR_VAL_W * GVAR_COLS);
|
||||
lv_obj_set_height(container, GVAR_H);
|
||||
lv_obj_set_style_pad_all(container, 0, LV_PART_MAIN);
|
||||
lv_obj_add_flag(container, LV_OBJ_FLAG_EVENT_BUBBLE);
|
||||
|
||||
for (int flightMode = 0; flightMode < MAX_FLIGHT_MODES; flightMode++) {
|
||||
fmCont[flightMode] = lv_obj_create(container);
|
||||
gvarStyle.setContStyle(fmCont[flightMode]);
|
||||
lv_obj_set_pos(fmCont[flightMode], (flightMode%GVAR_COLS)*GVAR_VAL_W, (flightMode/GVAR_COLS)*GVAR_VAL_H);
|
||||
lv_obj_set_user_data(fmCont[flightMode], this);
|
||||
lv_obj_add_flag(fmCont[flightMode], LV_OBJ_FLAG_EVENT_BUBBLE);
|
||||
if (flightMode == currentFlightMode) {
|
||||
lv_obj_add_state(fmCont[flightMode], LV_STATE_CHECKED);
|
||||
for (int flightMode = 0; flightMode < numFlightModes(); flightMode++) {
|
||||
fmCont[flightMode] = lv_obj_create(container);
|
||||
gvarStyle.setContStyle(fmCont[flightMode]);
|
||||
lv_obj_set_pos(fmCont[flightMode], (flightMode%GVAR_COLS)*GVAR_VAL_W, (flightMode/GVAR_COLS)*GVAR_VAL_H);
|
||||
lv_obj_set_user_data(fmCont[flightMode], this);
|
||||
lv_obj_add_flag(fmCont[flightMode], LV_OBJ_FLAG_EVENT_BUBBLE);
|
||||
if (flightMode == currentFlightMode) {
|
||||
lv_obj_add_state(fmCont[flightMode], LV_STATE_CHECKED);
|
||||
}
|
||||
|
||||
char label[16] = {};
|
||||
getFlightModeString(label, flightMode + 1);
|
||||
|
||||
lbl = lv_label_create(fmCont[flightMode]);
|
||||
gvarStyle.setLabelStyle(lbl);
|
||||
lv_label_set_text(lbl, label);
|
||||
lv_obj_set_pos(lbl, 0, 0);
|
||||
|
||||
valueTexts[flightMode] = lv_label_create(fmCont[flightMode]);
|
||||
gvarStyle.setValueStyle(valueTexts[flightMode]);
|
||||
lv_obj_set_pos(valueTexts[flightMode], 0, PAGE_LINE_HEIGHT - 6);
|
||||
|
||||
updateValueText(flightMode);
|
||||
}
|
||||
} else {
|
||||
valueTexts[0] = lv_label_create(lvobj);
|
||||
gvarStyle.setValueStyle(valueTexts[0]);
|
||||
|
||||
char label[16] = {};
|
||||
getFlightModeString(label, flightMode + 1);
|
||||
|
||||
lbl = lv_label_create(fmCont[flightMode]);
|
||||
gvarStyle.setLabelStyle(lbl);
|
||||
lv_label_set_text(lbl, label);
|
||||
lv_obj_set_pos(lbl, 0, 0);
|
||||
|
||||
valueTexts[flightMode] = lv_label_create(fmCont[flightMode]);
|
||||
gvarStyle.setValueStyle(valueTexts[flightMode]);
|
||||
lv_obj_set_pos(valueTexts[flightMode], 0, PAGE_LINE_HEIGHT - 6);
|
||||
|
||||
updateValueText(flightMode);
|
||||
updateValueText(0);
|
||||
}
|
||||
|
||||
lv_obj_enable_style_refresh(true);
|
||||
@@ -287,6 +301,8 @@ class GVarEditWindow : public Page
|
||||
NumberEdit* values[MAX_FLIGHT_MODES] = {};
|
||||
StaticText* gVarInHeader = nullptr;
|
||||
|
||||
int numFlightModes() { return modelFMEnabled() ? MAX_FLIGHT_MODES : 1; }
|
||||
|
||||
void buildHeader(Window* window)
|
||||
{
|
||||
header.setTitle(STR_MENU_GLOBAL_VARS);
|
||||
@@ -317,8 +333,12 @@ class GVarEditWindow : public Page
|
||||
strcat(label, getGVarValue(index, lastGVar, 0).c_str());
|
||||
}
|
||||
gVarInHeader->setText(label);
|
||||
for (auto& value : values) {
|
||||
value->invalidate();
|
||||
if (modelFMEnabled()) {
|
||||
for (auto& value : values) {
|
||||
value->invalidate();
|
||||
}
|
||||
} else {
|
||||
values[0]->invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -353,7 +373,7 @@ class GVarEditWindow : public Page
|
||||
max->update();
|
||||
}
|
||||
FlightModeData* fmData;
|
||||
for (int fm = 0; fm < MAX_FLIGHT_MODES; fm++) {
|
||||
for (int fm = 0; fm < numFlightModes(); fm++) {
|
||||
if (values[fm] == nullptr) // KLK: the order of calls has changed and
|
||||
// this might not be initialized yet.
|
||||
continue;
|
||||
@@ -409,38 +429,31 @@ class GVarEditWindow : public Page
|
||||
|
||||
new StaticText(line, rect_t{}, STR_NAME, 0, COLOR_THEME_PRIMARY1);
|
||||
grid.nextCell();
|
||||
Window* input =
|
||||
new ModelTextEdit(line, rect_t{}, gvar->name, LEN_GVAR_NAME);
|
||||
lv_obj_set_style_grid_cell_x_align(input->getLvObj(), LV_GRID_ALIGN_STRETCH,
|
||||
0);
|
||||
new ModelTextEdit(line, rect_t{}, gvar->name, LEN_GVAR_NAME);
|
||||
|
||||
line = window->newLine(&grid);
|
||||
|
||||
new StaticText(line, rect_t{}, STR_UNIT, 0, COLOR_THEME_PRIMARY1);
|
||||
grid.nextCell();
|
||||
input = new Choice(line, rect_t{}, "\001-%", 0, 1, GET_DEFAULT(gvar->unit),
|
||||
[=](int16_t newValue) {
|
||||
refreshTitle = (gvar->unit != newValue);
|
||||
gvar->unit = newValue;
|
||||
SET_DIRTY();
|
||||
setProperties();
|
||||
});
|
||||
lv_obj_set_style_grid_cell_x_align(input->getLvObj(), LV_GRID_ALIGN_STRETCH,
|
||||
0);
|
||||
new Choice(line, rect_t{}, "\001-%", 0, 1, GET_DEFAULT(gvar->unit),
|
||||
[=](int16_t newValue) {
|
||||
refreshTitle = (gvar->unit != newValue);
|
||||
gvar->unit = newValue;
|
||||
SET_DIRTY();
|
||||
setProperties();
|
||||
});
|
||||
|
||||
line = window->newLine(&grid);
|
||||
|
||||
new StaticText(line, rect_t{}, STR_PRECISION, 0, COLOR_THEME_PRIMARY1);
|
||||
grid.nextCell();
|
||||
input = new Choice(line, rect_t{}, STR_VPREC, 0, 1, GET_DEFAULT(gvar->prec),
|
||||
[=](int16_t newValue) {
|
||||
refreshTitle = (gvar->prec != newValue);
|
||||
gvar->prec = newValue;
|
||||
SET_DIRTY();
|
||||
setProperties();
|
||||
});
|
||||
lv_obj_set_style_grid_cell_x_align(input->getLvObj(), LV_GRID_ALIGN_STRETCH,
|
||||
0);
|
||||
new Choice(line, rect_t{}, STR_VPREC, 0, 1, GET_DEFAULT(gvar->prec),
|
||||
[=](int16_t newValue) {
|
||||
refreshTitle = (gvar->prec != newValue);
|
||||
gvar->prec = newValue;
|
||||
SET_DIRTY();
|
||||
setProperties();
|
||||
});
|
||||
|
||||
line = window->newLine(&grid);
|
||||
|
||||
@@ -455,8 +468,6 @@ class GVarEditWindow : public Page
|
||||
setProperties();
|
||||
});
|
||||
min->setAccelFactor(16);
|
||||
lv_obj_set_style_grid_cell_x_align(min->getLvObj(), LV_GRID_ALIGN_STRETCH,
|
||||
0);
|
||||
|
||||
line = window->newLine(&grid);
|
||||
|
||||
@@ -471,23 +482,27 @@ class GVarEditWindow : public Page
|
||||
setProperties();
|
||||
});
|
||||
max->setAccelFactor(16);
|
||||
lv_obj_set_style_grid_cell_x_align(max->getLvObj(), LV_GRID_ALIGN_STRETCH,
|
||||
0);
|
||||
|
||||
line = window->newLine(&grid);
|
||||
char flightModeName[16];
|
||||
FlightModeData* fmData;
|
||||
|
||||
for (int flightMode = 0; flightMode < MAX_FLIGHT_MODES; flightMode++) {
|
||||
for (int flightMode = 0; flightMode < numFlightModes(); flightMode++) {
|
||||
fmData = &g_model.flightModeData[flightMode];
|
||||
getFlightModeString(flightModeName, flightMode + 1);
|
||||
|
||||
int userNameLen = zlen(fmData->name, LEN_FLIGHT_MODE_NAME);
|
||||
if (modelFMEnabled()) {
|
||||
getFlightModeString(flightModeName, flightMode + 1);
|
||||
|
||||
if (userNameLen > 0) {
|
||||
strcpy(flightModeName, fmData->name);
|
||||
int userNameLen = zlen(fmData->name, LEN_FLIGHT_MODE_NAME);
|
||||
|
||||
if (userNameLen > 0) {
|
||||
strcpy(flightModeName, fmData->name);
|
||||
}
|
||||
new StaticText(line, rect_t{}, flightModeName, 0, COLOR_THEME_PRIMARY1);
|
||||
} else {
|
||||
new StaticText(line, rect_t{}, STR_VALUE, 0, COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
new StaticText(line, rect_t{}, flightModeName, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
if (flightMode > 0) {
|
||||
auto cb = new CheckBox(
|
||||
line, rect_t{}, [=] { return fmData->gvars[index] <= GVAR_MAX; },
|
||||
|
||||
@@ -225,6 +225,132 @@ static const lv_coord_t line_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1),
|
||||
static const lv_coord_t line_row_dsc[] = {LV_GRID_CONTENT,
|
||||
LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
class ModelViewOptions : public Page
|
||||
{
|
||||
public:
|
||||
class OptChoice : FormWindow
|
||||
{
|
||||
public:
|
||||
OptChoice(Window* parent, const char *const values[], int vmin, int vmax,
|
||||
std::function<int()> _getValue,
|
||||
std::function<void(int)> _setValue,
|
||||
bool globalState) :
|
||||
FormWindow(parent, rect_t{}),
|
||||
m_getValue(std::move(_getValue)),
|
||||
m_setValue(std::move(_setValue))
|
||||
{
|
||||
setFlexLayout(LV_FLEX_FLOW_ROW, 4);
|
||||
lv_obj_set_flex_align(lvobj, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND);
|
||||
|
||||
new Choice(this, rect_t{}, values, vmin, vmax,
|
||||
m_getValue,
|
||||
[=](int newValue) {
|
||||
m_setValue(newValue);
|
||||
setState();
|
||||
});
|
||||
m_lbl = new StaticText(this, rect_t{}, STR_ADCFILTERVALUES[globalState ? 1: 2], 0, COLOR_THEME_SECONDARY1);
|
||||
setState();
|
||||
}
|
||||
|
||||
protected:
|
||||
StaticText* m_lbl;
|
||||
std::function<int()> m_getValue;
|
||||
std::function<void(int)> m_setValue;
|
||||
|
||||
void setState()
|
||||
{
|
||||
if (m_getValue() == 0) {
|
||||
lv_obj_clear_flag(m_lbl->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_add_flag(m_lbl->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ModelViewOptions() : Page(ICON_MODEL_SETUP)
|
||||
{
|
||||
header.setTitle(STR_MENU_MODEL_SETUP);
|
||||
header.setTitle2(STR_VIEW_OPTIONS);
|
||||
|
||||
body.padAll(8);
|
||||
|
||||
auto form = new FormWindow(&body, rect_t{});
|
||||
form->setFlexLayout();
|
||||
form->padAll(4);
|
||||
|
||||
FlexGridLayout grid(line_col_dsc, line_row_dsc, 2);
|
||||
|
||||
auto line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_RADIO_MENU_TABS, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_THEME_EDITOR, 0, COLOR_THEME_PRIMARY1);
|
||||
new OptChoice(line, STR_ADCFILTERVALUES, 0, 2, GET_SET_DEFAULT(g_model.radioThemesDisabled), g_eeGeneral.radioThemesDisabled);
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUSPECIALFUNCS, 0, COLOR_THEME_PRIMARY1);
|
||||
new OptChoice(line, STR_ADCFILTERVALUES, 0, 2, GET_SET_DEFAULT(g_model.radioGFDisabled), g_eeGeneral.radioGFDisabled);
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUTRAINER, 0, COLOR_THEME_PRIMARY1);
|
||||
new OptChoice(line, STR_ADCFILTERVALUES, 0, 2, GET_SET_DEFAULT(g_model.radioTrainerDisabled), g_eeGeneral.radioTrainerDisabled);
|
||||
|
||||
line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_MODEL_MENU_TABS, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
#if defined(HELI)
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUHELISETUP, 0, COLOR_THEME_PRIMARY1);
|
||||
new OptChoice(line, STR_ADCFILTERVALUES, 0, 2, GET_SET_DEFAULT(g_model.modelHeliDisabled), g_eeGeneral.modelHeliDisabled);
|
||||
#endif
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUFLIGHTMODES, 0, COLOR_THEME_PRIMARY1);
|
||||
new OptChoice(line, STR_ADCFILTERVALUES, 0, 2, GET_SET_DEFAULT(g_model.modelFMDisabled), g_eeGeneral.modelFMDisabled);
|
||||
#endif
|
||||
|
||||
#if defined(GVARS)
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENU_GLOBAL_VARS, 0, COLOR_THEME_PRIMARY1);
|
||||
new OptChoice(line, STR_ADCFILTERVALUES, 0, 2, GET_SET_DEFAULT(g_model.modelGVDisabled), g_eeGeneral.modelGVDisabled);
|
||||
#endif
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUCURVES, 0, COLOR_THEME_PRIMARY1);
|
||||
new OptChoice(line, STR_ADCFILTERVALUES, 0, 2, GET_SET_DEFAULT(g_model.modelCurvesDisabled), g_eeGeneral.modelCurvesDisabled);
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENULOGICALSWITCHES, 0, COLOR_THEME_PRIMARY1);
|
||||
new OptChoice(line, STR_ADCFILTERVALUES, 0, 2, GET_SET_DEFAULT(g_model.modelLSDisabled), g_eeGeneral.modelLSDisabled);
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUCUSTOMFUNC, 0, COLOR_THEME_PRIMARY1);
|
||||
new OptChoice(line, STR_ADCFILTERVALUES, 0, 2, GET_SET_DEFAULT(g_model.modelSFDisabled), g_eeGeneral.modelSFDisabled);
|
||||
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUCUSTOMSCRIPTS, 0, COLOR_THEME_PRIMARY1);
|
||||
new OptChoice(line, STR_ADCFILTERVALUES, 0, 2, GET_SET_DEFAULT(g_model.modelCustomScriptsDisabled), g_eeGeneral.modelCustomScriptsDisabled);
|
||||
#endif
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUTELEMETRY, 0, COLOR_THEME_PRIMARY1);
|
||||
new OptChoice(line, STR_ADCFILTERVALUES, 0, 2, GET_SET_DEFAULT(g_model.modelTelemetryDisabled), g_eeGeneral.modelTelemetryDisabled);
|
||||
}
|
||||
};
|
||||
|
||||
void ModelSetupPage::build(FormWindow * window)
|
||||
{
|
||||
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 0);
|
||||
@@ -269,11 +395,6 @@ void ModelSetupPage::build(FormWindow * window)
|
||||
// TODO: show bitmap thumbnail instead?
|
||||
new ModelBitmapEdit(line, rect_t{});
|
||||
|
||||
// Global functions
|
||||
line = window->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_USE_GLOBAL_FUNCS, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_model.noGlobalFunctions));
|
||||
|
||||
// Model ADC jitter filter
|
||||
line = window->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_JITTER_FILTER, 0, COLOR_THEME_PRIMARY1);
|
||||
@@ -328,12 +449,15 @@ void ModelSetupPage::build(FormWindow * window)
|
||||
btn = new SubScreenButton(form, STR_THROTTLE_LABEL, []() { new ThrottleParams(); });
|
||||
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 2, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
|
||||
#if defined(USBJ_EX)
|
||||
form = new FormGroup(oform, rect_t{});
|
||||
form->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(PAGE_PADDING));
|
||||
lv_obj_set_grid_dsc_array(form->getLvObj(), col_dsc, row_dsc);
|
||||
|
||||
btn = new SubScreenButton(form, STR_USBJOYSTICK_LABEL, []() { new ModelUSBJoystickPage(); });
|
||||
btn = new SubScreenButton(form, STR_VIEW_OPTIONS, []() { new ModelViewOptions(); });
|
||||
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
|
||||
#if defined(USBJ_EX)
|
||||
btn = new SubScreenButton(form, STR_USBJOYSTICK_LABEL, []() { new ModelUSBJoystickPage(); });
|
||||
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -224,6 +224,7 @@ class WindowButtonGroup : public FormGroup
|
||||
setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8));
|
||||
lv_obj_set_style_flex_main_place(lvobj, LV_FLEX_ALIGN_SPACE_EVENLY, 0);
|
||||
padRow(lv_dpx(8));
|
||||
padBottom(4);
|
||||
|
||||
for (auto& entry : pages) {
|
||||
auto btn = new TextButton(this, rect_t{}, entry.first, [&, entry]() {
|
||||
@@ -243,7 +244,8 @@ class SubPage : public Page
|
||||
public:
|
||||
SubPage(MenuIcons icon, const char* title) : Page(icon)
|
||||
{
|
||||
header.setTitle(title);
|
||||
header.setTitle(STR_RADIO_SETUP);
|
||||
header.setTitle2(title);
|
||||
|
||||
body.setFlexLayout();
|
||||
body.padAll(8);
|
||||
@@ -254,10 +256,7 @@ class SoundPage : public SubPage {
|
||||
public:
|
||||
SoundPage() : SubPage(ICON_RADIO_SETUP, STR_SOUND_LABEL)
|
||||
{
|
||||
header.setTitle(STR_RADIO_SETUP);
|
||||
header.setTitle2(STR_SOUND_LABEL);
|
||||
|
||||
FlexGridLayout grid(col_two_dsc, row_dsc, 3);
|
||||
FlexGridLayout grid(col_two_dsc, row_dsc, 2);
|
||||
|
||||
auto line = body.newLine(&grid);
|
||||
|
||||
@@ -311,9 +310,6 @@ class VarioPage : public SubPage {
|
||||
public:
|
||||
VarioPage() : SubPage(ICON_RADIO_SETUP, STR_VARIO)
|
||||
{
|
||||
header.setTitle(STR_RADIO_SETUP);
|
||||
header.setTitle2(STR_VARIO);
|
||||
|
||||
FlexGridLayout grid(col_two_dsc, row_dsc, 4);
|
||||
|
||||
auto line = body.newLine(&grid);
|
||||
@@ -355,9 +351,6 @@ class HapticPage : public SubPage {
|
||||
public:
|
||||
HapticPage() : SubPage(ICON_RADIO_SETUP, STR_HAPTIC_LABEL)
|
||||
{
|
||||
header.setTitle(STR_RADIO_SETUP);
|
||||
header.setTitle2(STR_HAPTIC_LABEL);
|
||||
|
||||
FlexGridLayout grid(col_two_dsc, row_dsc, 4);
|
||||
|
||||
auto line = body.newLine(&grid);
|
||||
@@ -384,9 +377,6 @@ class AlarmsPage : public SubPage {
|
||||
public:
|
||||
AlarmsPage() : SubPage(ICON_RADIO_SETUP, STR_ALARMS_LABEL)
|
||||
{
|
||||
header.setTitle(STR_RADIO_SETUP);
|
||||
header.setTitle2(STR_ALARMS_LABEL);
|
||||
|
||||
FlexGridLayout grid(col_two_dsc, row_dsc, 4);
|
||||
|
||||
auto line = body.newLine(&grid);
|
||||
@@ -445,9 +435,6 @@ class BacklightPage : public SubPage {
|
||||
public:
|
||||
BacklightPage() : SubPage(ICON_RADIO_SETUP, STR_BACKLIGHT_LABEL)
|
||||
{
|
||||
header.setTitle(STR_RADIO_SETUP);
|
||||
header.setTitle2(STR_BACKLIGHT_LABEL);
|
||||
|
||||
FlexGridLayout grid(col_two_dsc, row_dsc, 4);
|
||||
|
||||
auto line = body.newLine(&grid);
|
||||
@@ -565,9 +552,6 @@ class GpsPage : public SubPage {
|
||||
public:
|
||||
GpsPage() : SubPage(ICON_RADIO_SETUP, STR_GPS)
|
||||
{
|
||||
header.setTitle(STR_RADIO_SETUP);
|
||||
header.setTitle2(STR_GPS);
|
||||
|
||||
FlexGridLayout grid(col_two_dsc, row_dsc, 4);
|
||||
|
||||
auto line = body.newLine(&grid);
|
||||
@@ -588,6 +572,95 @@ class GpsPage : public SubPage {
|
||||
}
|
||||
};
|
||||
|
||||
class ViewOptionsPage : public Page
|
||||
{
|
||||
public:
|
||||
const lv_coord_t opt_col_two_dsc[3] = {LV_GRID_FR(7), LV_GRID_FR(3), LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
ViewOptionsPage() : Page(ICON_RADIO_SETUP)
|
||||
{
|
||||
header.setTitle(STR_RADIO_SETUP);
|
||||
header.setTitle2(STR_VIEW_OPTIONS);
|
||||
|
||||
body.padAll(8);
|
||||
|
||||
FlexGridLayout grid(opt_col_two_dsc, row_dsc, 2);
|
||||
|
||||
auto form = new FormWindow(&body, rect_t{});
|
||||
form->setFlexLayout();
|
||||
form->padAll(0);
|
||||
|
||||
auto line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_RADIO_MENU_TABS, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_THEME_EDITOR, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.radioThemesDisabled));
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUSPECIALFUNCS, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.radioGFDisabled));
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUTRAINER, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.radioTrainerDisabled));
|
||||
|
||||
line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_MODEL_MENU_TABS, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
#if defined(HELI)
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUHELISETUP, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.modelHeliDisabled));
|
||||
#endif
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUFLIGHTMODES, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.modelFMDisabled));
|
||||
#endif
|
||||
|
||||
#if defined(GVARS)
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENU_GLOBAL_VARS, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.modelGVDisabled));
|
||||
#endif
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUCURVES, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.modelCurvesDisabled));
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENULOGICALSWITCHES, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.modelLSDisabled));
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUCUSTOMFUNC, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.modelSFDisabled));
|
||||
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUCUSTOMSCRIPTS, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.modelCustomScriptsDisabled));
|
||||
#endif
|
||||
|
||||
line = form->newLine(&grid);
|
||||
line->padLeft(10);
|
||||
new StaticText(line, rect_t{}, STR_MENUTELEMETRY, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.modelTelemetryDisabled));
|
||||
}
|
||||
};
|
||||
|
||||
RadioSetupPage::RadioSetupPage():
|
||||
PageTab(STR_RADIO_SETUP, ICON_RADIO_SETUP)
|
||||
{
|
||||
@@ -613,9 +686,9 @@ void RadioSetupPage::build(FormWindow * window)
|
||||
{STR_ALARMS_LABEL, []() { new AlarmsPage(); }},
|
||||
{STR_BACKLIGHT_LABEL, []() { new BacklightPage(); }},
|
||||
{STR_GPS, [](){new GpsPage();}},
|
||||
{STR_VIEW_OPTIONS, [](){new ViewOptionsPage();}},
|
||||
});
|
||||
|
||||
|
||||
#if defined(PWR_BUTTON_PRESS)
|
||||
// Pwr Off Delay
|
||||
{
|
||||
|
||||
@@ -37,22 +37,26 @@ class SourceChoiceMenuToolbar : public MenuToolbar
|
||||
{
|
||||
addButton(STR_CHAR_INPUT, MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT);
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
addButton(STR_CHAR_LUA, MIXSRC_FIRST_LUA, MIXSRC_LAST_LUA);
|
||||
if (modelCustomScriptsEnabled())
|
||||
addButton(STR_CHAR_LUA, MIXSRC_FIRST_LUA, MIXSRC_LAST_LUA);
|
||||
#endif
|
||||
addButton(STR_CHAR_STICK, MIXSRC_FIRST_STICK, MIXSRC_LAST_STICK);
|
||||
addButton(STR_CHAR_POT, MIXSRC_FIRST_POT, MIXSRC_LAST_POT);
|
||||
addButton(STR_CHAR_FUNCTION, MIXSRC_MAX, MIXSRC_MAX);
|
||||
#if defined(HELI)
|
||||
addButton(STR_CHAR_CYC, MIXSRC_FIRST_HELI, MIXSRC_LAST_HELI);
|
||||
if (modelHeliEnabled())
|
||||
addButton(STR_CHAR_CYC, MIXSRC_FIRST_HELI, MIXSRC_LAST_HELI);
|
||||
#endif
|
||||
addButton(STR_CHAR_TRIM, MIXSRC_FIRST_TRIM, MIXSRC_LAST_TRIM);
|
||||
addButton(STR_CHAR_SWITCH, MIXSRC_FIRST_SWITCH, MIXSRC_LAST_SWITCH);
|
||||
addButton(STR_CHAR_TRAINER, MIXSRC_FIRST_TRAINER, MIXSRC_LAST_TRAINER);
|
||||
addButton(STR_CHAR_CHANNEL, MIXSRC_FIRST_CH, MIXSRC_LAST_CH);
|
||||
#if defined(GVARS)
|
||||
addButton(STR_CHAR_SLIDER, MIXSRC_LAST_GVAR, MIXSRC_FIRST_GVAR);
|
||||
if (modelGVEnabled())
|
||||
addButton(STR_CHAR_SLIDER, MIXSRC_LAST_GVAR, MIXSRC_FIRST_GVAR);
|
||||
#endif
|
||||
addButton(STR_CHAR_TELEMETRY, MIXSRC_FIRST_TELEM, MIXSRC_LAST_TELEM);
|
||||
if (modelTelemetryEnabled())
|
||||
addButton(STR_CHAR_TELEMETRY, MIXSRC_FIRST_TELEM, MIXSRC_LAST_TELEM);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -28,6 +28,19 @@ typedef int8_t horzpos_t;
|
||||
typedef uint16_t vertpos_t;
|
||||
|
||||
typedef void (* MenuHandlerFunc)(event_t event);
|
||||
typedef bool (* MenuEnabledFunc)();
|
||||
|
||||
typedef struct _MenuHandler {
|
||||
MenuHandlerFunc menuFunc;
|
||||
MenuEnabledFunc enabledFunc;
|
||||
|
||||
bool isEnabled() const
|
||||
{
|
||||
if (enabledFunc)
|
||||
return enabledFunc();
|
||||
return true;
|
||||
}
|
||||
} MenuHandler;
|
||||
|
||||
extern tmr10ms_t menuEntryTime;
|
||||
extern vertpos_t menuVerticalPosition;
|
||||
|
||||
@@ -128,7 +128,7 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlag
|
||||
lcdDrawTextAtIndex(x1, y, STR_VCURVETYPE, curve.type, flags1);
|
||||
|
||||
if (active && menuHorizontalPosition==0) {
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, curve.type, CURVE_REF_CUSTOM);
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, curve.type, modelCurvesEnabled() ? CURVE_REF_CUSTOM : CURVE_REF_FUNC);
|
||||
if (checkIncDec_Ret) curve.value = 0;
|
||||
}
|
||||
switch (curve.type) {
|
||||
|
||||
@@ -182,8 +182,12 @@ bool isSourceAvailable(int source)
|
||||
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
if (source >= MIXSRC_FIRST_LUA && source <= MIXSRC_LAST_LUA) {
|
||||
div_t qr = div(source - MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
|
||||
return (qr.rem<scriptInputsOutputs[qr.quot].outputsCount);
|
||||
if (modelCustomScriptsEnabled()) {
|
||||
div_t qr = div(source - MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
|
||||
return (qr.rem<scriptInputsOutputs[qr.quot].outputsCount);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#elif defined(LUA_INPUTS)
|
||||
if (source >= MIXSRC_FIRST_LUA && source <= MIXSRC_LAST_LUA)
|
||||
@@ -215,6 +219,9 @@ bool isSourceAvailable(int source)
|
||||
#if !defined(HELI)
|
||||
if (source >= MIXSRC_CYC1 && source <= MIXSRC_CYC3)
|
||||
return false;
|
||||
#else
|
||||
if (!modelHeliEnabled() && source >= MIXSRC_CYC1 && source <= MIXSRC_CYC3)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if (source >= MIXSRC_FIRST_CH && source <= MIXSRC_LAST_CH) {
|
||||
@@ -229,6 +236,9 @@ bool isSourceAvailable(int source)
|
||||
#if !defined(GVARS)
|
||||
if (source >= MIXSRC_GVAR1 && source <= MIXSRC_LAST_GVAR)
|
||||
return false;
|
||||
#else
|
||||
if (!modelGVEnabled() && source >= MIXSRC_GVAR1 && source <= MIXSRC_LAST_GVAR)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if (source >= MIXSRC_FIRST_RESERVE && source <= MIXSRC_LAST_RESERVE)
|
||||
@@ -238,6 +248,8 @@ bool isSourceAvailable(int source)
|
||||
return g_model.trainerData.mode > 0;
|
||||
|
||||
if (source >= MIXSRC_FIRST_TELEM && source <= MIXSRC_LAST_TELEM) {
|
||||
if (!modelTelemetryEnabled())
|
||||
return false;
|
||||
div_t qr = div(source - MIXSRC_FIRST_TELEM, 3);
|
||||
if (qr.rem == 0)
|
||||
return isTelemetryFieldAvailable(qr.quot);
|
||||
@@ -260,7 +272,7 @@ bool isSourceAvailableInCustomSwitches(int source)
|
||||
{
|
||||
bool result = isSourceAvailable(source);
|
||||
|
||||
if (result && source >= MIXSRC_FIRST_TELEM && source <= MIXSRC_LAST_TELEM) {
|
||||
if (result && modelTelemetryEnabled() && source >= MIXSRC_FIRST_TELEM && source <= MIXSRC_LAST_TELEM) {
|
||||
div_t qr = div(source - MIXSRC_FIRST_TELEM, 3);
|
||||
result = isTelemetryFieldComparisonAvailable(qr.quot);
|
||||
}
|
||||
@@ -298,12 +310,12 @@ bool isSourceAvailableInInputs(int source)
|
||||
if (source >= MIXSRC_FIRST_TRAINER && source <= MIXSRC_LAST_TRAINER)
|
||||
return g_model.trainerData.mode > 0;
|
||||
|
||||
if (source >= MIXSRC_FIRST_TELEM && source <= MIXSRC_LAST_TELEM) {
|
||||
if (modelTelemetryEnabled() && source >= MIXSRC_FIRST_TELEM && source <= MIXSRC_LAST_TELEM) {
|
||||
div_t qr = div(source - MIXSRC_FIRST_TELEM, 3);
|
||||
return isTelemetryFieldAvailable(qr.quot) && isTelemetryFieldComparisonAvailable(qr.quot);
|
||||
}
|
||||
|
||||
if (source >= MIXSRC_FIRST_GVAR && source <= MIXSRC_LAST_GVAR)
|
||||
if (modelGVEnabled() && source >= MIXSRC_FIRST_GVAR && source <= MIXSRC_LAST_GVAR)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -105,7 +105,7 @@ void check_submenu_simple(event_t event, uint8_t rowcount)
|
||||
check_simple(event, 0, nullptr, 0, rowcount);
|
||||
}
|
||||
|
||||
void check_simple(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t menuTabSize, vertpos_t rowcount)
|
||||
void check_simple(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, vertpos_t rowcount)
|
||||
{
|
||||
check(event, curr, menuTab, menuTabSize, 0, 0, rowcount);
|
||||
}
|
||||
|
||||
@@ -173,7 +173,38 @@ tmr10ms_t menuEntryTime;
|
||||
#define MAXCOL(row) (horTab ? *(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0)
|
||||
#define POS_HORZ_INIT(posVert) 0
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow)
|
||||
uint8_t chgMenu(uint8_t curr, const MenuHandler * menuTab, uint8_t menuTabSize, int direction)
|
||||
{
|
||||
int cc = curr + direction;
|
||||
while (cc != curr) {
|
||||
if (cc < 0)
|
||||
cc = menuTabSize - 1;
|
||||
else if (cc >= menuTabSize)
|
||||
cc = 0;
|
||||
if (menuTab[cc].isEnabled())
|
||||
return cc;
|
||||
cc += direction;
|
||||
}
|
||||
return curr;
|
||||
}
|
||||
|
||||
uint8_t menuSize(const MenuHandler * menuTab, uint8_t menuTabSize)
|
||||
{
|
||||
uint8_t sz = 0;
|
||||
for (int i = 0; i < menuTabSize; i += 1) {
|
||||
if (menuTab[i].isEnabled()) {
|
||||
sz += 1;
|
||||
}
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
|
||||
uint8_t menuIdx(const MenuHandler * menuTab, uint8_t curr)
|
||||
{
|
||||
return menuSize(menuTab, curr + 1) - 1;
|
||||
}
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow)
|
||||
{
|
||||
vertpos_t l_posVert = menuVerticalPosition;
|
||||
horzpos_t l_posHorz = menuHorizontalPosition;
|
||||
@@ -209,10 +240,7 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
|
||||
break;
|
||||
#endif
|
||||
case EVT_KEY_FIRST(KEY_LEFT):
|
||||
if (curr > 0)
|
||||
cc = curr - 1;
|
||||
else
|
||||
cc = menuTabSize-1;
|
||||
cc = chgMenu(curr, menuTab, menuTabSize, -1);
|
||||
break;
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
@@ -221,15 +249,12 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
|
||||
break;
|
||||
#endif
|
||||
case EVT_KEY_FIRST(KEY_RIGHT):
|
||||
if (curr < (menuTabSize-1))
|
||||
cc = curr + 1;
|
||||
else
|
||||
cc = 0;
|
||||
cc = chgMenu(curr, menuTab, menuTabSize, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (cc != curr) {
|
||||
chainMenu(menuTab[cc]);
|
||||
chainMenu(menuTab[cc].menuFunc);
|
||||
}
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
@@ -239,7 +264,7 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
|
||||
}
|
||||
|
||||
menuCalibrationState = 0;
|
||||
drawScreenIndex(curr, menuTabSize, attr);
|
||||
drawScreenIndex(menuIdx(menuTab, curr), menuSize(menuTab, menuTabSize), attr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -145,17 +145,19 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
if (i_min <= MIXSRC_FIRST_POT && i_max >= MIXSRC_FIRST_POT) POPUP_MENU_ADD_ITEM(STR_MENU_POTS);
|
||||
if (i_min <= MIXSRC_MAX && i_max >= MIXSRC_MAX) POPUP_MENU_ADD_ITEM(STR_MENU_MAX);
|
||||
#if defined(HELI)
|
||||
if (i_min <= MIXSRC_FIRST_HELI && i_max >= MIXSRC_FIRST_HELI) POPUP_MENU_ADD_ITEM(STR_MENU_HELI);
|
||||
if (modelHeliEnabled())
|
||||
if (i_min <= MIXSRC_FIRST_HELI && i_max >= MIXSRC_FIRST_HELI && isValueAvailable && isValueAvailable(MIXSRC_FIRST_HELI))
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_HELI);
|
||||
#endif
|
||||
if (i_min <= MIXSRC_FIRST_TRIM && i_max >= MIXSRC_FIRST_TRIM) POPUP_MENU_ADD_ITEM(STR_MENU_TRIMS);
|
||||
if (i_min <= MIXSRC_FIRST_SWITCH && i_max >= MIXSRC_FIRST_SWITCH) POPUP_MENU_ADD_ITEM(STR_MENU_SWITCHES);
|
||||
if (i_min <= MIXSRC_FIRST_TRAINER && i_max >= MIXSRC_FIRST_TRAINER) POPUP_MENU_ADD_ITEM(STR_MENU_TRAINER);
|
||||
if (i_min <= MIXSRC_FIRST_CH && i_max >= MIXSRC_FIRST_CH) POPUP_MENU_ADD_ITEM(STR_MENU_CHANNELS);
|
||||
if (i_min <= MIXSRC_FIRST_GVAR && i_max >= MIXSRC_FIRST_GVAR && isValueAvailable(MIXSRC_FIRST_GVAR)) {
|
||||
if (i_min <= MIXSRC_FIRST_GVAR && i_max >= MIXSRC_FIRST_GVAR && isValueAvailable && isValueAvailable(MIXSRC_FIRST_GVAR)) {
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_GVARS);
|
||||
}
|
||||
|
||||
if (i_min <= MIXSRC_FIRST_TELEM && i_max >= MIXSRC_FIRST_TELEM) {
|
||||
if (modelTelemetryEnabled() && i_min <= MIXSRC_FIRST_TELEM && i_max >= MIXSRC_FIRST_TELEM) {
|
||||
for (int i = 0; i < MAX_TELEMETRY_SENSORS; i++) {
|
||||
TelemetrySensor * sensor = & g_model.telemetrySensors[i];
|
||||
if (sensor->isAvailable()) {
|
||||
@@ -215,7 +217,38 @@ tmr10ms_t menuEntryTime;
|
||||
#define COLATTR(row) (MAXCOL_RAW(row) == (uint8_t)-1 ? (const uint8_t)0 : (const uint8_t)(MAXCOL_RAW(row) & NAVIGATION_LINE_BY_LINE))
|
||||
#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0)
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t menuTabSize, const uint8_t * horTab, uint8_t horTabMax, vertpos_t rowcount)
|
||||
uint8_t chgMenu(uint8_t curr, const MenuHandler * menuTab, uint8_t menuTabSize, int direction)
|
||||
{
|
||||
int cc = curr + direction;
|
||||
while (cc != curr) {
|
||||
if (cc < 0)
|
||||
cc = menuTabSize - 1;
|
||||
else if (cc >= menuTabSize)
|
||||
cc = 0;
|
||||
if (menuTab[cc].isEnabled())
|
||||
return cc;
|
||||
cc += direction;
|
||||
}
|
||||
return curr;
|
||||
}
|
||||
|
||||
uint8_t menuSize(const MenuHandler * menuTab, uint8_t menuTabSize)
|
||||
{
|
||||
uint8_t sz = 0;
|
||||
for (int i = 0; i < menuTabSize; i += 1) {
|
||||
if (menuTab[i].isEnabled()) {
|
||||
sz += 1;
|
||||
}
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
|
||||
uint8_t menuIdx(const MenuHandler * menuTab, uint8_t curr)
|
||||
{
|
||||
return menuSize(menuTab, curr + 1) - 1;
|
||||
}
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandler * menuTab, uint8_t menuTabSize, const uint8_t * horTab, uint8_t horTabMax, vertpos_t rowcount)
|
||||
{
|
||||
vertpos_t l_posVert = menuVerticalPosition;
|
||||
horzpos_t l_posHorz = menuHorizontalPosition;
|
||||
@@ -233,10 +266,7 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t
|
||||
if (s_editMode>0)
|
||||
break;
|
||||
|
||||
if (curr > 0)
|
||||
cc = curr - 1;
|
||||
else
|
||||
cc = menuTabSize-1;
|
||||
cc = chgMenu(curr, menuTab, menuTabSize, -1);
|
||||
killEvents(event);
|
||||
break;
|
||||
|
||||
@@ -248,18 +278,15 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t
|
||||
if (s_editMode>0)
|
||||
break;
|
||||
|
||||
if (curr < (menuTabSize-1))
|
||||
cc = curr + 1;
|
||||
else
|
||||
cc = 0;
|
||||
cc = chgMenu(curr, menuTab, menuTabSize, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!menuCalibrationState && cc != curr) {
|
||||
chainMenu(menuTab[cc]);
|
||||
chainMenu(menuTab[cc].menuFunc);
|
||||
}
|
||||
|
||||
drawScreenIndex(curr, menuTabSize, 0);
|
||||
drawScreenIndex(menuIdx(menuTab, curr), menuSize(menuTab, menuTabSize), 0);
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
|
||||
@@ -223,17 +223,19 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
if (i_min <= MIXSRC_FIRST_POT && i_max >= MIXSRC_FIRST_POT) POPUP_MENU_ADD_ITEM(STR_MENU_POTS);
|
||||
if (i_min <= MIXSRC_MAX && i_max >= MIXSRC_MAX) POPUP_MENU_ADD_ITEM(STR_MENU_MAX);
|
||||
#if defined(HELI)
|
||||
if (i_min <= MIXSRC_FIRST_HELI && i_max >= MIXSRC_FIRST_HELI) POPUP_MENU_ADD_ITEM(STR_MENU_HELI);
|
||||
if (modelHeliEnabled())
|
||||
if (i_min <= MIXSRC_FIRST_HELI && i_max >= MIXSRC_FIRST_HELI && isValueAvailable && isValueAvailable(MIXSRC_FIRST_HELI))
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_HELI);
|
||||
#endif
|
||||
if (i_min <= MIXSRC_FIRST_TRIM && i_max >= MIXSRC_FIRST_TRIM) POPUP_MENU_ADD_ITEM(STR_MENU_TRIMS);
|
||||
if (i_min <= MIXSRC_FIRST_SWITCH && i_max >= MIXSRC_FIRST_SWITCH) POPUP_MENU_ADD_ITEM(STR_MENU_SWITCHES);
|
||||
if (i_min <= MIXSRC_FIRST_TRAINER && i_max >= MIXSRC_FIRST_TRAINER) POPUP_MENU_ADD_ITEM(STR_MENU_TRAINER);
|
||||
if (i_min <= MIXSRC_FIRST_CH && i_max >= MIXSRC_FIRST_CH) POPUP_MENU_ADD_ITEM(STR_MENU_CHANNELS);
|
||||
if (i_min <= MIXSRC_FIRST_GVAR && i_max >= MIXSRC_FIRST_GVAR && isValueAvailable(MIXSRC_FIRST_GVAR)) {
|
||||
if (i_min <= MIXSRC_FIRST_GVAR && i_max >= MIXSRC_FIRST_GVAR && isValueAvailable && isValueAvailable(MIXSRC_FIRST_GVAR)) {
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_GVARS);
|
||||
}
|
||||
|
||||
if (i_min <= MIXSRC_FIRST_TELEM && i_max >= MIXSRC_FIRST_TELEM) {
|
||||
if (modelTelemetryEnabled() && i_min <= MIXSRC_FIRST_TELEM && i_max >= MIXSRC_FIRST_TELEM) {
|
||||
for (int i = 0; i < MAX_TELEMETRY_SENSORS; i++) {
|
||||
TelemetrySensor * sensor = & g_model.telemetrySensors[i];
|
||||
if (sensor->isAvailable()) {
|
||||
@@ -300,7 +302,38 @@ void onLongMenuPress(const char * result)
|
||||
|
||||
tmr10ms_t menuEntryTime;
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t rowcount, uint8_t flags)
|
||||
uint8_t chgMenu(uint8_t curr, const MenuHandler * menuTab, uint8_t menuTabSize, int direction)
|
||||
{
|
||||
int cc = curr + direction;
|
||||
while (cc != curr) {
|
||||
if (cc < 0)
|
||||
cc = menuTabSize - 1;
|
||||
else if (cc >= menuTabSize)
|
||||
cc = 0;
|
||||
if (menuTab[cc].isEnabled())
|
||||
return cc;
|
||||
cc += direction;
|
||||
}
|
||||
return curr;
|
||||
}
|
||||
|
||||
uint8_t menuSize(const MenuHandler * menuTab, uint8_t menuTabSize)
|
||||
{
|
||||
uint8_t sz = 0;
|
||||
for (int i = 0; i < menuTabSize; i += 1) {
|
||||
if (menuTab[i].isEnabled()) {
|
||||
sz += 1;
|
||||
}
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
|
||||
uint8_t menuIdx(const MenuHandler * menuTab, uint8_t curr)
|
||||
{
|
||||
return menuSize(menuTab, curr + 1) - 1;
|
||||
}
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t rowcount, uint8_t flags)
|
||||
{
|
||||
vertpos_t l_posVert = menuVerticalPosition;
|
||||
horzpos_t l_posHorz = menuHorizontalPosition;
|
||||
@@ -328,10 +361,7 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
|
||||
if (s_editMode>0)
|
||||
break;
|
||||
|
||||
if (curr > 0)
|
||||
cc = curr - 1;
|
||||
else
|
||||
cc = menuTabSize-1;
|
||||
cc = chgMenu(curr, menuTab, menuTabSize, -1);
|
||||
killEvents(event);
|
||||
break;
|
||||
|
||||
@@ -339,19 +369,16 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
|
||||
if (s_editMode>0)
|
||||
break;
|
||||
|
||||
if (curr < (menuTabSize-1))
|
||||
cc = curr + 1;
|
||||
else
|
||||
cc = 0;
|
||||
cc = chgMenu(curr, menuTab, menuTabSize, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!menuCalibrationState && cc != curr) {
|
||||
chainMenu(menuTab[cc]);
|
||||
chainMenu(menuTab[cc].menuFunc);
|
||||
}
|
||||
|
||||
if (!(flags&CHECK_FLAG_NO_SCREEN_INDEX)) {
|
||||
drawScreenIndex(curr, menuTabSize, 0);
|
||||
drawScreenIndex(menuIdx(menuTab, curr), menuSize(menuTab, menuTabSize), 0);
|
||||
}
|
||||
|
||||
lcdDrawFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, SOLID, FILL_WHITE|GREY_DEFAULT);
|
||||
|
||||
@@ -199,17 +199,19 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
if (i_min <= MIXSRC_FIRST_POT && i_max >= MIXSRC_FIRST_POT) POPUP_MENU_ADD_ITEM(STR_MENU_POTS);
|
||||
if (i_min <= MIXSRC_MAX && i_max >= MIXSRC_MAX) POPUP_MENU_ADD_ITEM(STR_MENU_MAX);
|
||||
#if defined(HELI)
|
||||
if (i_min <= MIXSRC_FIRST_HELI && i_max >= MIXSRC_FIRST_HELI) POPUP_MENU_ADD_ITEM(STR_MENU_HELI);
|
||||
if (modelHeliEnabled())
|
||||
if (i_min <= MIXSRC_FIRST_HELI && i_max >= MIXSRC_FIRST_HELI && isValueAvailable && isValueAvailable(MIXSRC_FIRST_HELI))
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_HELI);
|
||||
#endif
|
||||
if (i_min <= MIXSRC_FIRST_TRIM && i_max >= MIXSRC_FIRST_TRIM) POPUP_MENU_ADD_ITEM(STR_MENU_TRIMS);
|
||||
if (i_min <= MIXSRC_FIRST_SWITCH && i_max >= MIXSRC_FIRST_SWITCH) POPUP_MENU_ADD_ITEM(STR_MENU_SWITCHES);
|
||||
if (i_min <= MIXSRC_FIRST_TRAINER && i_max >= MIXSRC_FIRST_TRAINER) POPUP_MENU_ADD_ITEM(STR_MENU_TRAINER);
|
||||
if (i_min <= MIXSRC_FIRST_CH && i_max >= MIXSRC_FIRST_CH) POPUP_MENU_ADD_ITEM(STR_MENU_CHANNELS);
|
||||
if (i_min <= MIXSRC_FIRST_GVAR && i_max >= MIXSRC_FIRST_GVAR && isValueAvailable(MIXSRC_FIRST_GVAR)) {
|
||||
if (i_min <= MIXSRC_FIRST_GVAR && i_max >= MIXSRC_FIRST_GVAR && isValueAvailable && isValueAvailable(MIXSRC_FIRST_GVAR)) {
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_GVARS);
|
||||
}
|
||||
|
||||
if (i_min <= MIXSRC_FIRST_TELEM && i_max >= MIXSRC_FIRST_TELEM) {
|
||||
if (modelTelemetryEnabled() && i_min <= MIXSRC_FIRST_TELEM && i_max >= MIXSRC_FIRST_TELEM) {
|
||||
for (int i = 0; i < MAX_TELEMETRY_SENSORS; i++) {
|
||||
TelemetrySensor * sensor = & g_model.telemetrySensors[i];
|
||||
if (sensor->isAvailable()) {
|
||||
@@ -269,7 +271,38 @@ tmr10ms_t menuEntryTime;
|
||||
#define MAXCOL(row) (MAXCOL_RAW(row) >= HIDDEN_ROW ? MAXCOL_RAW(row) : (const uint8_t)(MAXCOL_RAW(row) & (~NAVIGATION_LINE_BY_LINE)))
|
||||
#define POS_HORZ_INIT(posVert) 0
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow)
|
||||
uint8_t chgMenu(uint8_t curr, const MenuHandler * menuTab, uint8_t menuTabSize, int direction)
|
||||
{
|
||||
int cc = curr + direction;
|
||||
while (cc != curr) {
|
||||
if (cc < 0)
|
||||
cc = menuTabSize - 1;
|
||||
else if (cc >= menuTabSize)
|
||||
cc = 0;
|
||||
if (menuTab[cc].isEnabled())
|
||||
return cc;
|
||||
cc += direction;
|
||||
}
|
||||
return curr;
|
||||
}
|
||||
|
||||
uint8_t menuSize(const MenuHandler * menuTab, uint8_t menuTabSize)
|
||||
{
|
||||
uint8_t sz = 0;
|
||||
for (int i = 0; i < menuTabSize; i += 1) {
|
||||
if (menuTab[i].isEnabled()) {
|
||||
sz += 1;
|
||||
}
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
|
||||
uint8_t menuIdx(const MenuHandler * menuTab, uint8_t curr)
|
||||
{
|
||||
return menuSize(menuTab, curr + 1) - 1;
|
||||
}
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow)
|
||||
{
|
||||
vertpos_t l_posVert = menuVerticalPosition;
|
||||
horzpos_t l_posHorz = menuHorizontalPosition;
|
||||
@@ -286,27 +319,21 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
|
||||
|
||||
switch (event) {
|
||||
case EVT_KEY_FIRST(KEY_LEFT):
|
||||
if (curr > 0)
|
||||
cc = curr - 1;
|
||||
else
|
||||
cc = menuTabSize-1;
|
||||
cc = chgMenu(curr, menuTab, menuTabSize, -1);
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_RIGHT):
|
||||
if (curr < (menuTabSize-1))
|
||||
cc = curr + 1;
|
||||
else
|
||||
cc = 0;
|
||||
cc = chgMenu(curr, menuTab, menuTabSize, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (cc != curr) {
|
||||
chainMenu(menuTab[cc]);
|
||||
chainMenu(menuTab[cc].menuFunc);
|
||||
}
|
||||
}
|
||||
|
||||
menuCalibrationState = 0;
|
||||
drawScreenIndex(curr, menuTabSize, attr);
|
||||
drawScreenIndex(menuIdx(menuTab, curr), menuSize(menuTab, menuTabSize), attr);
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
|
||||
Reference in New Issue
Block a user