I'm an old COBOL programmer and I'm venturing into Arduino. I'm very confused.
I'm looking at the example sketch 'ColorPalette' from the FastLED library. Can someone please give me the answer to this noddy question?
Looks to me like startIndex is created and set to zero and then 1 is added to it. Then the function is called to set up the chosen colours and the show command is issued.... Then we come back in at the top of the loop.
As far as I can see, startIndex will ALWAYS be 1 when FillLEDsFromPaletteColors is called.
What is the point of declaring it, setting it to zero, then adding 1?
Or does this behave in a way other than I have described?
void loop()
{
ChangePalettePeriodically();
static uint8_t startIndex = 0;
startIndex = startIndex + 1; /* motion speed */
FillLEDsFromPaletteColors( startIndex);
FastLED.show();
FastLED.delay(1000 / UPDATES_PER_SECOND);
}