Hey guys, trying to figure out a way to use different animations on the

Hey guys, trying to figure out a way to use different animations on the same strip. Basically I have “gauges” and each gauge has 4 leds in it, each gauge is also a button that can be pressed. When that gauge is pressed I want the animation in just that gauge to change. In the docs I see this

"void fill_rainbow (struct CRGB *pFirstLED, int numToFill, uint8_t initialhue, uint8_t deltahue=5)
fill_rainbow - fill a range of LEDs with a rainbow of colors, at full saturation and full value (brightness) "

Which leads me to believe I can change this
fill_rainbow( leds, NUM_LEDS, gHue, 7);
to
fill_rainbow( leds[gaugeLeds[0]], ledsInDial, gHue, 7);
(gaugeLeds[0] being the first led number in that gauge)
and I would get just that animation on just the 4 leds of that gauge starting with the first led number in that gauge.
However, when I compile I get this

“no matching function for call to ‘fill_rainbow(CRGB&, int, uint8_t&, int)’”

my leds are declared like this
CRGB leds[NUM_LEDS];

So I am totally missing something… any ideas?

Indexing the leds array with the [] operator changes its representation from a pointer to a value. Since fill_rainbow takes a pointer, you’ll have to give it a pointer. There are two ways to do this:

  • You can use pointer arithmetic to “add” the offset to the pointer, in the format (leds + 0)
  • You can use the address-of operator to convert the dereferenced value back into a memory address, in the format &(leds[0])

I prefer pointer arithmetic myself, but you should use whichever you think makes the code’s intent clearest.