MCPcopy Create free account
hub / github.com/AlexGyver/GyverLamp2 / HeatColor

Function HeatColor

libraries/FastLED-3.4.0/src/colorutils.cpp:449–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

447// versus 768 bytes for a full 256-entry RGB lookup table.
448
449CRGB HeatColor( uint8_t temperature)
450{
451 CRGB heatcolor;
452
453 // Scale 'heat' down from 0-255 to 0-191,
454 // which can then be easily divided into three
455 // equal 'thirds' of 64 units each.
456 uint8_t t192 = scale8_video( temperature, 191);
457
458 // calculate a value that ramps up from
459 // zero to 255 in each 'third' of the scale.
460 uint8_t heatramp = t192 & 0x3F; // 0..63
461 heatramp <<= 2; // scale up to 0..252
462
463 // now figure out which third of the spectrum we're in:
464 if( t192 & 0x80) {
465 // we're in the hottest third
466 heatcolor.r = 255; // full red
467 heatcolor.g = 255; // full green
468 heatcolor.b = heatramp; // ramp up blue
469
470 } else if( t192 & 0x40 ) {
471 // we're in the middle third
472 heatcolor.r = 255; // full red
473 heatcolor.g = heatramp; // ramp up green
474 heatcolor.b = 0; // no blue
475
476 } else {
477 // we're in the coolest third
478 heatcolor.r = heatramp; // ramp up red
479 heatcolor.g = 0; // no green
480 heatcolor.b = 0; // no blue
481 }
482
483 return heatcolor;
484}
485
486
487// lsrX4: helper function to divide a number by 16, aka four LSR's.

Callers

nothing calls this directly

Calls 1

scale8_videoFunction · 0.85

Tested by

no test coverage detected