What would be the fastest way to increment the hue value of a CRGB class? Thanks!
I believe that’s. . .
leds[i].g++;
for green. Then there’s r and b.
Right, I can adjust each channel separately that way but I’m looking for a way to adjust all three channels in a hue advancement way.
I believe you can’t directly manipulate the hue of a CRGB. You’d have to convert it to HSV first. There is a function called rgb2hsv but the results are an approximation (for math reasons) and sketchy to use consistently. You can find the explanation in the file https://github.com/FastLED/FastLED/blob/master/hsv2rgb.h (Search for rgb2hsv).
If you could store your colors in CHSV from the beginning, it would make your life easier.
Can you work with HSV instead? Seems that would be much more straight forward to how you’re wanting to make a color adjustment.
Can you give us a bit more context?
It is very easy to switch if you start with HSV…the library does the work automatically, even for an entire palette. For instance:
// switch palette
if(ipal == 0 ) {currentRGBPalette = PartyColors_p ;}
else if( ipal == 1) {currentRGBPalette = BluesHSV_p ;}
else if ( ipal == 2 ) {currentRGBPalette = RedsHSV_p ;}
else if( ipal == 3 ) {currentRGBPalette = GreensHSV_p ;}
for(int ic = 0 ; ic < 16 ; ic++ ) {
// we take advantage of the library’s auto conversion of color space from
// HSV to RGB and use a CRGB variable for the color, even though we are getting the color from
// an HSV palette
CRGB c = currentRGBPalette[ic] ;
This works just fine. I wrote it so that I could use both HSV hue control and color blending.