Hello.
Writing this from memory... at work at the moment...
I have a TFT screen and I need to display minutes, seconds and milliseconds counting down.
I started with a test routine that triggered every 100ms if (currentMillis - timerMillis > 100) {}
Each time that was called, then it reduced the milliseconds by 10 on the display, and using the obvious coding, it reduced seconds if required and minutes.
But... it's not keeping time. I believe I have too much in the main loop and that means the updating is occurring well past the 100ms trigger point (if that makes sense). It drifts out and starts to run slow.
I wanted to use the Countdown library, as this seems far more efficient than my checks to see if seconds = 0 then decrease minutes and reset seconds to 59 etc.
But, I can't see how to retrieve the minutes, seconds and milliseconds value from that library (maybe you can't).
Now maybe part of the problem is I am blanking out the changing clock value (only the ones that need changing) using a tft.fillRect(x,y,12,12, BLACK); command. But I thought one line like this was more efficient than drawing the text again in Black.
I realise you need to see my horrific code, but can't do that until back tonight.
I also realise that the other stuff in the main loop needs to be quicker, but I have made that as efficient as I can. It checks a wifi connection every 3 seconds and that needs to stay.
I think what I need is some code that will keep time and allow the milliseconds element to skip values (and therefore displaying them) in order to keep time.
Just wondered if anyone had any ideas or links to useful libraries. I downloaded 3 different countdown libraries and none did what I need (as in, I could not work out how to retrieve the individual min, secs and ms values to display).