contrem / arduino-timer

Non-blocking library for delaying function calls
BSD 3-Clause "New" or "Revised" License
334 stars 50 forks source link

How long can a timer run? #70

Closed QDUNI closed 1 year ago

QDUNI commented 2 years ago

Hi,

How long can a timer run without needing to reset the timer/device ?

Thnx in advance

philj404 commented 2 years ago

The timer can run indefinitely without needing a reset. That said, if your code wants to schedule a task for over a month away, you may need to consider rollover issues.

(Internally the timer stores times as an unsigned long. The next time a task should run is also an unsigned long. The timer does not care what the particular value is, as it only compares the differences. When the difference between the current time and the time to run a task becomes positive, the task will run.)

You will need to consider unsigned long rollover issues if you want really long delays (waiting over 4294967295 ticks). That's equivalent to:

QDUNI commented 1 year ago

Thnx !