I realized I want to do everything with HSV.
Is there a better way than
uint8_t h[NUM_LEDS], s[NUM_LEDS], v[NUM_LEDS];
as global variables that I can adjust from every function?
like so:
uint8_t h[NUM_LEDS], s[NUM_LEDS], v[NUM_LEDS];
for (int i = 0; i < NUM_LEDS; i++) { leds[i]= CHSV(h[i],s[i],v[i]); }
FastLED.show();
What’s the goal?
There are a lot of ways to do this, but I generally use both a CRGB array and a CHSV array, and do all my work on the CHSV array, calling hsv2rgb_rainbow() just before I call show.
Uses roughly 2x the RAM, but unless you’re doing this with 1000’s of LED’s, most non 8-bit Arduino have more than enough capacity to handle it.
I’ve done something similar with a slight difference to your code:
CRGB leds[NUM_LEDS];
// define a second array of led data as HSV
CHSV hsv[NUM_LEDS];
// code, pattern, animation that sets/modifies the HSV array
// copy HSV data to leds
// FastLED will automatically convert HSV to RGB
for(uint16_t i = 0; i < NUM_LEDS, i++) {
leds[i] = hsv[i];
}
Thanks guys. Peter, the “goal” is just that I found using HSV was giving me much smaller and cleaner code. Since a lot of my effects are shifting and dimming individual leds in small amounts.
I also found that my leds, WS2813s are kinda weird. The Yellow for instance is at hue 80. And adjusting that is just much simpler with hue than RGB.