Skip to content

Commit 6324f27

Browse files
authored
Merge pull request #13 from tannewt/remove_stop
Remove stop kwarg and use write_then_readinto.
2 parents 68f818f + a4315e2 commit 6324f27

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

adafruit_apds9960/apds9960.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ def gesture(self): #pylint: disable-msg=too-many-branches
210210
if n_recs:
211211

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

217217
if abs(upp - down) > 13:
@@ -356,8 +356,7 @@ def _read8(self, command):
356356
buf = self.buf2
357357
buf[0] = command
358358
with self.i2c_device as i2c:
359-
i2c.write(buf, end=1)
360-
i2c.readinto(buf, end=1)
359+
i2c.write_then_readinto(buf, buf, out_end=1, in_end=1)
361360
return buf[0]
362361

363362
def _color_data16(self, command):
@@ -366,6 +365,5 @@ def _color_data16(self, command):
366365
buf = self.buf2
367366
buf[0] = command
368367
with self.i2c_device as i2c:
369-
i2c.write(buf, end=1, stop=False)
370-
i2c.readinto(buf)
368+
i2c.write_then_readinto(buf, buf, out_end=1)
371369
return buf[1] << 8 | buf[0]

0 commit comments

Comments
 (0)