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

◆ getGlobalBrightnessAndScalingFactors()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(6), fl::FiveBitGammaCorrectionMode GAMMA_CORRECTION_MODE = fl::kFiveBitGammaCorrectionMode_Null, uint32_t START_FRAME = 0x00000000, uint32_t END_FRAME = 0xFF000000>
static void APA102Controller< DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_SPEED, GAMMA_CORRECTION_MODE, START_FRAME, END_FRAME >::getGlobalBrightnessAndScalingFactors ( PixelController< RGB_ORDER > & pixels,
uint8_t * out_s0,
uint8_t * out_s1,
uint8_t * out_s2,
uint8_t * out_brightness )
inlinestaticprivate

Definition at line 445 of file chipsets.h.

447 {
448#if FASTLED_HD_COLOR_MIXING
450 pixels.getHdScale(out_s0, out_s1, out_s2, &brightness);
451 struct Math {
453 const uint16_t run = in_max - in_min;
454 const uint16_t rise = out_max - out_min;
455 const uint16_t delta = x - in_min;
456 return (delta * rise) / run + out_min;
457 }
458 };
459 // *out_brightness = Math::map(brightness, 0, 255, 0, 31);
460 uint16_t bri = Math::map(brightness, 0, 255, 0, 31);
461 if (bri == 0 && brightness != 0) {
462 // Fixes https://github.com/FastLED/FastLED/issues/1908
463 bri = 1;
464 }
465 *out_brightness = static_cast<uint8_t>(bri);
466 return;
467#else
468 uint8_t s0, s1, s2;
469 pixels.loadAndScaleRGB(&s0, &s1, &s2);
470#if FASTLED_USE_GLOBAL_BRIGHTNESS == 1
471 // This function is pure magic.
472 const uint16_t maxBrightness = 0x1F;
473 uint16_t brightness = ((((uint16_t)max(max(s0, s1), s2) + 1) * maxBrightness - 1) >> 8) + 1;
474 s0 = (maxBrightness * s0 + (brightness >> 1)) / brightness;
475 s1 = (maxBrightness * s1 + (brightness >> 1)) / brightness;
476 s2 = (maxBrightness * s2 + (brightness >> 1)) / brightness;
477#else
478 const uint8_t brightness = 0x1F;
479#endif // FASTLED_USE_GLOBAL_BRIGHTNESS
480 *out_s0 = s0;
481 *out_s1 = s1;
482 *out_s2 = s2;
483 *out_brightness = static_cast<uint8_t>(brightness);
484#endif // FASTLED_HD_COLOR_MIXING
485 }
APA102 controller class.
Definition chipsets.h:375

References brightness, PixelController< RGB_ORDER, LANES, MASK >::loadAndScaleRGB(), and x.

Referenced by showPixelsDefault().

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