Hi I’m working on a project where each LED in the strip has a fixed (but different) color and the brightness of every LED is changed to a new (individual) value every time through the loop. It seems that working in the HSV color space is the best way to do this. The Hue and Saturation levels are fixed while the Value parameter is changed every time through the loop.
But, I’m pretty sure that only a CRGB array can be passed to the “addLeds()” method. So, I maintain a separate “shadow” CHSV array of the same size. Every time through the loop I change the Level parameter of each element in the CHSV array and then copy it to the corresponding element of my CRGB “leds” array. When I’m done, I call the “show()” method.
Is this the best way to do it? The brightness needs to be an absolute value, not relative. So, I don’t think I can use color math or the “fadeLightBy()” / “nscale8()” methods.
I understand that. But in order change the value (brightness) with “led[i] = CHSV(hue, sat, value)” I have to also KNOW what hue and sat are. As I said, they are different (but fixed) for every LED in the string. There is no “led[i].changeValue” method, and the “led[i]” array elements are CRGB objects, so they can’t tell me their hue or sat values. So, if I only want to change the value (brightness) setting, I have to store the corresponding hue and sat values SOMEWHERE. That’s why I use a CHSV array of the same size to “shadow” the “led[]” array. So, every time through the loop I do “shadowArray[i].value = newBrightness” and then “led[i] = shadowArray[i]”.
@Greg_Valvo The only drawback I see is the extra memory needed for the intermediary HSV array (and probably only an issue if you have a large number is pixels). I think the way you are doing it is fine.
OK, thanks. I’m sticking with what I have. I’ll gladly take the small memory hit in exchange for the higher performance gained by not using “rgb2hsv_approximate”