diff --git a/esp-deckenlicht.ino b/esp-deckenlicht.ino index d7de0ae..704acb1 100644 --- a/esp-deckenlicht.ino +++ b/esp-deckenlicht.ino @@ -19,6 +19,7 @@ int w0; int w1; int w2; int w3; +int w0b, w1b, w2b, w3b; int step = 0; int strobo = 1; bool disco = false; @@ -99,9 +100,19 @@ bool discoHandler(const HomieRange& range, const String& value) { if (value.toInt() == 0) { disco = false; + // Return to previous state + w0 = w0b; + w1 = w1b; + w2 = w2b; + w3 = w3b; + output(); } else { step = 0; + w0b = w0; + w1b = w1; + w2b = w2; + w3b = w3; disco = true; } return true;