Array of RGB values. Hi there I’m writing a program to sequentially display colour values from a list of hundreds of RGB values. Should I simply create a mulitdimentional array thus:
int todays_colour[][3] = {{175,160,105},{167,212,86},{61,241,7}…{6,124,224}};
or is there a better ‘FastLED’ way to do it?
Probably a more convenient way, though possibly not as neat, would be a CRGB array (CRGB todays_colour[] = {…}). I think you can define colours as hex values in this way ({0xafa069, 0xa7d456, 0x3df107 … 0x067ce0}) which would keep it compact (as opposed to doing CRGB(…,…,…) for every value) though I could be wrong.
Many thanks, much appreciated. The CRGB array works nicely but I’ve run out of memory on my Mega2560 as I’m trying to store 3650 values! I’ll look into hex to see if it’s more efficient.
If your storing 3650 it sounds like your doing it wrong.
What’s the outcome your looking for?
Onwards…! I’ve problems creating an array of hex values like this: CRGB todays_colour[] = {OxAFA069,OxA7D456,Ox3DF107,Ox067CE0,…OxB6D4A}; with an error saying each hex value is not declared in this scope. Sorry I’m probably doing something stupid!
are they Ox or 0x at the beginning of those HEX numbers.
they look like “Ohh’s” not Zeros
Hey Kelvin, Yep, my preference would be to generate the values but its a constraint of the project that I have to use prerendered values. You were right about “Ohh’s” not Zeros, big DOH! to me. Unfortunately storing them as Hex seems to take exactly the same amount of memory. Darn! Rethink required.
‘Global variables use 11,166 bytes (136%) of dynamic memory’
3650 is a really specific number of colours, the kind of number only a computer could identify. If your lighting LEDs and it’s for people, it doesn’t need to be that specific
If your displaying colour values it sounds like you are making a colour reader / colour chart identifier?
If so, you can result the direct hex numbers for each RGB then average to whatever bit your memory can handle.
True colour being 256bit, 16mil colours
8 bit 512 colours
Many thanks Kelvin, I’m making a sign for a coworking space which acts as a clock with a new colour gradient gradually taking over the sign each day. 10 years of values obvs
I’m not sure how to reduce colour depth, it’s probaly fine to loop after 5 years!
ahh, ok, a maths solution is much more applicable to this. you must have an RTC embedded somewhere?
you look to be having 5 colours on show at any one time? or you are using different brightness’s of a single colour 5 times?
and you wish over a 24 hour period, for the sign to go from (as examples)
red>green
white > red
black > red
white > red > white
on its simplest form, take the hue colour wheel (for ease of use) then all the colours are accessible through 0-255
check the colour blend functions, and the colour palettes examples as once you get your head around them they are really easy and useful
http://fastled.io/docs/3.1/group___colorutils.html
you can generate a colourPalette to start with, then a randomisation / linear choice selection to generate tomorrowsColourPalette, then spend 24 (or working day? 8 hours) to blend from one palette to the next, then at the end of the day, generate a new colour palette and then copy ready for the next day to start blending again.
for a super smooth fade across 10 years, you are never going to see any colour fades though… it’ll just be so slow, that after a month, someone will notice that its gone from red to orange, then 6 months later it’ll be blue…
not super exciting, although technically perfect!
Hi Kelvin, Yep I have a DS3231 keeping track of time which seems to work well. The colour has to match with the daily colour used elsewhere in the building so I have to use the list given. It did occur to me, (took me a while!) I can put the values in a lookup table in Flash memory and just read into SRAM as needed. Yep it’s slow! I’ve worked out with my 54 x 18 matrix of pixels I only need to update every 1600 seconds. There would effectivley be a max of 3 colours in play at any one time. Yesterdays colour which is getting wiped, todya and then near midnight tomorrow’s colur creeping in at one edge. I’ve played a little with different blends. Tis looks useful:
https://github.com/FastLED/FastLED/wiki/Gradient-color-palettes The fill_gradient functions seem to use a HSV palette so you get all the colours between the specified colours. Thank you again for your help. Really appreciated.