1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-19 06:15:10 +03:00

Fixes #2519: removed telemetry values from available selection in Global Functions for "Play Value"

This commit is contained in:
Damjan Adamic 2015-07-20 20:34:15 +02:00
parent f845be683c
commit 841f11c21a
9 changed files with 32 additions and 14 deletions

View file

@ -669,7 +669,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti
if (item == source) b->setCurrentIndex(b->count()-1); if (item == source) b->setCurrentIndex(b->count()-1);
} }
for (int i=0; i<C9X_MAX_SENSORS; ++i) { for (int i=0; i<C9X_MAX_SENSORS; ++i) {
if (model->sensorData[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) { for (int j=0; j<3; ++j) {
item = RawSource(SOURCE_TYPE_TELEMETRY, 3*i+j); item = RawSource(SOURCE_TYPE_TELEMETRY, 3*i+j);
b->addItem(item.toString(model), item.toValue()); b->addItem(item.toString(model), item.toValue());
@ -681,7 +681,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti
} }
else { else {
for (int i=0; i<(flags & POPULATE_TELEMETRYEXT ? TELEMETRY_SOURCES_STATUS_COUNT : TELEMETRY_SOURCES_COUNT); i++) { 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)) if (i==TELEMETRY_SOURCE_RSSI_TX && IS_TARANIS(board)) // TODO this condition is never true since else clause is never taken for ARM boards!!!
continue; continue;
if (i==TELEMETRY_SOURCE_TX_TIME && !GetCurrentFirmware()->getCapability(RtcTime)) if (i==TELEMETRY_SOURCE_TX_TIME && !GetCurrentFirmware()->getCapability(RtcTime))
continue; continue;

View file

@ -86,6 +86,14 @@ bool isSourceAvailable(int source)
return true; 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 isSourceAvailableInCustomSwitches(int source)
{ {
bool result = isSourceAvailable(source); bool result = isSourceAvailable(source);

View file

@ -104,6 +104,6 @@ const MenuFuncP_PROGMEM menuTabGeneral[] PROGMEM = {
void menuGeneralCustomFunctions(uint8_t event) void menuGeneralCustomFunctions(uint8_t event)
{ {
MENU(STR_MENUGLOBALFUNCS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN+1, {0, NAVIGATION_LINE_BY_LINE|4/*repeated*/}); 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 #endif

View file

@ -74,7 +74,7 @@ void onCustomFunctionsFileSelectionMenu(const char *result)
} }
#endif #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; 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)); uint8_t active = (attr && (s_editMode>0 || p1valdiff));
switch (j) { switch (j) {
case 0: 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 (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_SWITCH(event, CFN_SWITCH(cfn), SWSRC_FIRST, SWSRC_LAST, eeFlags, isSwitchAvailableInCustomFunctions);
break; break;
@ -278,7 +278,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
else if (func == FUNC_PLAY_VALUE) { else if (func == FUNC_PLAY_VALUE) {
val_max = MIXSRC_FIRST_TELEM + TELEM_DISPLAY_MAX - 1; val_max = MIXSRC_FIRST_TELEM + TELEM_DISPLAY_MAX - 1;
putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr);
INCDEC_ENABLE_CHECK(isSourceAvailable); INCDEC_ENABLE_CHECK(functionsContext == &globalFunctionsContext ? isSourceAvailableInGlobalFunctions : isSourceAvailable);
} }
#endif #endif
#if defined(SDCARD) #if defined(SDCARD)
@ -377,5 +377,5 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
void menuModelCustomFunctions(uint8_t event) void menuModelCustomFunctions(uint8_t event)
{ {
MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_CFN+1, {0, NAVIGATION_LINE_BY_LINE|4/*repeated*/}); 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);
} }

View file

@ -102,7 +102,7 @@ void menuTelemetryFrsky(uint8_t event);
#endif #endif
void menuGeneralSetup(uint8_t event); void menuGeneralSetup(uint8_t event);
void menuGeneralCalib(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 menuModelSelect(uint8_t event);
void menuModelCustomFunctions(uint8_t event); void menuModelCustomFunctions(uint8_t event);
@ -253,6 +253,7 @@ int8_t checkIncDecMovedSwitch(int8_t val);
#if defined(CPUARM) #if defined(CPUARM)
bool isInputAvailable(int input); bool isInputAvailable(int input);
bool isSourceAvailable(int source); bool isSourceAvailable(int source);
bool isSourceAvailableInGlobalFunctions(int source);
bool isSourceAvailableInCustomSwitches(int source); bool isSourceAvailableInCustomSwitches(int source);
bool isInputSourceAvailable(int source); bool isInputSourceAvailable(int source);
#define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \ #define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \

View file

@ -131,6 +131,14 @@ bool isSourceAvailable(int source)
return true; 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 isSourceAvailableInCustomSwitches(int source)
{ {
bool result = isSourceAvailable(source); bool result = isSourceAvailable(source);

View file

@ -103,5 +103,5 @@ const MenuFuncP_PROGMEM menuTabGeneral[] PROGMEM = {
void menuGeneralCustomFunctions(uint8_t event) void menuGeneralCustomFunctions(uint8_t event)
{ {
MENU(STR_MENUGLOBALFUNCS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ }); 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);
} }

View file

@ -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; int sub = m_posVert;
uint8_t eeFlags = (functions == g_model.customFn) ? EE_MODEL : EE_GENERAL; 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); uint8_t active = (attr && s_editMode>0);
switch (j) { switch (j) {
case 0: 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 (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) { if (func == FUNC_OVERRIDE_CHANNEL && functions != g_model.customFn) {
func = CFN_FUNC(cfn) = func+1; func = CFN_FUNC(cfn) = func+1;
@ -288,7 +288,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
val_max = MIXSRC_LAST_TELEM; val_max = MIXSRC_LAST_TELEM;
putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr);
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE); INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
INCDEC_ENABLE_CHECK(isSourceAvailable); INCDEC_ENABLE_CHECK(functionsContext == &globalFunctionsContext ? isSourceAvailableInGlobalFunctions : isSourceAvailable);
} }
#endif #endif
else if (func == FUNC_VOLUME) { else if (func == FUNC_VOLUME) {
@ -390,5 +390,5 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
void menuModelCustomFunctions(uint8_t event) void menuModelCustomFunctions(uint8_t event)
{ {
MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_CFN, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ }); 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);
} }

View file

@ -104,7 +104,7 @@ void menuGeneralSetup(uint8_t event);
void menuGeneralSdManager(uint8_t event); void menuGeneralSdManager(uint8_t event);
void menuGeneralCalib(uint8_t event); void menuGeneralCalib(uint8_t event);
void menuGeneralVersion(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 menuModelSelect(uint8_t event);
void menuModelCustomFunctions(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 isInputAvailable(int input);
bool isSourceAvailable(int source); bool isSourceAvailable(int source);
bool isSourceAvailableInGlobalFunctions(int source);
bool isSourceAvailableInCustomSwitches(int source); bool isSourceAvailableInCustomSwitches(int source);
bool isInputSourceAvailable(int source); bool isInputSourceAvailable(int source);
#define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \ #define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \