How easy would it be to get the FIRE2012 code to work upside down?
So my controller and power is at the ‘top’ of the strip of LEDs and the furthest away LED is physically below that?
I’m lost in the programming (being a crap programmer and not too smart on math, either).
I’ve got it to kind of work, but all the colours are wrong.
Yes, swap led 0 values with led n, led 1 with led n-1, etc right before you call LEDs.show
Hackish, but it’s quick and dirty
Find, near the bottom, where it says
leds[j] = …
and change it to
leds[ (NUM_LEDS-1) - j ] = …
Works for both the palette and non-palette versions.
Basically what it’s doing is changing this original instruction: “fill the Nth LED from the start of the strip with the Nth value from the start of the heat array” to this ‘upside down’ instruction: “fill the Nth LED from the end of the strip with the Nth value from the start of the heat array.”
Presto: fire still burns right-side-up, but it “displays” upside down.
I want to do this also but this fix didn’t work for me. It works beautifully (burning top-to-bottom) with this code:
void Fire2012WithPalette()
{
random16_add_entropy( random());
static byte heat[NUM_LEDS];
for( int i = 0; i < NUM_LEDS; i++) {
heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
}
for( int k= NUM_LEDS - 3; k > 0; k–) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
}
if( random8() < SPARKING ) {
int y = random8(7);
heat[y] = qadd8( heat[y], random8(160,255) );
}
for( int j = 0; j < NUM_LEDS; j++) {
byte colorindex = scale8( heat[j], 240);
leds[j ] = ColorFromPalette( currentPalette, colorindex);
}
}
… but if I change the last line to
leds[ (NUM_LEDS-1) - j ] = ColorFromPalette( currentPalette, colorindex);
… then no lights come on at all. Is there something else I need to change?
Aah I think I figured it out. I am still learning how to set up arrays and I think my NUM_LEDS array wasn’t set up right. I’ll get there someday!!