Left for archival purposes.

User avatar
By flokli
#10857 Hey!

I wanted to use the esp as an Art-Net bridge, accepting UDP Packets with RGB values, but by using only Lua, the esp was too slow to do the conversion at a high frame rate. As everybody would expect RGB anyway, I changed the ws2812 driver to accept colors in RGB form ;-) It simply sends the red channel before the blue green one on-the-fly, no copies involved :-)

As the ws2812 module is not yet enabled by default, I think it'd be fine to "break" the old behaviour to get a more consistent api.

The pull request can be found here:
https://github.com/nodemcu/nodemcu-firmware/pull/250
User avatar
By Markus Gritsch
#11024 @flokli: Please delete your pull request, it breakes the WS2812 timing.

It took quite some time and experimentation to get the timing right, for all possible combinations of the values sent and used compiler optimization settings. Every change to this code has to be checked carfully with a logic analyzer or scope.

I would not mind changing the byte order to RGB, but the way you've done it breakes the timing. Here is the output with your changes when setting two LEDs to black with
Code: Select allws2812.write(4, string.char(0, 0, 0):rep(2))

snapshot.png

As can be seen, the first pulse gets stretched and is thus interpreted as a logic 1 which yields to a value of 128 for green instead of 0:
IMG_4425_1600x1200_85.jpg

Feel free to use your modified firmware for your needs, but please do not break the code in the master branch.

Thanks,
Markus
User avatar
By flokli
#11027 @Markus Gritsch: You're right. I thought the led was broken somehow, and for this reason green.
I will try to fix the timing before I reopen the pull-request.
User avatar
By Markus Gritsch
#11031 Thanks. And please do really verify your changes with a simple scope or a cheap LA and make sure, the timing does not change. Merely "LEDs seem to work for me" is not enough, due to different LEDs being more or less sensitive to border-line timings :)

And keep in mind that due to compiler optimizations it might make a difference if you send a 0 or a 1 as the first value, and also if it is the first time the code is called after a reset, or if you just check subsequent calls (caching).

Be careful and rather do not make a pull request if you don't have the tools to check the timings. Things get too easily broken otherwise.