Using Xojo to control WLED addressable leds (EN)

Gepubliceerd op 6 november 2023 om 14:16

Here's a short demo of WLEDRealtime if you've not seen it yet:

For a customer we wanted to develop a set of classes that allowed us to control WLED controllers via the realtime UDP api of WLED.

If you dont know what WLED is, click here to see a basic video. In short WLED is an Open Source firmware to control smart addressable led strips those called "neopixel", "ws2811", "ws2812", "ws2812b" etc. A WLED controller is mostly based on an ESP32 or similar ESP chipset, that controls these leds (pixels) individually, via HTTP, UDP, Serial, MQTT, Network DMX etc. you name it can wled can probably do it. 

Back to the Xojo classes, we wanted realtime control so we could do the effects (FX) directly from within Xojo instead of using the WLED provided effects.

Yes you guessed it, WLED has probably 100's of effects already in their firmware, you could use those via Xojo using the WLED JSON HTTP API, but we didn't implement this as we needed Realtime (UDP). 

We decided to use a Thread in our WLEDRealtime class to execute the events, this is because we can have some control over the delays between the packets. Since UDP is connection-less there is a chance of packet-loss, in our local tests we have only see this a few times but this depends on your network setup. We use a Raspberry Pi as the access point for the WLED WiFi, i will not be getting in to this right now.  Since Christmas is coming closer we decided to bring the classes available to the public, so that anyone can control it's Christmas lights right from within Xojo! 

Looking at the code we have a few things to note.

We mostly use Unicast to send packets to a single WLED controller, but we are able to send to multiple WLED controllers eighter with multiple WLEDDevice class instances or by using a single WLEDDevice instance and setting broadcast = true this way the WLEDRealtime class would automaticly use the broadcast address of the UDP chosen network interface. There is always the possibility to set the address yourself so you could set any broadcast/multicast/unicast address as you wish. The port however must match UDP Port or the 2nd UDP Port of the WLED controller(s) you want to control. 

If you already have an WLED Controller, then that's great you can start using the example directly! 

We will keep this set of classes in development so from time to time you'll see new effects and features coming to these classes.

Are you ready for some spectaculair coding, you can order a perpetual license here:

Source Code License Agreement

Order the classes here (by ordering you agree to the license agreement):

If you are a business, please mark your order as business trough the ordering form.

Moneybird ( is our payment provider.



Reactie plaatsen


Er zijn geen reacties geplaatst.