Skip to content

Support non-longint builds #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading