Skip to content
Merged
Changes from all 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
6 changes: 4 additions & 2 deletions adafruit_vl6180x.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,15 @@ def _read_8(self, address):
# Read and return a byte from the specified 16-bit register address.
with self._device as i2c:
result = bytearray(1)
i2c.write_then_readinto(bytes([(address >> 8) & 0xFF, address & 0xFF]), result)
i2c.write(bytes([(address >> 8) & 0xFF, address & 0xFF]))
i2c.readinto(result)
return result[0]

def _read_16(self, address):
# Read and return a 16-bit unsigned big endian value read from the
# specified 16-bit register address.
with self._device as i2c:
result = bytearray(2)
i2c.write_then_readinto(bytes([(address >> 8) & 0xFF, address & 0xFF]), result)
i2c.write(bytes([(address >> 8) & 0xFF, address & 0xFF]))
i2c.readinto(result)
return (result[0] << 8) | result[1]