Design question.
I want to have a particular animation run once when a button is pressed. I figured on handling the logic in an ISR and running the button on an interrupt pin. Daniel assured me that the interrupt would be detected during FastLEDdelay wait intervals. I now discover that during the interrupt period millis() will not update. So, is there a good way to handle frame rate in a function triggered in an ISR?
I guess an alternative would be to use the interrupt to set a flag and trigger the animation using a conditional on the next pass through loop.
Also worth noting that after interrupts are re-enabled, FastLED adjusts the millisecond timer to be (pretty much) correct again, accounting for the time spent with interrupts off.
Also also worth noting that only some LED types require disabling interrupts (eg WS2811 Neopixels), and many do not require this (eg APA102 “DotStars”).
And in general I like your idea: just set a flag in the ISR, and pick it up from normal code.
Don’t call FastLED.show from inside an ISR. Honestly, you really don’t want to be doing much of anything other than setting flags (and maybe moving a few bytes of data around, at most) inside of an ISR. They should be small, compact, fast. In your loop() { } you can then check for whether or not that flag had been set.
To expand on this a bit more. The way millis works on most arduino style systems is that there’s an ISR that fires roughly 1000 times/second, incrementing a counter.
Also, the way many of these MCU’s work, while you are inside of one ISR routine, any other interrupts won’t be handled until you exit the ISR routine. This is why you aren’t seeing millis update while you’re in the ISR.
(Some arm based systems allow for the option of nested interrupt handling, but then it becomes a question of priorities of the relative interrupt handlers)