I have just finished my 100 pixel Christmas Star and I am trying to do a nice animation that basically soft fades an icy color in the center and flickers at each of the points. I looked at the Fire2012 sketch and I love the effect that it produces. However when I try to extend the sketch to 100 pixels it does nothing. I am using an ATtiny85 and the sketch is small (only 3750 bytes). I tried 50 pixels and it works. I know that 100 pixels will use 300 bytes of RAM. I have run sketches with 100 pixels that do different motion and such with out any problems and still have RAM to spare.
I was thinking of trying to modify the code to do the animation for the longest point and replicating it for the 3 other points with a move or maybe with some slick array pointers. It took 2 days to construct it!
Thanks for the help in advance.
The Fire sketch also uses a byte per LED for the heat variable. So you are already up to 400. I never used the Attiny85 but I think it only has 512bytes of ram. I am guessing that you are just running out of ram.
Try increasing the LED number until you see at what point it freezes. You can then decide where you could reduce your ram usage !
I figured it out! It turns out that I didn’t need to use a fire length of more than 36. What I did was remap the fire to each of my points. So I made the fire strand map to only one point (the longest) and then copied that point to the other 3 points and it is working GREAT!
I guess I was over tired from the construction. LOL
That is what I have it doing now. I tweaked the cooling and sparking to get it to flicker nice.
Do you know if there is any documentation on the HeatColor function? Is there a CoolColor one? I want to be able to change the color to an icy blue/white. I might even put a button to switch it if I can figure out how to change the color.
+1 on the Fire2012WithPalette – provided the ATtiny has enough RAM.
Also, people have noted that if you switch the Red and Blue channels of a ‘heat color’, then ‘hot’ becomes ‘cold’:
So find this line (near the bottom of the sketch)
leds[j] = HeatColor( heat[j]);
and add this underneath:
if( swapRedAndBlue == true) {
uint8_t temp;
temp = leds[i].red;
leds[i].red = leds[i].blue;
leds[i].blue = temp;
}
Then somewhere else add a global boolean variable thus:
bool swapRedAndBlue = false;
And then you can set it to true whenever you wish, and presto: fire and ice!
(Full credit to @Erin_St_Blaine for first pointing out the fire-and-ice result of swapping red and blue in the fire code!)
All of the code and all of the source is on your machine under Documents/Arduino/Libraries/FastLED (more or less-- path may vary). You can also search it online from github. https://github.com/FastLED/FastLED
There’s a fair amount of documentation in the code, and in the Examples that use palettes; I’d start there.
@Mark_Kriegsman
Thanks! I will be taking a look to see how it works and to try some different effects. I tried the Fire2012WithPalette and it works but I ran out of RAM doing the same as I did for Fire2012. I love the effect!
How many colors does the palette hold? I figure that might be why I ran out of RAM with 100 pixels on my tiny85.
Well I guess I will be looking at the code to find out.
I have not been this excited since I was a little kid on Christmas! LOL So COOL! Whee!
Ok! I looked at the code and wrote my own version of HeatColor. You can set a global called colorMode to switch the color on the fly. I tried just calling HeatColor but I think the stack overflowed a bit and the animation got choppy. So I put the same code inline and the switch statement sets the color based on colorMode. I arranged the color changes so the “outer” and “inner” colors rotate. If you look at my comments in the switch statement, you will see the pattern there. Hope someone else finds it useful! It is REALLY cool watching it change from fiery, to icy, and the earthy color tones. I just placed a frame counter to change the mode. A button could work well too! If you place this function in Fire2012 and replace the calls to HeatColor, it works fantastic!
// Scale 'heat' down from 0-255 to 0-191,
// which can then be easily divided into three
// equal 'thirds' of 64 units each.
uint8_t t192 = scale8_video( temperature, 192);
// calculate a value that ramps up from
// zero to 255 in each 'third' of the scale.
uint8_t heatramp = t192 & 0x3F; // 0..63
heatramp <<= 2; // scale up to 0..252
// now figure out which third of the spectrum we're in:
if( t192 & 0x80) {
// we're in the hottest third
r = 255; // full red
g = 255; // full green
b = heatramp; // ramp up blue
} else if( t192 & 0x40 ) {
// we're in the middle third
r = 255; // full red
g = heatramp; // ramp up green
b = 0; // no blue
} else {
// we're in the coolest third
r = heatramp; // ramp up red
g = 0; // no green
b = 0; // no blue
}
switch (colorMode) {
case 1:
// red/magenta heat
heat_color.r = r;
heat_color.g = b;
heat_color.b = g;
break;
case 2:
// blue/magenta ice
heat_color.r = g;
heat_color.g = b;
heat_color.b = r;
break;
case 3:
// blue/cyan ice
heat_color.r = b;
heat_color.g = g;
heat_color.b = r;
break;
case 4:
// green/cyan earth
heat_color.r = b;
heat_color.g = r;
heat_color.b = g;
break;
case 5:
// green/yellow earth
heat_color.r = g;
heat_color.g = r;
heat_color.b = b;
break;
default:
// default red/yellow heat
heat_color.r = r;
heat_color.g = g;
heat_color.b = b;
}
return heat_color;