From 4457067045707b54558a298cd6daa4df8f5caf41 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sat, 10 Feb 2024 11:45:33 +0100 Subject: [PATCH] Multiple analog button fix for #3549 --- wled00/button.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wled00/button.cpp b/wled00/button.cpp index 60df15eb6..c1d033766 100644 --- a/wled00/button.cpp +++ b/wled00/button.cpp @@ -226,11 +226,11 @@ void handleAnalog(uint8_t b) void handleButton() { - static unsigned long lastRead = 0UL; + static unsigned long lastAnalogRead = 0UL; static unsigned long lastRun = 0UL; unsigned long now = millis(); - if (strip.isUpdating() && (now - lastRun < 400)) return; // don't interfere with strip update (unless strip is updating continuously, e.g. very long strips) + if (strip.isUpdating() && (now - lastRun < ANALOG_BTN_READ_CYCLE+1)) return; // don't interfere with strip update (unless strip is updating continuously, e.g. very long strips) lastRun = now; for (uint8_t b=0; b ANALOG_BTN_READ_CYCLE) { + if (now - lastAnalogRead > ANALOG_BTN_READ_CYCLE) { handleAnalog(b); - lastRead = now; } continue; } @@ -325,6 +324,9 @@ void handleButton() shortPressAction(b); } } + if (now - lastAnalogRead > ANALOG_BTN_READ_CYCLE) { + lastAnalogRead = now; + } } // If enabled, RMT idle level is set to HIGH when off