diff --git a/adafruit_ticks.py b/adafruit_ticks.py index b8d46d9..835853a 100644 --- a/adafruit_ticks.py +++ b/adafruit_ticks.py @@ -122,9 +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." - if delta <= -_TICKS_PERIOD / 2 or delta >= _TICKS_PERIOD / 2: - raise OverflowError("ticks interval overflow") - 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: