Skip to content

Commit c3e206b

Browse files
committed
Update adafruit_vl53l1x.py
Proposed changes
1 parent a5ebcca commit c3e206b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

adafruit_vl53l1x.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,8 @@ def distance_mode(self, mode):
301301
def roi_xy(self):
302302
"""Returns the x and y coordinates of the sensor's region of interest"""
303303
temp = self._read_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE)
304-
305-
x = (int.from_bytes(temp) & 0x0F) + 1
306-
y = ((int.from_bytes(temp) & 0xF0) >> 4) + 1
304+
x = (int.from_bytes(temp, 'little') & 0x0F) + 1
305+
y = ((int.from_bytes(temp, 'little') & 0xF0) >> 4) + 1
307306

308307
return x, y
309308

@@ -319,22 +318,22 @@ def roi_xy(self, data):
319318
optical_center = 199
320319

321320
self._write_register(
322-
_ROI_CONFIG__USER_ROI_CENTRE_SPAD, optical_center.to_bytes()
321+
_ROI_CONFIG__USER_ROI_CENTRE_SPAD, optical_center.to_bytes(1,'little')
323322
)
324323
self._write_register(
325324
_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE,
326-
((y - 1) << 4 | (x - 1)).to_bytes(),
325+
((y - 1) << 4 | (x - 1)).to_bytes(1,'little'),
327326
)
328327

329328
@property
330329
def roi_center(self):
331330
"""Returns the center of the sensor's region of interest"""
332331
temp = self._read_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD)
333-
return int.from_bytes(temp)
332+
return int.from_bytes(temp, 'little')
334333

335334
@roi_center.setter
336335
def roi_center(self, center):
337-
self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, center.to_bytes())
336+
self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, center.to_bytes(1,'little'))
338337

339338
def _write_register(self, address, data, length=None):
340339
if length is None:

0 commit comments

Comments
 (0)