I have a project using 256 neopixels in a grid pattern.
I'm encountering stability issues due to ram overflow. The Adafruit library declares a n*3 byte array at startup (in my case this is 768 bytes long) which is the biggest array in the sketch. I wanted to divide this by three by using a set 256 color palette. However I'm a bit lost in the code theres a lot of assembly and weird stuff going on in there.
Can anyone help me modify the library to use a set color palette?
I have made some progress in converting an RGB values to a single byte but can't find a elegant way to convert back from the byte to RGB values.
I have made some progress in converting an RGB values to a single byte
How did you do this? 3+3+2 bit for the color rgb informations or how did you squeeze it into a byte?
but can't find a elegant way to convert back from the byte to RGB values.
It will be hard to reconstruct an information that it not there anymore, except you can live with a very limited color space...
But you need the framebuffer anyway, so these 768 bytes are definetly gone.
Probably you find it helpful to check out the FastLED lib, which is not just the better library for the most (not all) usecases, but has already build in a very convenient color palette handling.
edit: It is possible to run simple 16x16 effects from an Uno, but you will spend more time optimizing your functions than actually with creating animations.
Get yourself a controller with more RAM, it is really worth the few bucks when programming led effects beyond scrolling rainbows.
The code I've posted creates a palette programatically. Its the principle used in old video systems with 256 colors by making the palette in code you don't use up space storing it or holding it in ram.
My problem is how to programatically reverse what I've done. i.e. take an RGB value and figure out which color on my palette matches (this can be very rough I just need a rough approximation)
EDIT: Also in relation to the board size is a big factor so a mega won't do. I'm using a nano and I've got a lot of 328p specific code in there.