feat: allow Sticky LS state to persist across EM or optionally across reboot (#4978)
This commit is contained in:
@@ -457,6 +457,16 @@ PACK(typedef struct {
|
||||
uint16_t duration:15;
|
||||
}) ls_stay_struct;
|
||||
|
||||
void logicalSwitchesInit(bool force)
|
||||
{
|
||||
for (unsigned int idx=0; idx<MAX_LOGICAL_SWITCHES; idx++) {
|
||||
LogicalSwitchData * ls = lswAddress(idx);
|
||||
if (ls->func == LS_FUNC_STICKY && (force || ls->lsPersist)) {
|
||||
lswFm[mixerCurrentFlightMode].lsw[idx].lastValue = ls->lsState;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool getLogicalSwitch(uint8_t idx)
|
||||
{
|
||||
LogicalSwitchData * ls = lswAddress(idx);
|
||||
@@ -745,6 +755,10 @@ void evalLogicalSwitches(bool isCurrentFlightmode)
|
||||
}
|
||||
}
|
||||
context.state = result;
|
||||
if ((g_model.logicalSw[idx].func == LS_FUNC_STICKY) && (g_model.logicalSw[idx].lsState != result)) {
|
||||
g_model.logicalSw[idx].lsState = result;
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user