I must say I truly enjoy using FastLED. The versatility is great!
My question is about converting between RGB and HSV. Is there a way to find out what the HSV value would be for a given RGB value?
Thanks in advance.
I must say I truly enjoy using FastLED. The versatility is great!
My question is about converting between RGB and HSV. Is there a way to find out what the HSV value would be for a given RGB value?
Thanks in advance.
There’s rgb2hsv_approximate - documented here - https://github.com/FastLED/FastLED/blob/master/hsv2rgb.h#L52
Great! Thanks!
@Fed_Sanchez Here’s an example that displays a randomly picked rgb color and the approximated hsv, and also prints the rgb values to the serial monitor.
It will visually let you see that often it’s fairly good, but is off with certain rgb value combinations.
Sorry, I wrote too soon. I cannot figure out how to use the subroutine. it this how?
In Setup:
CHSV 1leds[ 60 ];
CRGB 2leds[ 60 ];
In Loop:
hsv2rgb_rainbow( 1leds, 2leds)
and then 1leds will be filled with the HSV equivalent of 2leds?
Thank you so much for the example. I’ll give it a try.
Does not seem to give me good values. Is there another fnction for rgb2hsv? For hsv2rgb there are rainbow, spectrum, and raw.
No, and it is only an approximation (as it mentions in the comments that I linked to above) - compounded by the fact that not every RGB value had a corresponding HSV value.
@Fed_Sanchez Can you tell us about your project and explain why you need to convert? Maybe there’s an alternate way to do things without needing to convert.
I need to fine-tune the colour of the LEDs because I’m using it for proofing photograph a colour correction. Using RGB is great, but at times HSV is easier. I wanted to try to flip back-and-forth between. RGB and HSV to get the right color.