Makuna / NeoPixelBus

An Arduino NeoPixel support library supporting a large variety of individually addressable LEDs. Please refer to the Wiki for more details. Please use the GitHub Discussions to ask questions as the GitHub Issues feature is used for bug tracking.
GNU Lesser General Public License v3.0
1.18k stars 264 forks source link

LPD8806 Support #290

Closed MetricsGaming closed 5 years ago

MetricsGaming commented 5 years ago

Is your feature request related to a problem? Please describe. I am trying to integrate the LPD8806 LED strips with WLED. I currently have an existing Hyperion setup dependent on these strips.

Describe the solution you'd like I see that the APA102 with the data pin and clock pin is supported. The timings are a little different then LPD8806. Is there a way to add LPD8806 compatibility as well, instantly making these strips with WLED viable?

Describe alternatives you've considered I have tried using the APA102 to see if it "just worked" and it unfortunately doesn't. Brightness doesn't work and the colors do not matchup. The preset scenes actually seem to kind of work but the colors are all over the place as well. I presume it's because of the mismatch in timings. The other alternative is ripping out the old strips for supported ones, the wife does not approve of that.

Makuna commented 5 years ago

It can be done, but I need a protocol spec sheet. It seems to be elusive/proprietary. I also do not have any of these to test with.

This is the best I have found, which really isn't helpful; and even seems to have conflicting data.

https://cdn-shop.adafruit.com/datasheets/lpd8806+english.pdf

In the general section it states up to 20MHhz clk rate, but in the recommended it states 1-2 MHz!

What platform (AVR, Esp8266, etc) are you using?

The hardware SPI defaults to 20mhz, you modify this line to

SPI.beginTransaction(SPISettings(2000000L, MSBFIRST, SPI_MODE0));

to switch it down to 2mhz and see if that improves things.

Makuna commented 5 years ago

Ok, its more complex than just changing the SPI frequency. It will require some color translation and special "latching" support; as it isn't even close to a APA102. But Adafruit had some code for it. https://github.com/adafruit/LPD8806/blob/master/LPD8806.cpp

MetricsGaming commented 5 years ago

It can be done, but I need a protocol spec sheet. It seems to be elusive/proprietary. I also do not have any of these to test with.

This is the best I have found, which really isn't helpful; and even seems to have conflicting data.

https://cdn-shop.adafruit.com/datasheets/lpd8806+english.pdf

In the general section it states up to 20MHhz clk rate, but in the recommended it states 1-2 MHz!

What platform (AVR, Esp8266, etc) are you using?

The hardware SPI defaults to 20mhz, you modify this line to

SPI.beginTransaction(SPISettings(2000000L, MSBFIRST, SPI_MODE0));

to switch it down to 2mhz and see if that improves things.

Currently I am running a raspberry pi with ubuntu with hyperion installed on it. I want to be able to use and eps8266 chipset. I did purchase the strips from adafruit so it makes sense they have some support code with it. I have my 36 led test strip I could send you? I wonder if looking through the Hyperion code would help? https://github.com/hyperion-project/hyperion I do see what you are talking about in the data sheet. I did find some code where this was set #define DEFAULT_SPI_SPEED 2500000 https://github.com/gkaindl/ambi-tv/tree/master/src/components

Makuna commented 5 years ago

Its faster if I order some. Consider making a donation using the paypal link in the wiki/readme.

MetricsGaming commented 5 years ago

Its faster if I order some. Consider making a donation using the paypal link in the wiki/readme.

If that's faster easier, not a problem, it's done.

Makuna commented 5 years ago

Do you know the color order of the strip that you have? It seems most hard code to GRB order.

Makuna commented 5 years ago

https://github.com/Makuna/NeoPixelBus/pull/291 My Lpd886 Strip showed up. Even Adafruits old code didn't work well beyond 32 pixels, they didn't have the protocol correct. for bitbang, declare your strip like...

NeoPixelBus<Lpd8806BrgFeature, Lpd8806Method> strip(PixelCount, DotClockPin, DotDataPin);

for SPI, declare your strip like...

// hardware SPI support often has hard coded pins, so no need to pass them in
NeoPixelBus<Lpd8806BrgFeature, Lpd8806SpiMethod> strip(PixelCount); 

Let me know if your color order is not supported, I only added two for now, Grb and Brg. Mine were Brg. You can use the DotStartTest sample and modify the constructor to confirm.
NOTE: Adjust the strip count, if you set it to less than you have with DotStars or these, the pixel after the last one you defined will light up white'ish.

You can copy the repo directly into your installed version to get the latest. I will put out a new release in the next few days.

MetricsGaming commented 5 years ago

Do you know the color order of the strip that you have? It seems most hard code to GRB order.

Mine are BRG

MetricsGaming commented 5 years ago

291

My Lpd886 Strip showed up. Even Adafruits old code didn't work well beyond 32 pixels, they didn't have the protocol correct. for bitbang, declare your strip like...

NeoPixelBus<Lpd8806BrgFeature, Lpd8806Method> strip(PixelCount, DotClockPin, DotDataPin);

for SPI, declare your strip like...

// hardware SPI support often has hard coded pins, so no need to pass them in
NeoPixelBus<Lpd8806BrgFeature, Lpd8806SpiMethod> strip(PixelCount); 

Let me know if your color order is not supported, I only added two for now, Grb and Brg. Mine were Brg. You can use the DotStartTest sample and modify the constructor to confirm. NOTE: Adjust the strip count, if you set it to less than you have with DotStars or these, the pixel after the last one you defined will light up white'ish.

You can copy the repo directly into your installed version to get the latest. I will put out a new release in the next few days.

First of all thank you for your quick work, you have some fast shipping. I was surprised you got the LED strips so fast hence why there was a lapse in checking in sooner, sorry.

I have not been able to get bitbang or SPI to change the colors on the strip in the DotStarTest. I changed the 2 lines your have above in the DotStarTest.ino, am i missing something more? In the serial monitor I can see the expected output, just not reflected on the strips. I changed the pin out to match the wiring on my nodemcu and pixel count to 36 DotClockPin = 0; DotDataPin = 2; edit: forgot to mention I also updated your library to 2.5.2 in the Arduino IDE edit 2: I re-uploaded the sketch, with bitbang again, SPI just doesn't work or I am doing it wrong, brightness 20, and it appears to work now, only the first 4 pixels are lighting up (I think that is working as intended since I don't see a loop or array that would show pixels 0-35) but they are in the right order. On my rPi Hyperion setup I am using SPI.

Makuna commented 5 years ago

If you use SPI (hardware) on most Arduino's then those are not the right pins, the pins you pass are ignored and the hardware defined pins are used. The pins are dependant on the hardware.
Define = Description = Board Label SCK = SPI Clock = Esp8266 Pin Labeled Clk, SCK, SPI_Clk, GPIO6 MOSI = SPI Data Out = Esp8266 Pin Labeled SPI_Mosi, GPIO8 For Esp32, you can define the hardware pins, but you must pass pins to the Begin call like...

strip.Begin(SCK, MISO, MOSI, SS);

Even though only SCK and MOSI are required; the SPI requires the others.

Makuna commented 5 years ago

This should now be in the released version