From 79e0a212e7235874976270aeff27fe0559313faf Mon Sep 17 00:00:00 2001 From: Wilhelm Date: Sun, 27 Feb 2022 02:37:32 +0100 Subject: [PATCH] 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 --- radio/src/switches.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/radio/src/switches.cpp b/radio/src/switches.cpp index 9a8fc7182..736938b8a 100644 --- a/radio/src/switches.cpp +++ b/radio/src/switches.cpp @@ -908,22 +908,26 @@ void logicalSwitchesTimerTick() ls_sticky_struct & lastValue = (ls_sticky_struct &)LS_LAST_VALUE(fm, i); bool before = lastValue.last & 0x01; if (lastValue.state) { - bool now = getSwitch(ls->v2); - if (now != before) { - lastValue.last ^= 1; - if (!before) { - lastValue.state = 0; + if (ls->v2 != SWSRC_NONE) { // only if used / source set + bool now = getSwitch(ls->v2); + if (now != before) { + lastValue.last ^= 1; + if (!before) { + lastValue.state = 0; + } + } } - } } else { - bool now = getSwitch(ls->v1); - if (before != now) { - lastValue.last ^= 1; - if (!before) { - lastValue.state = 1; + if (ls->v1 != SWSRC_NONE) { // only if used / source set + bool now = getSwitch(ls->v1); + if (before != now) { + lastValue.last ^= 1; + if (!before) { + lastValue.state = 1; + } + } } - } } } else if (ls->func == LS_FUNC_EDGE) {