Hi all,
I've started work on a ESP32 library for driving addressable LEDs. Right now it relies on bit-banging using noploops, but with the RMT library now released, I am planning on focusing to migrate over to that as soon as possible.
I expect the interface to stay the same, but a great amount of work will be done in the led_strip.c file to use the RMT library.
Github is located here: https://github.com/Lucas-Bruder/ESP32_LED_STRIP
Please feel free to contact me with feedback and suggestions. Code isn't the prettiest right now, just wanted to focus on getting it working. If you would like to collaborate on it with me, please let me know!
Lucas
ESP32 WS2812B library
Re: ESP32 WS2812B library
Haven't seen that, thanks for sharing! Will definitely be useful when switching over to RMT on my library, the library for RMT is very overwhelming right nowWiFive wrote:Have you seen https://github.com/FozzTexx/ws2812-demo
But the more the merrier! Thanks for sharing
Re: ESP32 WS2812B library
Back in October there was a post that first gave reference to using RMT as the driver for NeoPixels (what I will refer to as generic WS2812s) ... that post was found here ... http://esp32.com/viewtopic.php?f=13&t=293.
It is only in the last couple of weeks that drivers for RMT have been released. Combine these with the ESP32 technical reference and the light bulb (figuratively and now literally has come on). I am delighted to report that I used the RMT driver library from C to control timings. By my calculation, the maximum possible resolution is 12.5 nano seconds. For our NeoPixels, the smallest interval we need is 350ns so we are well within specs. I found that having a cheap logic analyzer was invaluable as I could trivially visualize the signals on the output. My analyzer has a max recording rate of 24MHz which means that (in principle) it is accurate to ~50ns which is still in the correct order of being useful for NeoPixels.
I set the clock divisor to be 8 ... which effectively gives me a resolution of 100ns. I was able to set the duration to 1 and measure a length of 100ns, I then set it to 2 and measured 200ns etc etc ...
From there it was all plain sailing and I was able to control the NeoPixel without issue. Again, this is using the RMT driver library. One of the advantages of the driver library that I believe exists is that it takes care of buffer management for us. Since the RMT only has a finite amount of buffer space to hold its current stream of output, an interrupt can fire before the buffer is consumed fully so that it is "replenished" in the background. I "believe" this is handled by the driver library.
Because my sub-hobby of choice is JavaScript, I then added an RMT module to my JavaScript runtime for the ESP32 based on Duktape. This allows me to drive RMT at a high level. For example
Here I pass in an array of JS objects where each object contains a level and a duration ... the function takes care of driving the RMT drivers correctly passing in the correct data.
With this RMT driver in place, I was able to easily map a NeoPixel abstraction on top of this.
It is only in the last couple of weeks that drivers for RMT have been released. Combine these with the ESP32 technical reference and the light bulb (figuratively and now literally has come on). I am delighted to report that I used the RMT driver library from C to control timings. By my calculation, the maximum possible resolution is 12.5 nano seconds. For our NeoPixels, the smallest interval we need is 350ns so we are well within specs. I found that having a cheap logic analyzer was invaluable as I could trivially visualize the signals on the output. My analyzer has a max recording rate of 24MHz which means that (in principle) it is accurate to ~50ns which is still in the correct order of being useful for NeoPixels.
I set the clock divisor to be 8 ... which effectively gives me a resolution of 100ns. I was able to set the duration to 1 and measure a length of 100ns, I then set it to 2 and measured 200ns etc etc ...
From there it was all plain sailing and I was able to control the NeoPixel without issue. Again, this is using the RMT driver library. One of the advantages of the driver library that I believe exists is that it takes care of buffer management for us. Since the RMT only has a finite amount of buffer space to hold its current stream of output, an interrupt can fire before the buffer is consumed fully so that it is "replenished" in the background. I "believe" this is handled by the driver library.
Because my sub-hobby of choice is JavaScript, I then added an RMT module to my JavaScript runtime for the ESP32 based on Duktape. This allows me to drive RMT at a high level. For example
Code: Select all
RMT.write(channel, [{level: true, duration: 13}, {level: false, duration: 4}]);
With this RMT driver in place, I was able to easily map a NeoPixel abstraction on top of this.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: ESP32 WS2812B library
Awesome, this information definitely helps. After more investigation today, it looks like I'll be using the rmt_write_items function; seems like the easiest way to get the strips working with minimal effort. Don't have a logic analyzer with me currently, so right now I'm doing guess and check :/ If I can't figure it out this way, things will pick up once I get back to work and have access to an oscope.kolban wrote:Back in October there was a post that first gave reference to using RMT as the driver for NeoPixels (what I will refer to as generic WS2812s) ... that post was found here ... http://esp32.com/viewtopic.php?f=13&t=293.
It is only in the last couple of weeks that drivers for RMT have been released. Combine these with the ESP32 technical reference and the light bulb (figuratively and now literally has come on). I am delighted to report that I used the RMT driver library from C to control timings. By my calculation, the maximum possible resolution is 12.5 nano seconds. For our NeoPixels, the smallest interval we need is 350ns so we are well within specs. I found that having a cheap logic analyzer was invaluable as I could trivially visualize the signals on the output. My analyzer has a max recording rate of 24MHz which means that (in principle) it is accurate to ~50ns which is still in the correct order of being useful for NeoPixels.
I set the clock divisor to be 8 ... which effectively gives me a resolution of 100ns. I was able to set the duration to 1 and measure a length of 100ns, I then set it to 2 and measured 200ns etc etc ...
From there it was all plain sailing and I was able to control the NeoPixel without issue. Again, this is using the RMT driver library. One of the advantages of the driver library that I believe exists is that it takes care of buffer management for us. Since the RMT only has a finite amount of buffer space to hold its current stream of output, an interrupt can fire before the buffer is consumed fully so that it is "replenished" in the background. I "believe" this is handled by the driver library.
Because my sub-hobby of choice is JavaScript, I then added an RMT module to my JavaScript runtime for the ESP32 based on Duktape. This allows me to drive RMT at a high level. For example
Here I pass in an array of JS objects where each object contains a level and a duration ... the function takes care of driving the RMT drivers correctly passing in the correct data.Code: Select all
RMT.write(channel, [{level: true, duration: 13}, {level: false, duration: 4}]);
With this RMT driver in place, I was able to easily map a NeoPixel abstraction on top of this.
I would like to get my RMT branch merged in by Friday at the latest. In addition to the led_strip functions, I plan on adding led_wall and led_room libraries so a user can do some cool animations in their rooms where the strip may cover multiple corners on multiple walls in a room.
If anyone would like to contribute, please reach out to me at lbruder@me.com! Could use some help writing some cool animations for people to use
Re: ESP32 WS2812B library
If anyone has some time, would appreciate help with the library
Right now, only the first light is blinking a yellowish color. I haven't been able to get any other leds to light up. Checked out master and everything from that branch still functions correctly with bit-banging, so I know it's not the led strip.
I noticed the IR example doesn't set the duration to '0' at the end to signal the last rtm_item. When I don't add a 0 for the last duration, I've noticed that it takes a good amount longer to finish sending verses adding the 0 packet at the end of the rtm_item array.
https://github.com/Lucas-Bruder/ESP32_L ... rmt_driver
Thank you for any help!
Right now, only the first light is blinking a yellowish color. I haven't been able to get any other leds to light up. Checked out master and everything from that branch still functions correctly with bit-banging, so I know it's not the led strip.
I noticed the IR example doesn't set the duration to '0' at the end to signal the last rtm_item. When I don't add a 0 for the last duration, I've noticed that it takes a good amount longer to finish sending verses adding the 0 packet at the end of the rtm_item array.
https://github.com/Lucas-Bruder/ESP32_L ... rmt_driver
Thank you for any help!
Re: ESP32 WS2812B library
My opinion is that without a logic analyzer (for example : http://www.ebay.com/itm/24MHz-8-Channel ... 1685084604) you are working with your eyes closed. I can't stress strongly enough how useful such a tool is married with the skills to use it. If you had one of these you would be able to exactly see the timing pulses sent to the Data IN of your first NeoPixel and, by experience, from there all else fits together. While I realize you may not have one today ... I'd suggest ordering one on-line and then be patient till it arrives.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: ESP32 WS2812B library
You're absolutely right, I'm just being impatientkolban wrote:My opinion is that without a logic analyzer (for example : http://www.ebay.com/itm/24MHz-8-Channel ... 1685084604) you are working with your eyes closed. I can't stress strongly enough how useful such a tool is married with the skills to use it. If you had one of these you would be able to exactly see the timing pulses sent to the Data IN of your first NeoPixel and, by experience, from there all else fits together. While I realize you may not have one today ... I'd suggest ordering one on-line and then be patient till it arrives.
Edit: Figured it out, silly array indexing bug
Who is online
Users browsing this forum: No registered users and 63 guests