diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index da3f94543..754d849a0 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -669,7 +669,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti if (item == source) b->setCurrentIndex(b->count()-1); } for (int i=0; isensorData[i].isAvailable()) { + if (model && model->sensorData[i].isAvailable()) { //this conditon must be false if we populate Global Functions where model = 0 for (int j=0; j<3; ++j) { item = RawSource(SOURCE_TYPE_TELEMETRY, 3*i+j); b->addItem(item.toString(model), item.toValue()); @@ -681,8 +681,6 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti } else { for (int i=0; i<(flags & POPULATE_TELEMETRYEXT ? TELEMETRY_SOURCES_STATUS_COUNT : TELEMETRY_SOURCES_COUNT); i++) { - if (i==TELEMETRY_SOURCE_RSSI_TX && IS_TARANIS(board)) - continue; if (i==TELEMETRY_SOURCE_TX_TIME && !GetCurrentFirmware()->getCapability(RtcTime)) continue; if (i==TELEMETRY_SOURCE_SWR && !GetCurrentFirmware()->getCapability(SportTelemetry)) diff --git a/radio/src/gui/9X/helpers.cpp b/radio/src/gui/9X/helpers.cpp index 6731a118d..b823acd81 100755 --- a/radio/src/gui/9X/helpers.cpp +++ b/radio/src/gui/9X/helpers.cpp @@ -86,6 +86,14 @@ bool isSourceAvailable(int source) return true; } +bool isSourceAvailableInGlobalFunctions(int source) +{ + if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { + return false; + } + return isSourceAvailable(source); +} + bool isSourceAvailableInCustomSwitches(int source) { bool result = isSourceAvailable(source); diff --git a/radio/src/gui/9X/menu_general.cpp b/radio/src/gui/9X/menu_general.cpp index b2e3e679d..d7d56ec13 100755 --- a/radio/src/gui/9X/menu_general.cpp +++ b/radio/src/gui/9X/menu_general.cpp @@ -104,6 +104,6 @@ const MenuFuncP_PROGMEM menuTabGeneral[] PROGMEM = { void menuGeneralCustomFunctions(uint8_t event) { MENU(STR_MENUGLOBALFUNCS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN+1, {0, NAVIGATION_LINE_BY_LINE|4/*repeated*/}); - return menuCustomFunctions(event, g_eeGeneral.customFn, globalFunctionsContext); + return menuCustomFunctions(event, g_eeGeneral.customFn, &globalFunctionsContext); } #endif diff --git a/radio/src/gui/9X/menu_model_custom_functions.cpp b/radio/src/gui/9X/menu_model_custom_functions.cpp index e29ba60ba..4e44e3806 100644 --- a/radio/src/gui/9X/menu_model_custom_functions.cpp +++ b/radio/src/gui/9X/menu_model_custom_functions.cpp @@ -74,7 +74,7 @@ void onCustomFunctionsFileSelectionMenu(const char *result) } #endif -void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext) +void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext) { int8_t sub = m_posVert - 1; @@ -95,7 +95,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu uint8_t active = (attr && (s_editMode>0 || p1valdiff)); switch (j) { case 0: - putsSwitches(MODEL_CUSTOM_FUNC_1ST_COLUMN, y, CFN_SWITCH(cfn), attr | ((functionsContext.activeSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); + putsSwitches(MODEL_CUSTOM_FUNC_1ST_COLUMN, y, CFN_SWITCH(cfn), attr | ((functionsContext->activeSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); if (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_SWITCH(event, CFN_SWITCH(cfn), SWSRC_FIRST, SWSRC_LAST, eeFlags, isSwitchAvailableInCustomFunctions); break; @@ -278,7 +278,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu else if (func == FUNC_PLAY_VALUE) { val_max = MIXSRC_FIRST_TELEM + TELEM_DISPLAY_MAX - 1; putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); - INCDEC_ENABLE_CHECK(isSourceAvailable); + INCDEC_ENABLE_CHECK(functionsContext == &globalFunctionsContext ? isSourceAvailableInGlobalFunctions : isSourceAvailable); } #endif #if defined(SDCARD) @@ -377,5 +377,5 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu void menuModelCustomFunctions(uint8_t event) { MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_CFN+1, {0, NAVIGATION_LINE_BY_LINE|4/*repeated*/}); - return menuCustomFunctions(event, g_model.customFn, modelFunctionsContext); + return menuCustomFunctions(event, g_model.customFn, &modelFunctionsContext); } diff --git a/radio/src/gui/9X/menus.h b/radio/src/gui/9X/menus.h index aa2832559..37e78cf2a 100755 --- a/radio/src/gui/9X/menus.h +++ b/radio/src/gui/9X/menus.h @@ -102,7 +102,7 @@ void menuTelemetryFrsky(uint8_t event); #endif void menuGeneralSetup(uint8_t event); void menuGeneralCalib(uint8_t event); -void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext); +void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext); void menuModelSelect(uint8_t event); void menuModelCustomFunctions(uint8_t event); @@ -253,6 +253,7 @@ int8_t checkIncDecMovedSwitch(int8_t val); #if defined(CPUARM) bool isInputAvailable(int input); bool isSourceAvailable(int source); + bool isSourceAvailableInGlobalFunctions(int source); bool isSourceAvailableInCustomSwitches(int source); bool isInputSourceAvailable(int source); #define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \ diff --git a/radio/src/gui/Taranis/helpers.cpp b/radio/src/gui/Taranis/helpers.cpp index 4985337d7..86e7dabee 100755 --- a/radio/src/gui/Taranis/helpers.cpp +++ b/radio/src/gui/Taranis/helpers.cpp @@ -131,6 +131,14 @@ bool isSourceAvailable(int source) return true; } +bool isSourceAvailableInGlobalFunctions(int source) +{ + if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { + return false; + } + return isSourceAvailable(source); +} + bool isSourceAvailableInCustomSwitches(int source) { bool result = isSourceAvailable(source); diff --git a/radio/src/gui/Taranis/menu_general.cpp b/radio/src/gui/Taranis/menu_general.cpp index 392edfe09..a3534ca57 100755 --- a/radio/src/gui/Taranis/menu_general.cpp +++ b/radio/src/gui/Taranis/menu_general.cpp @@ -103,5 +103,5 @@ const MenuFuncP_PROGMEM menuTabGeneral[] PROGMEM = { void menuGeneralCustomFunctions(uint8_t event) { MENU(STR_MENUGLOBALFUNCS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ }); - return menuCustomFunctions(event, g_eeGeneral.customFn, globalFunctionsContext); + return menuCustomFunctions(event, g_eeGeneral.customFn, &globalFunctionsContext); } diff --git a/radio/src/gui/Taranis/menu_model_custom_functions.cpp b/radio/src/gui/Taranis/menu_model_custom_functions.cpp index fb4576ffc..c3f55f83d 100644 --- a/radio/src/gui/Taranis/menu_model_custom_functions.cpp +++ b/radio/src/gui/Taranis/menu_model_custom_functions.cpp @@ -121,7 +121,7 @@ void onCustomFunctionsMenu(const char *result) } } -void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext) +void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext) { int sub = m_posVert; uint8_t eeFlags = (functions == g_model.customFn) ? EE_MODEL : EE_GENERAL; @@ -158,7 +158,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu uint8_t active = (attr && s_editMode>0); switch (j) { case 0: - putsSwitches(MODEL_CUSTOM_FUNC_1ST_COLUMN, y, CFN_SWITCH(cfn), attr | ((functionsContext.activeSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); + putsSwitches(MODEL_CUSTOM_FUNC_1ST_COLUMN, y, CFN_SWITCH(cfn), attr | ((functionsContext->activeSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); if (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_SWITCH(event, CFN_SWITCH(cfn), SWSRC_FIRST, SWSRC_LAST, eeFlags, isSwitchAvailableInCustomFunctions); if (func == FUNC_OVERRIDE_CHANNEL && functions != g_model.customFn) { func = CFN_FUNC(cfn) = func+1; @@ -288,7 +288,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu val_max = MIXSRC_LAST_TELEM; putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE); - INCDEC_ENABLE_CHECK(isSourceAvailable); + INCDEC_ENABLE_CHECK(functionsContext == &globalFunctionsContext ? isSourceAvailableInGlobalFunctions : isSourceAvailable); } #endif else if (func == FUNC_VOLUME) { @@ -390,5 +390,5 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu void menuModelCustomFunctions(uint8_t event) { MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_CFN, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ }); - return menuCustomFunctions(event, g_model.customFn, modelFunctionsContext); + return menuCustomFunctions(event, g_model.customFn, &modelFunctionsContext); } diff --git a/radio/src/gui/Taranis/menus.h b/radio/src/gui/Taranis/menus.h index 1f7bf39f0..8283b6a25 100755 --- a/radio/src/gui/Taranis/menus.h +++ b/radio/src/gui/Taranis/menus.h @@ -104,7 +104,7 @@ void menuGeneralSetup(uint8_t event); void menuGeneralSdManager(uint8_t event); void menuGeneralCalib(uint8_t event); void menuGeneralVersion(uint8_t event); -void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext); +void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext); void menuModelSelect(uint8_t event); void menuModelCustomFunctions(uint8_t event); @@ -212,6 +212,7 @@ int getFirstAvailable(int min, int max, bool (*func)(int)); bool isInputAvailable(int input); bool isSourceAvailable(int source); +bool isSourceAvailableInGlobalFunctions(int source); bool isSourceAvailableInCustomSwitches(int source); bool isInputSourceAvailable(int source); #define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \