Rather than just blindly copy and paste FastLED functions into sketches,

Rather than just blindly copy and paste FastLED functions into sketches, I’m trying to break them down and understand them so that, hopefully, I can use what I learn to understand future functions (and, hopefully, bother you guys less).

I’ve been messing with fill-gradient and have figured out the following FastLED for Dummies explanation.

fill_gradient(leds,0,CHSV(0,255,255),100,CHSV(96,255,255),SHORTEST_HUES);

In the above example:

0 = the starting LED. LEDs are indexed to zero, so LED #1 is identified as 0, LED #2 is identified as 1, and so on.
CHSV(0,255,255) = the starting color of the gradient expressed in HSV values, in this case red.
100 = the ending LED. Like the starting LED, it can be any number.
CHSV(96,255,255) = the ending color for the gradient, in this case green.
SHORTEST_HUES = The hue is a value on a color wheel. There are always two directions you can go to get from one place on a wheel to another (one hue value to another hue value). FastLED lets you pick the direction you want to go. SHORTEST_HUES is the shortest distance between the two values (the most common choice), LONGEST_HUES is the longest way around. FORWARD_HUES always moves clockwise. BACKWARD_HUES always moves counter-clockwise.

My question is…

What does the ‘leds’ in the function (right after fill_gradient and before the zero) signify? Is it something that can be tweaked/altered/replaced – or does it just need to be there for some magical reason that only people far smarter than me understand?

I’ve also seen it in the fill-solids function, but sometimes it seems to be replaced by ‘struct CRGB * leds’ or ‘struct CHSV* targetArray’ or similar.

If it can be explained, I’d appreciate it. if it’s something you just have to keep hammering away at, I’m already on it! :slight_smile:

In the beginning of your arduino sketch you defined a LED strip and gave it a name:

// Define the array of leds
CRGB leds[NUM_LEDS];

If you had more then one LED strip, you might have defined several at the top, something like:

// Define the array of leds
CRGB leds[NUM_LEDS];
CRGB leds_top[NUM_LEDS];
CRGB leds_helmet[NUM_LEDS_HELMET];

These names are used to specify which LED strip to operate on.

leds[0] = CRGB::Red; // set pixel 0 to red on strip leds.
leds_top[0] = CRGB::Green; // set pixel 0 to green on strip leds_top.
leds_helmet[0] = CRGB::Blue; // set pixel 0 to blue on strip leds_helmet.

Now that you explain it I feel kind’a stupid! Thanks! It makes a lot more sense now.

I’m thinking there’s probably a way to use something similar to break a strip down into two or more ‘virtual’ strips? Time to go make some awesome mistakes!

Thanks again!

Thanks AyTooZee, i am in a similar position and this input is invaluable.