From fe919c0b31a13c0314850e430d4754b8115ed7e4 Mon Sep 17 00:00:00 2001 From: philmoz Date: Sun, 19 Oct 2025 13:58:30 +1100 Subject: [PATCH] feat(bw): make source selection consistent with color screen radios (#6685) --- radio/src/dataconstants.h | 5 ++- radio/src/gui/128x64/model_input_edit.cpp | 2 +- .../gui/128x64/model_special_functions.cpp | 2 +- radio/src/gui/212x64/model_input_edit.cpp | 2 +- .../src/gui/212x64/model_logical_switches.cpp | 2 +- .../gui/212x64/model_special_functions.cpp | 2 +- radio/src/gui/common/stdlcd/model_inputs.cpp | 2 +- radio/src/gui/gui_common.cpp | 33 ------------------- radio/src/gui/gui_common.h | 3 -- 9 files changed, 8 insertions(+), 45 deletions(-) diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index fb804b815..bcd368d50 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -588,9 +588,8 @@ enum SrcTypes { SRC_TX = 1 << 16, SRC_TIMER = 1 << 17, SRC_TELEM = 1 << 18, - SRC_TELEM_COMP = 1 << 19, - SRC_NONE = 1 << 20, - SRC_INVERT = 1 << 21, + SRC_NONE = 1 << 19, + SRC_INVERT = 1 << 20, }; enum BacklightMode { diff --git a/radio/src/gui/128x64/model_input_edit.cpp b/radio/src/gui/128x64/model_input_edit.cpp index 9c7faf726..6a429eb35 100644 --- a/radio/src/gui/128x64/model_input_edit.cpp +++ b/radio/src/gui/128x64/model_input_edit.cpp @@ -100,7 +100,7 @@ void menuModelExpoOne(event_t event) lcdDrawTextAlignedLeft(y, STR_SOURCE); drawSource(EXPO_ONE_2ND_COLUMN, y, ed->srcRaw, STREXPANDED|attr); if (attr) - ed->srcRaw = checkIncDec(event, ed->srcRaw, INPUTSRC_FIRST, INPUTSRC_LAST, EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isSourceAvailableInInputs); + ed->srcRaw = checkIncDec(event, ed->srcRaw, INPUTSRC_FIRST, INPUTSRC_LAST, EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isSourceAvailable); break; case EXPO_FIELD_SCALE: diff --git a/radio/src/gui/128x64/model_special_functions.cpp b/radio/src/gui/128x64/model_special_functions.cpp index c535aa25f..decc79657 100644 --- a/radio/src/gui/128x64/model_special_functions.cpp +++ b/radio/src/gui/128x64/model_special_functions.cpp @@ -385,7 +385,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN - (val_displayed == 0 ? 0 : 2 * FW), y, val_displayed, attr); if (active) { INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE | INCDEC_SOURCE_INVERT); - INCDEC_ENABLE_CHECK(functionsContext == &globalFunctionsContext ? isSourceAvailableInGlobalFunctions : isSourceAvailable); + INCDEC_ENABLE_CHECK(isSourceAvailable); } } else if (func == FUNC_VOLUME) { diff --git a/radio/src/gui/212x64/model_input_edit.cpp b/radio/src/gui/212x64/model_input_edit.cpp index 22ac8237b..9543e0034 100644 --- a/radio/src/gui/212x64/model_input_edit.cpp +++ b/radio/src/gui/212x64/model_input_edit.cpp @@ -102,7 +102,7 @@ void menuModelExpoOne(event_t event) lcdDrawTextAlignedLeft(y, STR_SOURCE); drawSource(EXPO_ONE_2ND_COLUMN, y, ed->srcRaw, STREXPANDED|attr); if (attr && menuHorizontalPosition==0) - ed->srcRaw = checkIncDec(event, ed->srcRaw, INPUTSRC_FIRST, INPUTSRC_LAST, EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isSourceAvailableInInputs); + ed->srcRaw = checkIncDec(event, ed->srcRaw, INPUTSRC_FIRST, INPUTSRC_LAST, EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isSourceAvailable); if (abs(ed->srcRaw) >= MIXSRC_FIRST_TELEM) { drawSensorCustomValue(EXPO_ONE_2ND_COLUMN+30, y, (abs(ed->srcRaw) - MIXSRC_FIRST_TELEM)/3, getValue(ed->srcRaw), LEFT|(menuHorizontalPosition==1?attr:0)); if (attr && menuHorizontalPosition == 1) ed->scale = checkIncDec(event, ed->scale, 0, maxTelemValue(abs(ed->srcRaw) - MIXSRC_FIRST_TELEM + 1), EE_MODEL); diff --git a/radio/src/gui/212x64/model_logical_switches.cpp b/radio/src/gui/212x64/model_logical_switches.cpp index 547da8322..5c0cd7173 100644 --- a/radio/src/gui/212x64/model_logical_switches.cpp +++ b/radio/src/gui/212x64/model_logical_switches.cpp @@ -166,7 +166,7 @@ void menuModelLogicalSwitches(event_t event) drawSource(CSW_2ND_COLUMN, y, v1_val, attr1); if (horz == 1) { INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE | INCDEC_SOURCE_INVERT); - INCDEC_ENABLE_CHECK(isSourceAvailableInCustomSwitches); + INCDEC_ENABLE_CHECK(isSourceAvailable); } else { INCDEC_SET_FLAG(EE_MODEL); diff --git a/radio/src/gui/212x64/model_special_functions.cpp b/radio/src/gui/212x64/model_special_functions.cpp index f2c63b15e..ed193a719 100644 --- a/radio/src/gui/212x64/model_special_functions.cpp +++ b/radio/src/gui/212x64/model_special_functions.cpp @@ -358,7 +358,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr); if (active) { INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE | INCDEC_SOURCE_INVERT); - INCDEC_ENABLE_CHECK(functionsContext == &globalFunctionsContext ? isSourceAvailableInGlobalFunctions : isSourceAvailable); + INCDEC_ENABLE_CHECK(isSourceAvailable); } } else if (func == FUNC_VOLUME) { diff --git a/radio/src/gui/common/stdlcd/model_inputs.cpp b/radio/src/gui/common/stdlcd/model_inputs.cpp index e7987ef81..523fc1c24 100644 --- a/radio/src/gui/common/stdlcd/model_inputs.cpp +++ b/radio/src/gui/common/stdlcd/model_inputs.cpp @@ -64,7 +64,7 @@ void insertExpo(uint8_t idx) } else { expo->srcRaw = MIXSRC_FIRST_STICK + inputMappingChannelOrder(i - 1); } - if (isSourceAvailableInInputs(expo->srcRaw)) { + if (isSourceAvailable(expo->srcRaw)) { break; } } diff --git a/radio/src/gui/gui_common.cpp b/radio/src/gui/gui_common.cpp index f0a25a345..c38d03897 100644 --- a/radio/src/gui/gui_common.cpp +++ b/radio/src/gui/gui_common.cpp @@ -247,13 +247,6 @@ static bool isSourceTelemAvailable(int source) { return isTelemetryFieldComparisonAvailable(qr.quot); } -static bool isSourceTelemCompAvailable(int source) { - if (!modelTelemetryEnabled()) - return false; - div_t qr = div(source, 3); - return isTelemetryFieldComparisonAvailable(qr.quot); -} - struct sourceAvailableCheck { uint16_t first; uint16_t last; @@ -287,7 +280,6 @@ static struct sourceAvailableCheck sourceChecks[] = { { MIXSRC_TX_VOLTAGE, MIXSRC_TX_GPS, SRC_TX, sourceIsAvailable }, { MIXSRC_FIRST_TIMER, MIXSRC_LAST_TIMER, SRC_TIMER, isSourceTimerAvailable }, { MIXSRC_FIRST_TELEM, MIXSRC_LAST_TELEM, SRC_TELEM, isSourceTelemAvailable }, - { MIXSRC_FIRST_TELEM, MIXSRC_LAST_TELEM, SRC_TELEM_COMP, isSourceTelemCompAvailable }, { MIXSRC_NONE, MIXSRC_NONE, SRC_NONE, sourceIsAvailable }, }; @@ -316,31 +308,6 @@ bool isSourceAvailable(int source) ); } -// Used only in B&W radios for Global Functions when funcion is FUNC_PLAY_VALUE -bool isSourceAvailableInGlobalFunctions(int source) -{ - return checkSourceAvailable(source, - SRC_COMMON | SRC_INPUT | SRC_LUA | SRC_HELI | SRC_CHANNEL | SRC_TX | SRC_TIMER | SRC_NONE - ); -} - -// Used only in B&W radios with wide screen LCD (212x64) for logical switches -// V1 parameter when LS function is LS_FAMILY_OFS or LS_FAMILY_DIFF -bool isSourceAvailableInCustomSwitches(int source) -{ - return checkSourceAvailable(source, - SRC_COMMON | SRC_INPUT | SRC_LUA | SRC_HELI | SRC_CHANNEL | SRC_TX | SRC_TIMER | SRC_TELEM_COMP | SRC_NONE - ); -} - -// Only used for B&W radios for Input source (color radios use isSourceAvailable) -bool isSourceAvailableInInputs(int source) -{ - return checkSourceAvailable(source, - SRC_COMMON | SRC_CHANNEL_ALL | SRC_TELEM_COMP - ); -} - bool isLogicalSwitchAvailable(int index) { LogicalSwitchData * lsw = lswAddress(index); diff --git a/radio/src/gui/gui_common.h b/radio/src/gui/gui_common.h index 258135cd5..df390ef4e 100644 --- a/radio/src/gui/gui_common.h +++ b/radio/src/gui/gui_common.h @@ -56,15 +56,12 @@ int getFirstAvailable(int min, int max, IsValueAvailable isValueAvailable); bool checkSourceAvailable(int source, uint32_t sourceTypes); bool checkSwitchAvailable(int swtch, uint32_t swtchTypes); bool isInputAvailable(int input); -bool isSourceAvailableInInputs(int source); bool isThrottleSourceAvailable(int source); bool isLogicalSwitchAvailable(int index); bool isAssignableFunctionAvailable(int function); bool isSourceAvailable(int source); int timersSetupCount(); bool isTimerSourceAvailable(int source); -bool isSourceAvailableInGlobalFunctions(int source); -bool isSourceAvailableInCustomSwitches(int source); bool isSourceAvailableInResetSpecialFunction(int index); bool isSourceAvailableInGlobalResetSpecialFunction(int index); bool isSwitchAvailable(int swtch, SwitchContext context);