avoid glitches at relay power-on

* switch on relay _after_ the current leds transmission is complete.
This commit is contained in:
Frank
2025-01-10 12:49:46 +01:00
parent c0d8e256ae
commit 6caa9d78b8
2 changed files with 7 additions and 4 deletions

View File

@@ -389,6 +389,7 @@ void handleIO()
esp32RMTInvertIdle(); esp32RMTInvertIdle();
#endif #endif
if (rlyPin>=0) { if (rlyPin>=0) {
if (strip.isUpdating()) delay(FRAMETIME_FIXED); // WLEDMM avoids randomly colored pixles at power-on
pinMode(rlyPin, OUTPUT); pinMode(rlyPin, OUTPUT);
digitalWrite(rlyPin, !rlyMde); digitalWrite(rlyPin, !rlyMde);
} }

View File

@@ -893,10 +893,10 @@ void WLED::setup()
void WLED::beginStrip() void WLED::beginStrip()
{ {
// Initialize NeoPixel Strip and button // Initialize NeoPixel Strip and button
strip.fill(BLACK); // WLEDMM avoids random colors at power-on
strip.finalizeInit(); // busses created during deserializeConfig() strip.finalizeInit(); // busses created during deserializeConfig()
strip.makeAutoSegments(); strip.makeAutoSegments();
strip.setBrightness(0); strip.setBrightness(0, true); // WLEDMM directly apply BLACK (no transition time)
strip.fill(BLACK); // WLEDMM avoids random colors at power-on
strip.setShowCallback(handleOverlayDraw); strip.setShowCallback(handleOverlayDraw);
if (turnOnAtBoot) { if (turnOnAtBoot) {
@@ -915,9 +915,11 @@ void WLED::beginStrip()
// init relay pin // init relay pin
if (rlyPin>=0) { 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)); 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);
} }
} }