Overflow handling on millis() is superfetatory.
There is absolutely no problem with the comparison math during an overflow event.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
To view this discussion on the web visit https://groups.google.com/a/arduino.cc/d/msgid/developers/19824bb5-4183-47e1-8f8c-9b76e7108c5an%40arduino.cc.
--
overflow/underflow on unsigned is defined in standard C/C++unsigned start = millis();if( millis()-start > 1000 ) ....Works Always, not need nothing.
There is no problem to be avoided
millis() works across the overflow.
You even can wrap all that stuff in a macro:
//*** Convenience macro for Timing ***
#define runEvery(t) for (static uint16_t _lasttime; (uint16_t)((uint16_t)millis() - _lasttime) >= (t); _lasttime += (t))
Then in you code, you just write:
runEvery(125){
<code that should run every 125ms>
}
And it does the magic.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
To view this discussion on the web visit https://groups.google.com/a/arduino.cc/d/msgid/developers/caeb7c8a-acd9-469d-86b1-2f931599ef04n%40arduino.cc.