Fixes #4136 - Reset all logical switch fields on change of function type - By @elecpower

This commit is contained in:
Bertrand Songis
2017-03-02 20:24:01 +01:00
parent 40dae8a8a7
commit d724ec1128
4 changed files with 22 additions and 21 deletions
@@ -445,7 +445,17 @@ void menuModelLogicalSwitches(event_t event)
CHECK_INCDEC_MODELVAR_ZERO(event, cs->func, LS_FUNC_MAX);
uint8_t new_cstate = lswFamily(cs->func);
if (cstate != new_cstate) {
cs->v1 = cs->v2 = (new_cstate==LS_FAMILY_TIMER ? -119/*1.0*/ : 0);
#if defined(CPUARM)
unsigned int save_func = cs->func;
memset(cs, 0, sizeof(LogicalSwitchData));
cs->func = save_func;
#else
cs->v1 = cs->v2 = 0;
cs->andsw = 0;
#endif
if (new_cstate == LS_FAMILY_TIMER) {
cs->v1 = cs->v2 = -119; // 1.0
}
}
break;
}