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

◆ Fire2012()

void Fire2012 ( )
Examples
Fire2012.ino.

Definition at line 79 of file Fire2012.ino.

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

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

Referenced by loop().

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