Programmable neopixels light show recommendations

Hi All, need some help :slight_smile:

Let’s see if I can explain what I want to do. I don’t want to reinvent the wheel and I would imagine this problem has been tackled for similar applications many times, but I can’t find anything!

I want to be able to make programmable shows that I can send to a Photon and then run a NeoPixel light show in sequence.

For now let’s consider 240 leds per photon and for simplicity let’s only consider one photon.

My vision is to have a state for each of the 240 leds per line (per frame) with coma delimited field per each LED and line feed for every frame. Every frame will be read and a value will be assign for each led in a given frame.

When I say frame I mean a 30th fraction of a second. Usually for good animations people recommend 30 frames per second. Some 60, but let’s first solve for 30!

We will run the show at 30 frames per second, so every 30th of a second a line will be read and striped per field for every LED (by a comma or by a fixed length per LED), And then each value will be assigned to the LED accordingly and a led will be lit according to its value. Then… On to the next line.

Say the file is composed as follows:
Note: Each comma delimited field will be an RGB value in hex form for a given LED from LED 1 to LED 240. When you see ‘…’ it means that it goes to the nth field but abbreviated for the post. Like saying (and so on).

First value will be LED 0 and the next value will be LED 2 and so on. We will use comas here in the example to make it clear where each value changes.

----[BEGIN FILE]
FF0000,64FFFF,64FFFF,64FFFF,64FFFF,64FFFF,FF0000,FF0000,FF0000,64FFFF,…
64FFFF,FF0000,64FFFF,64FFFF,64FFFF,64FFFF,FF0000,FF0000,FF0000,64FFFF,…
FF0000,64FFFF,64FFFF,64FFFF,64FFFF,64FFFF,FF0000,FF0000,FF0000,64FFFF,…
64FFFF,FF0000,64FFFF,64FFFF,64FFFF,64FFFF,FF0000,FF0000,FF0000,64FFFF,…

----[END FILE]

Now, I know this could work but my question is in terms of efficiency and any recommendations that might arise or you could recommend, I dont know whats the best efficient way to use. Both for storing and parsing on time.

I know hex values are shorter than individual RGB values, but then I have to convert from hex to RGB 0-256 values per color channel. I don’t know if the savings in memory will make it slower to run and not allow me to run the 30frames per second I am aiming for. There’s also a lot of duplication and seems in efficient in terms of memory usage. I could write a more efficient protocol where I can specify a value and then assign it to one or more LEDs, like this:

----[BEGIN FILE]
FF0000=1,4,7,12,32 …
64FFFF=2,3,5,6,8,9.10,11,13 …

----[END FILE]

But this is efficiency only exists when the values are repetitive and this is not predictable reality. I have to design for worst case scenario which means that all LEDs need different values.

What I am looking for is for recommendations on what’s a good practice to implement what I want. Because it is not only the parsing speed I don’t know if I can achieve or not, but also the storage space. I need way to store 3-4 minute show somewhere. If I use this form I will likely need an SD card or some sort of external memory because it will not fit in the onboard photon memory (according to my math which I am not good at either :blush: ). So I will need to buffer and read and parse 30 times per second.

–>My math looks like this :

About 6 bytes per LED. So 240 LEDS = 1,440 bytes per line (not counting the comas, which I might skip if length is predictable).
1,440 bytes per line x 30 frames in a second [each line is a frame] = 43,200 Bytes in a second.
43,200 bytes in a second x 60 seconds = 2,592,000 Bytes in a minute
2,592,000 bytes in a minute x 4 minute song = 10,368,000 = 10.368 Mb [as in Megas!]

So no! It won’t fit on the on board memory if I am counting right!

Is there a better way to do this than anyone can suggest, Idealy I dont want to use an SD card or anything external although might be impossible. I want to transmit the show via WiFi and store it. Then run it on command and maybe in the future I will broadcast via UDP a time code to run a specific frame per Photon, but that’s in the future… I also need to think about parsing speed for smooth animations, so anything you can suggest to make this better I would appreciate!

When you have to transmit and store MBs you should opt for a binary format (e.g. via FTP) and forget about parsing

Thanks.

What do you mean forget parsing? I understand the binary part.

If you already have binary data you won’t need to parse that anymore since you already have the format the controller needs.

1 Like