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

◆ computeAdjustment()

CRGB CRGB::computeAdjustment ( fl::u8 scale,
const CRGB & colorCorrection,
const CRGB & colorTemperature )
static

Calculates the combined color adjustment to the LEDs at a given scale, color correction, and color temperature.

Parameters
scalethe scale value for the RGB data (i.e. brightness)
colorCorrectioncolor correction to apply
colorTemperaturecolor temperature to apply
Returns
a CRGB object representing the adjustment, including color correction and color temperature

Definition at line 29 of file crgb.cpp.hpp.

30 {
31#if defined(NO_CORRECTION) && (NO_CORRECTION == 1)
32 return CRGB(scale, scale, scale);
33#else
34 CRGB adj(0, 0, 0);
35 if (scale > 0) {
36 for (fl::u8 i = 0; i < 3; ++i) {
37 fl::u8 cc = colorCorrection.raw[i];
38 fl::u8 ct = colorTemperature.raw[i];
39 if (cc > 0 && ct > 0) {
40 // Optimized for AVR size. This function is only called very
41 // infrequently so size matters more than speed.
42 // (cc + 1) * scale is at most 65280, so it fits in
43 // 16 bits. Reordering the exact product avoids a wide multiply.
44 const fl::u16 scaledCorrection = (fl::u16(cc) + 1U) * scale;
45 fl::u32 work = fl::u32(scaledCorrection) * (fl::u16(ct) + 1U);
46 work /= 0x10000L;
47 adj.raw[i] = work & 0xFF;
48 }
49 }
50 }
51 return adj;
52#endif
53}
fl::UISlider scale("Scale", 4,.1, 4,.1)
unsigned char u8
Definition s16x16x4.h:132
FASTLED_FORCE_INLINE CRGB() FL_NO_EXCEPT
Default constructor.
Definition crgb.h:111

References CRGB(), fl::FL_NO_EXCEPT, and scale.

Referenced by fl::CLEDController::getAdjustment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: