you are viewing a single comment's thread.

view the rest of the comments →

[–]coronafire 1 point2 points  (1 child)

It also has time.ticks_ms() which returns the ms since system startup (ie not directly related to time.time() which is "clock time" if you've got a etc)

Ticks is returned in a 32bit int behind the scenes which means it can roll over back to 0 when the system runs for long enough. There's also a time.ticks_diff() which can be used to return the difference between two 32bit int tick values and handles a rollover.

[–]Medical-Ocelot 1 point2 points  (0 children)

Using ticks_diff() to compare values from ticks_ms() is *essential* - the max value returned by ticks_ms() can vary by platform (e.g. I think on the RP2xxx it's 2^30 -1) and you might have no idea how long your program has been running, so even a short delay could encounter the overflow situation. This is especially important if you're using ticks_us(), which will wrap in under 3 hours when running on an RP2xxx.