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

◆ HeatColor()

CRGB fl::HeatColor ( fl::u8 temperature)

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}
unsigned char u8
Definition stdint.h:131
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38

References FL_NO_EXCEPT.

Referenced by FL_DISABLE_WARNING().

+ Here is the caller graph for this function: