Skip to content

Remove stop kwarg and use write_then_readinto. #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2019
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
10 changes: 4 additions & 6 deletions adafruit_vcnl4010.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,15 @@ def _read_u8(self, address):
# Read an 8-bit unsigned value from the specified 8-bit address.
with self._device as i2c:
self._BUFFER[0] = address & 0xFF
i2c.write(self._BUFFER, end=1, stop=False)
i2c.readinto(self._BUFFER, end=1)
return self._BUFFER[0]
i2c.write_then_readinto(self._BUFFER, self._BUFFER, out_end=1, in_start=1)
return self._BUFFER[1]

def _read_u16BE(self, address):
# Read a 16-bit big-endian unsigned value from the specified 8-bit address.
with self._device as i2c:
self._BUFFER[0] = address & 0xFF
i2c.write(self._BUFFER, end=1, stop=False)
i2c.readinto(self._BUFFER, end=2)
return (self._BUFFER[0] << 8) | self._BUFFER[1]
i2c.write_then_readinto(self._BUFFER, self._BUFFER, out_end=1, in_start=1)
return (self._BUFFER[1] << 8) | self._BUFFER[2]

def _write_u8(self, address, val):
# Write an 8-bit unsigned value to the specified 8-bit address.
Expand Down