Skip to content

Remove stop kwarg and use write_then_readinto. #13

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_apds9960/apds9960.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ def gesture(self): #pylint: disable-msg=too-many-branches
if n_recs:

with self.i2c_device as i2c:
i2c.write(buffer, end=1, stop=False)
i2c.readinto(buffer, start=1, end=min(129, 1 + n_recs * 4))
i2c.write_then_readinto(buffer, buffer, out_end=1, in_start=1,
in_end=min(129, 1 + n_recs * 4))
upp, down, left, right = buffer[1:5]

if abs(upp - down) > 13:
Expand Down Expand Up @@ -356,8 +356,7 @@ def _read8(self, command):
buf = self.buf2
buf[0] = command
with self.i2c_device as i2c:
i2c.write(buf, end=1)
i2c.readinto(buf, end=1)
i2c.write_then_readinto(buf, buf, out_end=1, in_end=1)
return buf[0]

def _color_data16(self, command):
Expand All @@ -366,6 +365,5 @@ def _color_data16(self, command):
buf = self.buf2
buf[0] = command
with self.i2c_device as i2c:
i2c.write(buf, end=1, stop=False)
i2c.readinto(buf)
i2c.write_then_readinto(buf, buf, out_end=1)
return buf[1] << 8 | buf[0]