Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
IsTime function
boolean IsTime(unsigned long *timeMark, unsigned long timeInterval) {
if (millis() - *timeMark >= timeInterval) {
*timeMark = millis();
return true;
return false;

Problem with this... Lets say ISTIME is called LATE - it can't compensate for this so accurate timing is impossible... surely needs to compensate and ensure that timer overflow doesn't mess anything up. Perhaps some may not want that compensation, a flag could allow both versions..

In case that's not clear, lets say we need this to run every 50ms. We come in late at 52ms... and the timeMark is reset for another 50ms. It SHOULD be set to 48ms to compensate for us being late this time. Also technically we're potentially creeping a fraction of a millisecond each time we use this.


@scargill So...any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.