I am attempting to run some FastLED animations on WS2812 panels. I had my code running on an Adafruit Trinket Pro (a 16MHz avr/arduino-alike) and recently moved to running on a Teensy in order to do more sophisticated animation. Unfortunately now all the animations are running much faster than real-time because an increment of 1000 in millis() occurs every ~425ms of actual time.
Some code to minimally demonstrate this (not really related to my fastled animations, but still based off of millis()) is:
Inspecting the serial console and timing how long it takes for 100 numbers to be printed, I find that it takes about 42 seconds when it should be 100. I'm sure I could write some code to get accurate counts wrt my laptop's clock if I needed to but I'm just watching the serial console with a stopwatch right now. I get similar numbers for printing ten numbers and so on. The millisecond counter is definitely substantially fast. How do I fix this?
Some code to minimally demonstrate this (not really related to my fastled animations, but still based off of millis()) is:
Code:
void loop() {
static unsigned long prev = 0;
static unsigned int i = 0;
unsigned long cur = millis();
showCurrentPattern();
if (cur - prev > 1000) {
prev = cur;
i++;
Serial.println(i, DEC);
}
Inspecting the serial console and timing how long it takes for 100 numbers to be printed, I find that it takes about 42 seconds when it should be 100. I'm sure I could write some code to get accurate counts wrt my laptop's clock if I needed to but I'm just watching the serial console with a stopwatch right now. I get similar numbers for printing ten numbers and so on. The millisecond counter is definitely substantially fast. How do I fix this?