FastLED 3.10.8
Loading...
Searching...
No Matches

◆ HeatColor()

CRGB fl::HeatColor ( fl::u8 temperature)
Examples
Fire2012.ino.

Definition at line 284 of file colorutils.cpp.hpp.

284 {
285 CRGB heatcolor;
286
287 // Scale 'heat' down from 0-255 to 0-191,
288 // which can then be easily divided into three
289 // equal 'thirds' of 64 units each.
290 fl::u8 t192 = scale8_video(temperature, 191);
291
292 // calculate a value that ramps up from
293 // zero to 255 in each 'third' of the scale.
294 fl::u8 heatramp = t192 & 0x3F; // 0..63
295 heatramp <<= 2; // scale up to 0..252
296
297 // now figure out which third of the spectrum we're in:
298 if (t192 & 0x80) {
299 // we're in the hottest third
300 heatcolor.r = 255; // full red
301 heatcolor.g = 255; // full green
302 heatcolor.b = heatramp; // ramp up blue
303
304 } else if (t192 & 0x40) {
305 // we're in the middle third
306 heatcolor.r = 255; // full red
307 heatcolor.g = heatramp; // ramp up green
308 heatcolor.b = 0; // no blue
309
310 } else {
311 // we're in the coolest third
312 heatcolor.r = heatramp; // ramp up red
313 heatcolor.g = 0; // no green
314 heatcolor.b = 0; // no blue
315 }
316
317 return heatcolor;
318}
fl::CRGB CRGB
Definition crgb.h:25
unsigned char u8
Definition stdint.h:131

Referenced by drawFireEffect(), and Fire2012().

+ Here is the caller graph for this function: