Skip to content

Measurement quality #9

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 6 commits into from
Feb 26, 2024
Merged
Changes from 3 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
58 changes: 58 additions & 0 deletions adafruit_vl53l4cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,64 @@ def distance(self):
dist = struct.unpack(">H", dist)[0]
return dist / 10

@property
def range_status(self):
"""Measurement validity. Returns a number between 0 to 255 where:
0 - None - Returned distance is valid
1 - Warning - Sigma is above the defined threshold
2 - Warning - Signal is below the defined threshold
3 - Error - Measured distance is below detection threshold
4 - Error - Phase out of valid limit
5 - Error - Hardware fail
6 - Warning - Phase valid but no wrap around check performed
7 - Error - Wrapped target, phase does not match
8 - Error - Processing fail
9 - Error - Crosstalk signal fail
10 - Error - Interrupt error
11 - Error - Merged target
12 - Error - Signal is too low
255 - Error - Other error (for example, boot error)
"""
status_rtn = [
255,
255,
255,
5,
2,
4,
1,
7,
3,
0,
255,
255,
9,
13,
255,
255,
255,
255,
10,
6,
255,
255,
11,
12,
]
status = self._read_register(_VL53L4CD_RESULT_RANGE_STATUS, 1)
status = struct.unpack(">B", status)[0]
status = status & 0x1F
if status < 24:
status = status_rtn[status]
return status

@property
def sigma(self):
"""Sigma estimator for the noise in the reported target distance in units of centimeters."""
sigma = self._read_register(_VL53L4CD_RESULT_SIGMA, 2)
sigma = struct.unpack(">H", sigma)[0]
return sigma / 40

@property
def timing_budget(self):
"""Ranging duration in milliseconds. Valid range is 10ms to 200ms."""
Expand Down