Skip to content

Commit 31799b9

Browse files
authored
Merge pull request #8 from caternuson/iss7_range_check
Add range status check
2 parents bfd6a32 + 061e127 commit 31799b9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

adafruit_vl53l1x.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
_SD_CONFIG__INITIAL_PHASE_SD0 = const(0x007A)
4949
_SYSTEM__INTERRUPT_CLEAR = const(0x0086)
5050
_SYSTEM__MODE_START = const(0x0087)
51+
_VL53L1X_RESULT__RANGE_STATUS = const(0x0089)
5152
_VL53L1X_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 = const(0x0096)
5253
_VL53L1X_IDENTIFICATION__MODEL_ID = const(0x010F)
5354

@@ -201,6 +202,8 @@ def model_info(self):
201202
@property
202203
def distance(self):
203204
"""The distance in units of centimeters."""
205+
if self._read_register(_VL53L1X_RESULT__RANGE_STATUS)[0] != 0x09:
206+
return None
204207
dist = self._read_register(
205208
_VL53L1X_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0, 2
206209
)

0 commit comments

Comments
 (0)