Skip to content

Commit

Permalink
Merge pull request #17 from FoamyGuy/remove_longint_req
Browse files Browse the repository at this point in the history
Support non-longint builds
  • Loading branch information
FoamyGuy authored Jan 9, 2025
2 parents 467fa0b + 7074f7c commit 4b9259f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions adafruit_vl53l4cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def timing_budget(self):
"""Ranging duration in milliseconds. Valid range is 10ms to 200ms."""
osc_freq = struct.unpack(">H", self._read_register(0x0006, 2))[0]

macro_period_us = 16 * (int(2304 * (0x40000000 / osc_freq)) >> 6)
macro_period_us = 16 * (int(2304 * (1073741824.0 / osc_freq)) >> 6)

macrop_high = struct.unpack(
">H", self._read_register(_VL53L4CD_RANGE_CONFIG_A, 2)
Expand Down Expand Up @@ -310,7 +310,7 @@ def timing_budget(self, val):
raise RuntimeError("Osc frequency is 0.")

timing_budget_us = val * 1000
macro_period_us = int(2304 * (0x40000000 / osc_freq)) >> 6
macro_period_us = int(2304 * (1073741824.0 / osc_freq)) >> 6

if inter_meas == 0:
# continuous mode
Expand All @@ -325,7 +325,7 @@ def timing_budget(self, val):
timing_budget_us <<= 12
tmp = macro_period_us * 16
ls_byte = int(((timing_budget_us + ((tmp >> 6) >> 1)) / (tmp >> 6)) - 1)
while ls_byte & 0xFFFFFF00 > 0:
while (ls_byte >> 8) & 0xFFFFFF > 0:
ls_byte >>= 1
ms_byte += 1
ms_byte = (ms_byte << 8) + (ls_byte & 0xFF)
Expand All @@ -335,7 +335,7 @@ def timing_budget(self, val):
ms_byte = 0
tmp = macro_period_us * 12
ls_byte = int(((timing_budget_us + ((tmp >> 6) >> 1)) / (tmp >> 6)) - 1)
while ls_byte & 0xFFFFFF00 > 0:
while (ls_byte >> 8) & 0xFFFFFF > 0:
ls_byte >>= 1
ms_byte += 1
ms_byte = (ms_byte << 8) + (ls_byte & 0xFF)
Expand Down

0 comments on commit 4b9259f

Please sign in to comment.