Skip to content

Commit 5285ba8

Browse files
committed
enables ROI useage
This should make the ROI functions work
1 parent 3f15840 commit 5285ba8

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

adafruit_vl53l1x.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ def roi_xy(self):
297297
"""Returns the x and y coordinates of the sensor's region of interest"""
298298
temp = self._read_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE)
299299

300-
x = (int.from_bytes(temp) & 0x0F) + 1
301-
y = ((int.from_bytes(temp) & 0xF0) >> 4) + 1
300+
x = (int.from_bytes(temp, 'big') & 0x0F) + 1
301+
y = ((int.from_bytes(temp, 'big') & 0xF0) >> 4) + 1
302302

303303
return x, y
304304

@@ -313,21 +313,23 @@ def roi_xy(self, data):
313313
if x > 10 or y > 10:
314314
optical_center = 199
315315

316-
self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, optical_center.to_bytes())
316+
self._write_register(
317+
_ROI_CONFIG__USER_ROI_CENTRE_SPAD, optical_center.to_bytes(1, 'big')
318+
)
317319
self._write_register(
318320
_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE,
319-
((y - 1) << 4 | (x - 1)).to_bytes(),
320-
) # noqa: E501
321+
((y - 1) << 4 | (x - 1)).to_bytes(1, 'big'),
322+
)
321323

322324
@property
323325
def roi_center(self):
324326
"""Returns the center of the sensor's region of interest"""
325327
temp = self._read_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD)
326-
return int.from_bytes(temp)
328+
return int.from_bytes(temp,'big')
327329

328330
@roi_center.setter
329331
def roi_center(self, center):
330-
self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, center.to_bytes())
332+
self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, center.to_bytes(1, 'big'))
331333

332334
def _write_register(self, address, data, length=None):
333335
if length is None:

0 commit comments

Comments
 (0)