FastLED 3.10.6
Loading...
Searching...
No Matches

◆ HeatColor()

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

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

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