fix: Invalid 'active' state of Sticky LS when no source set (#1430)

* The set/reset switches for a logical switch are only processed if the are valid.

* added coment

* Move / elaborate on comment

Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
Wilhelm
2022-02-27 11:37:32 +10:00
committed by GitHub
co-authored by Peter Feerick
parent 0391174e06
commit 79e0a212e7
+4
View File
@@ -908,6 +908,7 @@ void logicalSwitchesTimerTick()
ls_sticky_struct & lastValue = (ls_sticky_struct &)LS_LAST_VALUE(fm, i); ls_sticky_struct & lastValue = (ls_sticky_struct &)LS_LAST_VALUE(fm, i);
bool before = lastValue.last & 0x01; bool before = lastValue.last & 0x01;
if (lastValue.state) { if (lastValue.state) {
if (ls->v2 != SWSRC_NONE) { // only if used / source set
bool now = getSwitch(ls->v2); bool now = getSwitch(ls->v2);
if (now != before) { if (now != before) {
lastValue.last ^= 1; lastValue.last ^= 1;
@@ -916,7 +917,9 @@ void logicalSwitchesTimerTick()
} }
} }
} }
}
else { else {
if (ls->v1 != SWSRC_NONE) { // only if used / source set
bool now = getSwitch(ls->v1); bool now = getSwitch(ls->v1);
if (before != now) { if (before != now) {
lastValue.last ^= 1; lastValue.last ^= 1;
@@ -926,6 +929,7 @@ void logicalSwitchesTimerTick()
} }
} }
} }
}
else if (ls->func == LS_FUNC_EDGE) { else if (ls->func == LS_FUNC_EDGE) {
ls_stay_struct & lastValue = (ls_stay_struct &)LS_LAST_VALUE(fm, i); ls_stay_struct & lastValue = (ls_stay_struct &)LS_LAST_VALUE(fm, i);
// if this ls was reset by the logicalSwitchesReset() the lastValue will be set to CS_LAST_VALUE_INIT(0x8000) // if this ls was reset by the logicalSwitchesReset() the lastValue will be set to CS_LAST_VALUE_INIT(0x8000)