Skip to content

Commit

Permalink
avoid glitches at relay power-on
Browse files Browse the repository at this point in the history
* switch on relay _after_ the current leds transmission is complete.
  • Loading branch information
softhack007 committed Jan 10, 2025
1 parent c0d8e25 commit 6caa9d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions wled00/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 6 additions & 4 deletions wled00/wled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 6caa9d7

Please sign in to comment.