FastLED 3.9.15
Loading...
Searching...
No Matches

◆ Fire2012()

void Fire2012 ( )
Examples
Fire2012.ino.

Definition at line 80 of file Fire2012.ino.

81{
82// Array of temperature readings at each simulation cell
83 static uint8_t heat[NUM_LEDS];
84
85 // Step 1. Cool down every cell a little
86 for( int i = 0; i < NUM_LEDS; i++) {
87 heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
88 }
89
90 // Step 2. Heat from each cell drifts 'up' and diffuses a little
91 for( int k= NUM_LEDS - 1; k >= 2; k--) {
92 heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
93 }
94
95 // Step 3. Randomly ignite new 'sparks' of heat near the bottom
96 if( random8() < SPARKING ) {
97 int y = random8(7);
98 heat[y] = qadd8( heat[y], random8(160,255) );
99 }
100
101 // Step 4. Map from heat cells to LED colors
102 for( int j = 0; j < NUM_LEDS; j++) {
103 CRGB color = HeatColor( heat[j]);
104 int pixelnumber;
105 if( gReverseDirection ) {
106 pixelnumber = (NUM_LEDS-1) - j;
107 } else {
108 pixelnumber = j;
109 }
110 leds[pixelnumber] = color;
111 }
112}
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
int y
Definition simple.h:93
#define COOLING
Definition Fire2012.ino:72
#define SPARKING
Definition Fire2012.ino:77
bool gReverseDirection
Definition Fire2012.ino:16
uint8_t heat[NUM_LEDS]
Definition Fire2023.h:100
CRGB HeatColor(fl::u8 temperature)
fl::CRGB CRGB
Definition crgb.h:25
LIB8STATIC fl::u8 random8() FL_NOEXCEPT
Generate an 8-bit random number.
Definition random8.h:53
unsigned char uint8_t
Definition s16x16x4.h:209

References COOLING, gReverseDirection, heat, HeatColor(), leds, NUM_LEDS, random8(), SPARKING, and y.

Referenced by loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: