Skip to content

Add ValueError to start_range_continuous() #28

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 2 commits into from
Apr 27, 2022
Merged
Changes from all commits
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
16 changes: 9 additions & 7 deletions adafruit_vl6180x.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,17 @@ def range_history_enabled(self) -> bool:
def start_range_continuous(self, period: int = 100) -> None:
"""Start continuous range mode

:param int period: Time delay between measurements, in milliseconds
:param int period: Time delay between measurements, in milliseconds; the value you
will be floored to the nearest 10 milliseconds (setting to 157 ms sets it to 150
ms). Range is 10 - 2550 ms.
"""
# Set range between measurements
period_reg: int = 0
if period > 10:
if period < 2250:
period_reg = (period // 10) - 1
else:
period_reg = 254
if not 10 <= period <= 2550:
raise ValueError(
"Delay must be in 10 millisecond increments between 10 and 2550 milliseconds"
)

period_reg = (period // 10) - 1
self._write_8(_VL6180X_REG_SYSRANGE_INTERMEASUREMENT_PERIOD, period_reg)

# Start continuous range measurement
Expand Down