Is there a way to read the CHSV val parameter from the leds[x] array?

Is there a way to read the CHSV val parameter from the leds[x] array?

I’m working on some code right now to sense when for example, using
fadeToBlackBy( leds, NUM_LEDS, 10);

would get to the last step before becoming completely black. So I figure I’m looking to see when the val parameter is >0 and <10. Is there a way to do this?

For that particular case, try
k = leds[i].getAverageLight();

It returns the average of R G and B, and works well for what you’re describing. (And is very fast, unlike RGB-to-HSV approximation.)

Not really - there’s a function to convert from RGB back to HSV, but it’s only an approximation. However, for what you specifically want to do here, calling getLuma might give you want you want:

http://fastled.io/docs/3.1/struct_c_r_g_b.html#abd395f8a00bd4f9539f04200df1975f4

The idea is to create an effect where when the light is about to fade it “pops” a white flash. So while using FadeToBlackBy() I want to detect the last moment it’s still lit, but not off (because I don’t want to trigger non-active pixels with the effect).

I take it the fade function basically reduces the rgb values by a certain amount until the average is, for example, >1 and <10 and this would work?

Assuming leds[i].getAverageLight() is what to use, what’s the most efficient way to match it being >0 and <x? Should I resolve the value to a uint8_t variable and then do the compare, or reference the function twice in an if statement? I’m really anal about trying to write fast and memory efficient code.

The fade function multiplies each r g and b channel by ((255-fadeamount)/256).

So if fade amount is “10”, the each channel is multiplied by ((255-10)/256), or 0.957.

So if the Red channel for a pixel was, say, 50 beforehand, it would be 47 afterwards.

You can calculate from your fade amount number what will happen.

But mostly: just try it and see what you like visually!