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
@@ -154,7 +154,7 @@ void evalFunctions(CustomFunctionData * functions, CustomFunctionsContext & func
|
||||
MASK_FUNC_TYPE newActiveFunctions = 0;
|
||||
MASK_CFN_TYPE newActiveSwitches = 0;
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
functionSwitchFunctionState = 0;
|
||||
g_model.cfsResetSFState();
|
||||
#endif
|
||||
|
||||
uint8_t playFirstIndex = (functions == g_model.customFn ? 1 : 1+MAX_SPECIAL_FUNCTIONS);
|
||||
@@ -386,14 +386,13 @@ void evalFunctions(CustomFunctionData * functions, CustomFunctionsContext & func
|
||||
if (CFN_PARAM(cfn)) { // Duration is set
|
||||
if (! CFN_VAL2(cfn) ) { // Duration not started yet
|
||||
CFN_VAL2(cfn) = timersGetMsTick() + CFN_PARAM(cfn) * 100;
|
||||
functionSwitchFunctionState |= 1 << CFN_CS_INDEX(cfn);
|
||||
}
|
||||
else if (timersGetMsTick() < (uint32_t)CFN_VAL2(cfn) ) { // Still within push duration
|
||||
functionSwitchFunctionState |= 1 << CFN_CS_INDEX(cfn);
|
||||
g_model.cfsSetSFState(CFN_CS_INDEX(cfn), 1);
|
||||
} else if (timersGetMsTick() < (uint32_t)CFN_VAL2(cfn) ) { // Still within push duration
|
||||
g_model.cfsSetSFState(CFN_CS_INDEX(cfn), 1);
|
||||
}
|
||||
} else { // No duration set
|
||||
g_model.cfsSetSFState(CFN_CS_INDEX(cfn), 1);
|
||||
}
|
||||
else // No duration set
|
||||
functionSwitchFunctionState |= 1 << CFN_CS_INDEX(cfn);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -473,7 +472,7 @@ void evalFunctions(CustomFunctionData * functions, CustomFunctionsContext & func
|
||||
if (CFN_FUNC(cfn) == FUNC_PUSH_CUST_SWITCH) {
|
||||
// Handling duration after function is active
|
||||
if (timersGetMsTick() < (uint32_t)CFN_VAL2(cfn)) {
|
||||
functionSwitchFunctionState |= 1 << CFN_CS_INDEX(cfn);
|
||||
g_model.cfsSetSFState(CFN_CS_INDEX(cfn), 1);
|
||||
}
|
||||
else {
|
||||
CFN_VAL2(cfn) = 0;
|
||||
|
||||
Reference in New Issue
Block a user