Today I learned: `FastLED.show()` will automatically wait/delay if you have set a refresh rate

Today I learned: FastLED.show() will automatically wait/delay if you have set a refresh rate before with FastLED.setMaxRefreshRate(FPS). This is relevant when you want to do time-critical things in addition to blinking LEDs.

To still cap the amount of frames rendered by second, you can use the EVERY_N_ macros:

`EVERY_N_MILLISECONDS(1000/FPS) {

animation code

FastLED.show();
}
`

This info is hidden in the docs, but was not obvious to me. Hope it helps.

Yeah - I need to do some writeups that more directly call stuff like this out. The max refresh rate code was put in initially because WS2812 leds freak out if you try to update them more than 400 times/second, and after getting multiple bug reports from people confused as to why their leds were freaking out, it felt easier to make it possible to have the library manage the rate :slight_smile:

It’s an awesome feature, don’t get me wrong :slight_smile:

I just forgot that I set the refresh rate and lost my hair about the “mysterious” delay.

I was trying this, but it doesn’t work in subroutines. I assume because it’s variables go out of scope when the routine exits.

So I’m using static instances of CEveryMillis Update(1000/fps); to do the same thing.

You then use

If(Update) {
#animation
Show;
}

The class has lots of great methods like reset() and setPeriod(); so it’s really flexible. Beats if(millis() - previous_millis > 1000/fps) {
#animation
Show;
Previous_millis = millis();
}

Which is what I was doing before I found this.