Wish NeoPixels Library

Cableguy

Expert
Licensed User
Longtime User
Sure would like a library to control WS2812 LED strips like Adafruit's NeoPixel library. Thanks
Aren't they 1wire devices? Either that or i2c, and they should already be supported, I think
 

Cableguy

Expert
Licensed User
Longtime User
After reading the linked page, I guess it wouldn't be too difficult for someone who can make sense of the accurate timings needed to create a module for the bit-banging... It all comes to setting a pin on and off during the correct amount of time to establish a 1 or 0 bit value...
I could give it s go, but I don't have such LEDs... Yet!
 

Toley

Active Member
Licensed User
Longtime User
After reading the linked page, I guess it wouldn't be too difficult for someone who can make sense of the accurate timings needed to create a module for the bit-banging... It all comes to setting a pin on and off during the correct amount of time to establish a 1 or 0 bit value...
I could give it s go, but I don't have such LEDs... Yet!
If you want my advice don't buy the NeoPixels ones they are far too expensive. Go on Ebay or AliExpress and search for WS2812B you will have a lot of strips of all length available and also leds rings of all size.
 

Robert Gately

Member
Licensed User
I'd be happy to mail some to you.

I hope you succeed in making the library. It will make it possible for me to switch my Arduino projects to B4R.

I'd be happy to beta test.

Good luck!
 

Cableguy

Expert
Licensed User
Longtime User
I will order some and dig a bit on this... but you'll need to be patient with me
 

Robert Gately

Member
Licensed User
Interesting. You may learn all that you need from it.

I have only used individual WS2812B and linear strips. In my (limited) experience, I have powered over 70 of them using 8AA batteries and a 5V regulator. The Adafruit library allowed me to control the brightness and color of each one when they were in a strip form.

Patiently looking forward to your results.
 

Cableguy

Expert
Licensed User
Longtime User
It may take a while for it to get here... in the meantime, post the link to the adafruit lib that you use, maybe someone else will want to take a go at it
 

Toley

Active Member
Licensed User
Longtime User
Hi,

I have already played with NeoPixel or rather APA102 SPI ledstrips. They are much faster than WS2812 "one wire" strips.
You can find the adafruit library (pure arduino) to drive them.

See more here : https://www.b4x.com/android/forum/threads/jg-ledstrip-apa102.50708/
Your leds have the exact same protocol as WS2812

Edit: I don't know why you think they are faster. They surely use the same WS2812B Driver IC. They are mostly used with Adafruit Neopixel. https://github.com/adafruit/Adafruit_NeoPixel
 
Last edited:

freedom2000

Well-Known Member
Licensed User
Longtime User
Your leds have the exact same protocol as WS2812

Edit: I don't know why you think they are faster. They surely use the same WS2812B Driver IC. They are mostly used with Adafruit Neopixel. https://github.com/adafruit/Adafruit_NeoPixel

Oups sorry you are totally right. I read too fast and made the confusion with the "old style" one wire leds (And I did forgot their names)

Sorry for the trouble... APA102 and WS2812 should indeed be the same, with same (fast) speed.
 

Toley

Active Member
Licensed User
Longtime User
Oups sorry you are totally right. I read too fast and made the confusion with the "old style" one wire leds (And I did forgot their names)

Sorry for the trouble... APA102 and WS2812 should indeed be the same, with same (fast) speed.
Finally I believe you are also right. Your leds use 2 wires to talk. They are probably easier and faster to interface since they use real SPI protocol. The problem with NeoPixel is that they must use a full 8bits SPI data to send 1 bit to the display so a total of 24 bytes must be send by the SPI port to address 1 LED. This greatly limit the speed and overuse the AVR. Happily other way exit to talk more easily to those LED strips.
 

freedom2000

Well-Known Member
Licensed User
Longtime User
Finally I believe you are also right. Your leds use 2 wires to talk. They are probably easier and faster to interface since they use real SPI protocol. The problem with NeoPixel is that they must use a full 8bits SPI data to send 1 bit to the display so a total of 24 bytes must be send by the SPI port to address 1 LED. This greatly limit the speed and overuse the AVR. Happily other way exit to talk more easily to those LED strips.

Not totally right !
The SPI can be hardware controlled on the arduino, so that the load on the cpu will be very low. (it's the case on the ESP8266 that I use it the above link)
Furthermore, SPI is clock controlled and the clock can be very fast (depending on the chip of course). That's why I said that SPI ledstrips are much faster than One wire ones (I found the reference which is WS2811)
The WS2811 is a chip, like the APA102, but instead of SPI it uses a purely timing-based serial protocol which is rather slow compared to SPI.
 

JordiCP

Expert
Licensed User
Longtime User
Just the other day I was also wondering if the hardware SPI of the ESP8266 could be used to control the WS2812 in a tricky way. I mean, use HSPI but only connect the data line.

Taking into account "1" and "0" timings, each WS2812 symbol ("1" or "0") could be translated to 3 SPI bits (110 or 100) and with the appropiate SPI clock, let the ESP8266 do the work. I think that setting the clock to 3MHz, it will be about 1usec per WS2812 symbol (bit)
Still much slower than APA102, but no need to do precise time critical routines.
 

Toley

Active Member
Licensed User
Longtime User
Just the other day I was also wondering if the hardware SPI of the ESP8266 could be used to control the WS2812 in a tricky way. I mean, use HSPI but only connect the data line.

Taking into account "1" and "0" timings, each WS2812 symbol ("1" or "0") could be translated to 3 SPI bits (110 or 100) and with the appropiate SPI clock, let the ESP8266 do the work. I think that setting the clock to 3MHz, it will be about 1usec per WS2812 symbol (bit)
Still much slower than APA102, but no need to do precise time critical routines.
NeoPixel works very well with ESP8266
 

freedom2000

Well-Known Member
Licensed User
Longtime User
Just the other day I was also wondering if the hardware SPI of the ESP8266 could be used to control the WS2812 in a tricky way. I mean, use HSPI but only connect the data line.

Taking into account "1" and "0" timings, each WS2812 symbol ("1" or "0") could be translated to 3 SPI bits (110 or 100) and with the appropiate SPI clock, let the ESP8266 do the work. I think that setting the clock to 3MHz, it will be about 1usec per WS2812 symbol (bit)
Still much slower than APA102, but no need to do precise time critical routines.
That's clever Jordi.
Try it and tell us.

But I wonder how you will synchronize CPU and Hardware SPI clock to output each pixel timing ? Unless you prepare a full "frame buffer" containing the exact timings for allthe ledstrip ?

I haven't looked at the precise electrical interface of SPI. Isn't is a "return to 0" of data forced by the clock signal on the MOSI bus ? Said in other words, are you sure that the data value is kept unchanged on the MOSI bus when the clock is changing ? (dashed blue line below)
C0434-Figure3.gif
 
Top