Is there a way to convert my LED array to shades of gray that represent each color’s brightness? I’m trying to add a B&W post-process effect to my pixels. I’m not having any luck with setHSV.
Of course, as soon as I post I find a solution in the docs. Here’s what I used.
for (int i = 0; i < NUM_LEDS; i++)
{
uint8_t luma = leds[i].getLuma();
leds[i] = CRGB(luma, luma, luma);
}
FastLED.show();
Great! How’s that work, visually?
If you want a different base color (eg try:
…
CRGB base = CHSV( HUE_GREEN, 128, 255);
leds[i] = base.nscale8_video( luma );
…
Nifty trick for using a different base color @Mark_Kriegsman . I guess this does something similar to using a multiplier, yes?
luma = (leds[i].r * 0.3) + (leds[i].g * 0.59) + (leds[i].b * 0.11)
Yep. That’s basically what CRGB::getLuma does, except getLuma does it with (faster) fixed-point math and avoids the floating point overhead.