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

◆ HeatColor()

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

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

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

Referenced by FL_DISABLE_WARNING().

+ Here is the caller graph for this function: