Mark Kriegsman , in the Fire2012 demo, why the "-3" term in line 82?

@Mark_Kriegsman , in the Fire2012 demo, why the “-3” term in line 82?

// Step 2.  Heat from each cell drifts 'up' and diffuses a little
for( int k= NUM_LEDS - 3; k > 0; k--) {
  heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
}

I’d noticed my flames never reached the top two pixels of my strips and wondered why, this seems to be the reason.

:))) l noticed it too))

Looks like a holdover from when the leds were wired backwards - you want one of:

// lower numbered LEDs are near the top - so you want things moving towards 0
for(int k = 0; k < NUM_LEDS-3; k++) {
heat[k] = (heat[k+1] + heat[k+2] + heat[k+2])/3;
}

or

// higher numbered LEDs are near the top, so you want things moving towards NUM_LEDS
for(int k = NUM_LEDS-1; k >1; k–) {
keat[k] = (heat[k-1] + heat[k-2] + heat[k-2])/3;
}

Right now, the code as it is written above will have a couple of array out of bounds issues - oops :slight_smile:

There are only two hard problems in computer science: cache invalidation strategies and naming things. And off-by-one errors.

Also the halting problem. Which is what Dan and I work on for our day jobs. :smiley:

Hey @Mark_Kriegsman , did I see there was a way to feed an RGB or HSV color to make the “flame” a different color other than red?

“Rainbow fire” might cover it:
https://plus.google.com/112916219338292742137/posts/dkBUj4ZtpsB

(Still has the -3 bug :slight_smile:

Daaaaaa, that’s what I was looking for! Danke.