Skip to content

Commit

Permalink
added a delay after switching relay (#4474)
Browse files Browse the repository at this point in the history
- helps to stabilize power on the LEDs before sending data
  • Loading branch information
DedeHai authored Jan 9, 2025
1 parent 709aeff commit bb0c0af
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions wled00/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ void handleIO()
if (rlyPin>=0) {
pinMode(rlyPin, rlyOpenDrain ? OUTPUT_OPEN_DRAIN : OUTPUT);
digitalWrite(rlyPin, rlyMde);
delay(50); // wait for relay to switch and power to stabilize

This comment has been minimized.

Copy link
@blazoncek

blazoncek Jan 10, 2025

Collaborator

Not a good approach IMO. This will add 50ms delay in everything WLED does within loop().
True, this will only happen on power on but I still think adding delay() is inappropriate in a multitasking approach WLED has.

This comment has been minimized.

Copy link
@DedeHai

DedeHai Jan 10, 2025

Author Collaborator

agreed. what would be a better solution? I had another approach with a delay variable but it was way more complex: additional checks, global/static variable etc. just to make it non-blocking.
maybe the whole relay handling/state change/bootup needs a make-over...

This comment has been minimized.

Copy link
@blazoncek

blazoncek Jan 10, 2025

Collaborator

Async operation in strip.service() or the part where it is invoked.

This comment has been minimized.

Copy link
@DedeHai

DedeHai Jan 10, 2025

Author Collaborator

I don't think convoluting relay operation with strip service is any better...

}
offMode = false;
}
Expand Down

0 comments on commit bb0c0af

Please sign in to comment.