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 443 of file chipsets.h.

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

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: