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

◆ HeatColor()

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

Definition at line 200 of file colorutils.cpp.

200 {
201 CRGB heatcolor;
202
203 // Scale 'heat' down from 0-255 to 0-191,
204 // which can then be easily divided into three
205 // equal 'thirds' of 64 units each.
206 fl::u8 t192 = scale8_video(temperature, 191);
207
208 // calculate a value that ramps up from
209 // zero to 255 in each 'third' of the scale.
210 fl::u8 heatramp = t192 & 0x3F; // 0..63
211 heatramp <<= 2; // scale up to 0..252
212
213 // now figure out which third of the spectrum we're in:
214 if (t192 & 0x80) {
215 // we're in the hottest third
216 heatcolor.r = 255; // full red
217 heatcolor.g = 255; // full green
218 heatcolor.b = heatramp; // ramp up blue
219
220 } else if (t192 & 0x40) {
221 // we're in the middle third
222 heatcolor.r = 255; // full red
223 heatcolor.g = heatramp; // ramp up green
224 heatcolor.b = 0; // no blue
225
226 } else {
227 // we're in the coolest third
228 heatcolor.r = heatramp; // ramp up red
229 heatcolor.g = 0; // no green
230 heatcolor.b = 0; // no blue
231 }
232
233 return heatcolor;
234}
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:127
unsigned char u8
Definition int.h:17
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86

References scale8_video().

+ Here is the call graph for this function: