Skip to content

Commit

Permalink
Merge pull request #11 from adafruit/ticks-exception-like-micropython
Browse files Browse the repository at this point in the history
raise an OverflowError like micropython for too big a value
  • Loading branch information
dhalbert authored Aug 9, 2024
2 parents 527d90e + 892cca3 commit 26a51ab
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion adafruit_ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ def ticks_ms() -> int:

def ticks_add(ticks: int, delta: int) -> int:
"Add a delta to a base number of ticks, performing wraparound at 2**29ms."
return (ticks + delta) % _TICKS_PERIOD
if -_TICKS_HALFPERIOD < delta < _TICKS_HALFPERIOD:
return (ticks + delta) % _TICKS_PERIOD
raise OverflowError("ticks interval overflow")


def ticks_diff(ticks1: int, ticks2: int) -> int:
Expand Down

0 comments on commit 26a51ab

Please sign in to comment.