Fire2012 + Color Palette = Rainbow Fire The latest "FastLED 2.1" branch on github

Fire2012 + Color Palette = Rainbow Fire
The latest “FastLED 2.1” branch on github now contains a new example sketch, “Fire2012WithPalette”. This is basically exactly the same as the Fire2012 example except that instead of using the function “HeatColor(…)” to choose a color to show the temperature of each cell, this new code uses “ColorFromPalette(…)”.
The code shows five different ways to set up different color palettes, from the newly built-in HeatColor_p, to hand-colored gradients, and finally a dynamically re-colored palette than makes your fire burn through all the colors of the rainbow, as shown in this video.

Download the latest FastLED 2.1 code, choose Fire2012WithPalette from the examples, and just un-comment the palette setup you want to try.
https://github.com/FastLED/FastLED/archive/FastLED2.1.zip

You can read the example code here https://github.com/FastLED/FastLED/blob/FastLED2.1/examples/Fire2012WithPalette/Fire2012WithPalette.ino

Basically, once the color palette is set up the way you want, the only real change in the Fire2012 code is that this old line
leds[j] = HeatColor( heat[j] );
is replaced with this new one
leds[j] = ColorFromPalette( gPal, heat[j] );
…more or less – there’s actually one other line added to scale the heat down from a maximum of 255 to a maximum of 240, just for good looks.

Basically, “ColorFromPalette(pal,num)” takes a number from 0-255, and returns the corresponding color from the color palette you’ve set up. What’s nice is that you’ve separated the ‘animation’ part of your program from the ‘color selection’ part, so you can leave the animation alone (e.g, the fire), and tinker with the colors all you like.

That looks great Mark!

Thanks! I suspect that there are plenty of times when I’m not going to use color palettes, but I also have sneaking suspicion that I’m going to use them a heck of a lot now that we have them, and they’re compact and fast.

@Erin_St_Blaine : I’ve been thinking of your ‘fire and ice’ animation as I’ve been working on the color palettes, and particularly while I was putting together this example. It’d be even easier to code that up now: basically just switch the color palette from red to blue every N seconds – and the whole rest of the program wouldn’t care one whit.

Thanks a ton Mark! I have yet to incorporate it into my code, but looking at the sample just now, it appears to be very simple.

I’m loving playing with this!! I’m lost in Fabrication Land right now but have been messing about with the palettes while waiting for glue to dry. Hope to get some fun stuff running soon!

Very nice. Have updated the library and am now looking to incorporate Fire2012WithPalette with my other IR controlled routines.

Mark, Hope this is correct place.
Mark,
I have a large carboy I wish to illuminate with Fire2012. Naturally I wish to feed from top rather than bottom.
Do I just reverse the polarity of all the ‘for’ statements to achieve the same effect?
Than you in anticipation,
Mike
PS: I have reversed all the" for" statements but the result is a pale (sic) imitation of your original. It tends to the yellow/white end of spectrum and does not “run” in correct direction.

Any advise in resolving this would be appreciated! (This is my first try at addressable LEDs).
Regards,
Mike

Hi Mike!
I think the only thing that needs to be reversed is one part of the last loop, “Step 4. Map from heat cells to LED colors.” Start with a fresh copy of the example code, and then find “Step 4.” happens. There’s a loop there (the last one in the example code) that starts
for( int j = 0; j < NUM_LEDS; j++) {

I’d add a line after that that says
int k = (NUM_LEDS - 1) - j;

Now as j goes up from 0 to (NUM_LEDS-1), k will go down from (NUM_LEDS-1) to 0.

Now look at the following line that says
leds[j] = …
and change it to say
leds[k] = …
leaving everything else the same.

What this does (I think-- haven’t tried this yet myself) is keep the whole fire/heat simulation exactly the same internally – but then it ‘draws it’ upside down onto the LEDs.

Does this work for you, and give the effect you’re hoping for?

Hi Mark First off your Work in LEDs is Great!
And thanks for sharing i wouldn’t have this cool floor light without it…
https://plus.google.com/u/0/118115461623830030163/posts/LxR1y81R5vB?pid=6166775905170250370&oid=118115461623830030163

As you can see in the vid I had it working good on multiple strips (2x32) on their own pins but ran out of pins so i did a serpentine layout upgrade to 5 strips.

Now i cant get the fire to work right with the XY matrix setup, i think its your code actually from the examples…

The hardware-n-config is working have NoisePlusPalette, Fireworks and others using the matrix setup…
Iv tried a bunch of things but i not that good at programming…

Thanx in advance for any advice…

N/M, I found my problem. Had some things backwards in the XY part of code…
Thanks Again.

Glad you got it working now!