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