From 6caa9d78b8a1042b264d47800817ca9185acbf33 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 10 Jan 2025 12:49:46 +0100 Subject: [PATCH] avoid glitches at relay power-on * switch on relay _after_ the current leds transmission is complete. --- wled00/button.cpp | 1 + wled00/wled.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/wled00/button.cpp b/wled00/button.cpp index fd6a8754..7cfb1264 100644 --- a/wled00/button.cpp +++ b/wled00/button.cpp @@ -389,6 +389,7 @@ void handleIO() esp32RMTInvertIdle(); #endif if (rlyPin>=0) { + if (strip.isUpdating()) delay(FRAMETIME_FIXED); // WLEDMM avoids randomly colored pixles at power-on pinMode(rlyPin, OUTPUT); digitalWrite(rlyPin, !rlyMde); } diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 85f22060..6d5c0f28 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -893,10 +893,10 @@ void WLED::setup() void WLED::beginStrip() { // Initialize NeoPixel Strip and button + strip.fill(BLACK); // WLEDMM avoids random colors at power-on strip.finalizeInit(); // busses created during deserializeConfig() strip.makeAutoSegments(); - strip.setBrightness(0); - strip.fill(BLACK); // WLEDMM avoids random colors at power-on + strip.setBrightness(0, true); // WLEDMM directly apply BLACK (no transition time) strip.setShowCallback(handleOverlayDraw); if (turnOnAtBoot) { @@ -915,9 +915,11 @@ void WLED::beginStrip() // init relay pin if (rlyPin>=0) { - delay(FRAMETIME_FIXED); // WLEDMM wait a bit, to ensure that no background led communication is happening while powering on the strip + if (strip.isUpdating()) delay(FRAMETIME_FIXED); // WLEDMM ensure that no background led communication is happening while powering on the strip digitalWrite(rlyPin, (rlyMde ? bri : !bri)); - delay(50); // wait for relay to switch and power to stabilize + delay(75); // wait for relay to switch and power to stabilize + strip.show(); // update LEDs + delay(5); } }