Skip to content

Commit 3669549

Browse files
committed
update read_reg()
1 parent 466e0c0 commit 3669549

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

adafruit_mlx90393.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,12 @@ def read_reg(self, reg: int) -> int:
406406
407407
:param int reg: The register to read
408408
"""
409-
# Write 'value' to the specified register
409+
# Read register
410410
payload = bytes([_CMD_RR, reg << 2])
411-
with self.i2c_device as i2c:
412-
i2c.write(payload)
413-
414-
# Read the response (+1 to account for the mandatory status byte!)
415411
data = bytearray(3)
416412
with self.i2c_device as i2c:
417-
i2c.readinto(data)
413+
i2c.write_then_readinto(payload, data)
414+
418415
# Unpack data (status byte, big-endian 16-bit register value)
419416
self._status_last, val = struct.unpack(">BH", data)
420417
if self._debug:

0 commit comments

Comments
 (0)