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

◆ HeatColor()

CRGB fl::HeatColor ( uint8_t temperature)

Definition at line 199 of file colorutils.cpp.

199 {
200 CRGB heatcolor;
201
202 // Scale 'heat' down from 0-255 to 0-191,
203 // which can then be easily divided into three
204 // equal 'thirds' of 64 units each.
205 uint8_t t192 = scale8_video(temperature, 191);
206
207 // calculate a value that ramps up from
208 // zero to 255 in each 'third' of the scale.
209 uint8_t heatramp = t192 & 0x3F; // 0..63
210 heatramp <<= 2; // scale up to 0..252
211
212 // now figure out which third of the spectrum we're in:
213 if (t192 & 0x80) {
214 // we're in the hottest third
215 heatcolor.r = 255; // full red
216 heatcolor.g = 255; // full green
217 heatcolor.b = heatramp; // ramp up blue
218
219 } else if (t192 & 0x40) {
220 // we're in the middle third
221 heatcolor.r = 255; // full red
222 heatcolor.g = heatramp; // ramp up green
223 heatcolor.b = 0; // no blue
224
225 } else {
226 // we're in the coolest third
227 heatcolor.r = heatramp; // ramp up red
228 heatcolor.g = 0; // no green
229 heatcolor.b = 0; // no blue
230 }
231
232 return heatcolor;
233}
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_video(uint8_t i, fract8 scale)
The "video" version of scale8() guarantees that the output will be only be zero if one or both of the...
Definition scale8.h:123
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55

References scale8_video().

+ Here is the call graph for this function: