Hello!
New to the community, I have been using the Neopixel library and have been switching over to FastLED because of the obvious advantages. I’m getting stuck on the EVERY_N_MILLIS function and how to use it properly. I want to use it in a for loop to control the speed of an animation. For Example:
void wipe( CRGB color, uint8_t wait) {
for (int i=0 ; i < NUM_LEDS; i++) {
leds[i] = color;
EVERY_N_MILLIS(wait); //Tried Here
FastLED.show();
EVERY_N_MILLIS(wait); //Tried Here
}
}
But it does not seem to make a difference
That’s an interesting take that Ken has on the EVERY_N_MILLIS call. I do it by:
void loop () {
EVERY_N_MILLIS(wait) {
coolfunction();
}
FastLED.show(); // I always keep this in the loop.
}
void coolfunction() {
// Do awesome stuff.
}
The advantage Ken’s has is that each display routine you call can have separate wait times, whereas mine is a one size fits all unless I change the wait value on the fly. Hmm, choices, choices.
Ken’s way was perfect for me, I had too many delays in my Neopixel sketch all over the place. This way allowed me to change the speed when calling the function. Worked extremely well.