feat(radio): refactor of switch handling to better support customisable switches (#6095)
Co-authored-by: philmoz <phil.a.mitchell@gmail.com> Co-authored-by: 3djc <3djc@gh.com> Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
co-authored by
philmoz
3djc
elecpower
parent
28833f42e6
commit
0c8c39b134
@@ -362,7 +362,7 @@ bool isSwitchAvailable(int swtch, SwitchContext context)
|
||||
|
||||
if (swtch >= SWSRC_FIRST_SWITCH && swtch <= SWSRC_LAST_SWITCH) {
|
||||
div_t swinfo = switchInfo(swtch);
|
||||
if (swinfo.quot >= switchGetMaxSwitches() + switchGetMaxFctSwitches()) {
|
||||
if (swinfo.quot >= switchGetMaxAllSwitches()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ bool isSwitchAvailable(int swtch, SwitchContext context)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IS_SWITCH_FS(swinfo.quot) && context == GeneralCustomFunctionsContext) {
|
||||
if (switchIsCustomSwitch(swinfo.quot) && context == GeneralCustomFunctionsContext) {
|
||||
return false; // FS are defined at model level, and cannot be in global functions
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ static bool isSwitchSwitchAvailable(int swtch, bool invert) {
|
||||
// Check normal switch
|
||||
if (swtch < MAX_SWITCHES * 3) {
|
||||
div_t swinfo = switchInfo(swtch + SWSRC_FIRST_SWITCH);
|
||||
if (swinfo.quot >= switchGetMaxSwitches() + switchGetMaxFctSwitches()) {
|
||||
if (swinfo.quot >= switchGetMaxAllSwitches()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -670,12 +670,9 @@ bool isAssignableFunctionAvailable(int function, bool modelFunctions)
|
||||
case FUNC_DISABLE_AUDIO_AMP:
|
||||
return false;
|
||||
#endif
|
||||
#if !defined(LED_STRIP_GPIO)
|
||||
#if !defined(LED_STRIP_LENGTH)
|
||||
case FUNC_RGB_LED:
|
||||
return false;
|
||||
#elif defined(RGB_LED_OFFSET)
|
||||
case FUNC_RGB_LED:
|
||||
return (LED_STRIP_LENGTH > RGB_LED_OFFSET);
|
||||
#endif
|
||||
#if !defined(DEBUG)
|
||||
case FUNC_TEST:
|
||||
|
||||
Reference in New Issue
Block a user