feat: allow Sticky LS state to persist across EM or optionally across reboot (#4978)

This commit is contained in:
philmoz
2024-06-02 16:22:36 +10:00
committed by GitHub
parent 0399858a76
commit b16524837a
26 changed files with 121 additions and 46 deletions
+14
View File
@@ -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);
}
}
}