WS2812 LED Flexible 32 x 8 grid

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

mnf
Valued Contributor
Valued Contributor
Posts: 552
Joined: Wed May 31, 2017 11:57 am
Has thanked: 54 times
Been thanked: 310 times
Contact:

WS2812 LED Flexible 32 x 8 grid

Postby mnf » Sun Dec 01, 2019 6:53 pm

I was lucky enough to be given a 32 x 8 grid of WS2812 LEDs to play with.
(For example https://www.amazon.co.uk/Flexible-Indiv ... -4-catcorr)

This is a 'searingly' bright and very colourful display - so I thought I'd do a 'Christmas' display (more fundraising!)

I got it working with an Arduino (Nano - cheap clone) - which, surprisingly, manages to power the display from it's 5v pin. (A separate power supply is probably a good idea here though!)

First task was a scrolling text - based heavily on the MAX7219 code...

LightBoard.fcfx
(48.15 KiB) Downloaded 3 times

Then - a couple of effects - I added two TheatreChase routines based on the Adafruit demo (for NeoPixel strands) and a scrolling 'Rainbow' effect. Also a 'FadeToBlack'. There is a 'static' rainbow which needs some work.

- But, I'd like more - any suggestions for (easy) transitions/effects - or (much) better - implementations of transitions
or effects :)

Note that the code does simulate (although it doesn't run as fast as on an Arduino) - the output (esp. text) on the FC 2d panel looks a bit 'faded'. I used a dimmer colour here - because the display is painfully bright to look at.... Due to a bug in the scroll routine in the WS281x component it only works at full brightness (till Ben fixes the component - pretty please)
There is also a slight bug - on the Arduino the 'rainbow' is different (and incorrect) - red dominates more than it should...

Note - the display size is currently hardcoded as 32 * 8 (bad) - but an Arduino probably can't cope with a much bigger display (the buffer for this is 768 bytes). I'd like to add an SD card reader - to display 'bitmap' images. Should be room (512 byte buffer needed for SD reads)

Martin
These users thanked the author mnf for the post (total 3):
medelec35 (Sun Dec 01, 2019 11:31 pm) • jgu1 (Mon Dec 02, 2019 1:12 pm) • STibor (Tue Dec 03, 2019 3:06 am)
Rating: 15.79%
 

User avatar
Benj
Matrix Staff
Posts: 14363
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4444 times
Been thanked: 4144 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby Benj » Wed Dec 04, 2019 11:45 am

Hello,

The WS2812 LEDs are great fun. I've been playing around with this in my spare time and I'll try and make a video soon to show off what it can actually do.

https://www.amazon.co.uk/ANIGHT-Animate ... B081M6GXZ4

Note that the code does simulate (although it doesn't run as fast as on an Arduino) - the output (esp. text) on the FC 2d panel looks a bit 'faded'. I used a dimmer colour here - because the display is painfully bright to look at


I had the same problem so used the IsSim component to decide if it's the simulation or not to allow me to easily dim the hardware but the simulation remains full brightness.

Due to a bug in the scroll routine in the WS281x component it only works at full brightness (till Ben fixes the component - pretty please)


Can you show me an easy way to try and replicate this bug, I'm not aware of it. You may also want to check you are using the latest version of the component as there have been some recent changes to brightness and how this works. Hopefully the problem is already fixed :)

There is also a slight bug - on the Arduino the 'rainbow' is different (and incorrect) - red dominates more than it should...


I beleive the red LED has a slightly higher luminosity to the other two colours. Are you using the WS2812 or the WS2812B devices? The link you sent suggests the newer B version. Not sure if there is much we can do about this without scaling down the red colour channel in software.

mnf
Valued Contributor
Valued Contributor
Posts: 552
Joined: Wed May 31, 2017 11:57 am
Has thanked: 54 times
Been thanked: 310 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby mnf » Wed Dec 04, 2019 1:06 pm

Hi Ben,

I've PMd you with details of the bug...

Martin
These users thanked the author mnf for the post:
Benj (Wed Dec 04, 2019 1:40 pm)
Rating: 5.26%
 

User avatar
Benj
Matrix Staff
Posts: 14363
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4444 times
Been thanked: 4144 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby Benj » Wed Dec 04, 2019 1:53 pm

Hi Martin,

Shift LEDs does get the scaled colour value and attempts to re-scale back up to original. However I can see this may lead to a gradual fade as the original full depth value has been lost. Hmm not sure what I can do about this?

For example lets say brightness is 128 or 0.5

A value of 200 would get scaled down to ( 200 * 12 7) >> 8 = 99.
Then when reading back the value we would end up with ( 99 << 8 ) / 127 = 199

I'm sure there are worse case situations. Maybe I can round up rather than down? This may then have the opposite effect of making things brighter :D

I'll see if there is a way for the shift macros to bypass the brightness calculations so we are just taking the values and moving them as is. Might use a bit more ROM but should end up running faster.

Edit, think I've solved the problem for you now. New component is now on the update system and may even use less ROM :D It should certainly run faster. Rolling the fix out to the other smart LED components now.

Also forgot about the disabled code, yes this is either other chips or other LED types, basically any code that isn't needed on your current configuration.
These users thanked the author Benj for the post:
mnf (Wed Dec 04, 2019 7:07 pm)
Rating: 5.26%
 

mnf
Valued Contributor
Valued Contributor
Posts: 552
Joined: Wed May 31, 2017 11:57 am
Has thanked: 54 times
Been thanked: 310 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby mnf » Wed Dec 04, 2019 7:06 pm

Thanks Ben,

I've added a scrolling sinewave routine - and works ok in simulation. Out this evening so can't test on hardware till tomorrow...

Couple of other ideas:

Colour swap: Allow colour cycling 'animation'
Using an old technique - and would require rewriting the Ws281x component - would be to have a colour 'lookup table' - each colour in the display buffer would then be 4 or 8 bits (16 or 256 colours allowed) This would use a lot less memory and allow larger displays. I'm not sure my eyes can resolve 256*256*256 colours in the LEDs!

I found a an eeprom breakout - to provide storage for 'bitmaps'. (24LC256 or similar - 256k bits or 32k bytes). The FC component doesn't provide much support above a very basic read/write byte.

So I wrote a short test to use the block read/write functions of the eeprom. Anyone brave/foolish enough to test (I'd probably pull it to a (barebones) component but at present it is a standalone program) Feedback or ideas on the interface I've chosen?? Probably should pull it to a new thread - but for the moment I'll post it here.... Works well with the limited tests I've tried..

eeprom.fcfx
(22.53 KiB) Not downloaded yet

LightBoard.fcfx
(51.81 KiB) Not downloaded yet
(Just testing a (low res) sinewave scroll)

Martin

User avatar
Benj
Matrix Staff
Posts: 14363
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4444 times
Been thanked: 4144 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby Benj » Thu Dec 05, 2019 10:41 am

Hi Martin,

The bitmap drawer GLCD components should work directly with the WS2812 component allowing you to store the bitmap files in flash or on an SD card. Thought this info might help.

https://www.instructables.com/id/Easy-RGB-LED-Sign/

Some good ideas there.

mnf
Valued Contributor
Valued Contributor
Posts: 552
Joined: Wed May 31, 2017 11:57 am
Has thanked: 54 times
Been thanked: 310 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby mnf » Thu Dec 05, 2019 9:27 pm

Some cool ideas there..

Yes - the fix to scroll worked. Almost a shame - the sine wave produced an interesting 'whip' effect at 0.1 brightness.

Martin
These users thanked the author mnf for the post:
Benj (Fri Dec 06, 2019 10:49 am)
Rating: 5.26%