Skip to content

Commit

Permalink
Merge pull request #15 from tannewt/remove_stop
Browse files Browse the repository at this point in the history
Remove stop kwarg and use write_then_readinto.
  • Loading branch information
jerryneedell committed Aug 23, 2019
2 parents fe6796f + c6de17f commit 7e30aad
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions adafruit_lsm9ds1.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,8 @@ def _read_u8(self, sensor_type, address):
device = self._xg_device
with 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, in_end=2)
return self._BUFFER[1]

def _read_bytes(self, sensor_type, address, count, buf):
if sensor_type == _MAGTYPE:
Expand All @@ -388,8 +387,7 @@ def _read_bytes(self, sensor_type, address, count, buf):
device = self._xg_device
with device as i2c:
buf[0] = address & 0xFF
i2c.write(buf, end=1, stop=False)
i2c.readinto(buf, end=count)
i2c.write_then_readinto(buf, buf, out_end=1, in_end=count)

def _write_u8(self, sensor_type, address, val):
if sensor_type == _MAGTYPE:
Expand Down

0 comments on commit 7e30aad

Please sign in to comment.