Skip to content

Commit 09b1225

Browse files
authored
Merge pull request #9 from ladyada/master
use new write_then_readinto for repeated start
2 parents cd2c7a4 + 57e8f65 commit 09b1225

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

adafruit_fxos8700.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def _read_u8(self, address):
139139
# Read an 8-bit unsigned value from the specified 8-bit address.
140140
with self._device as i2c:
141141
self._BUFFER[0] = address & 0xFF
142-
i2c.write(self._BUFFER, end=1, stop=False)
143-
i2c.readinto(self._BUFFER, end=1)
142+
i2c.write_then_readinto(self._BUFFER, self._BUFFER,
143+
out_end=1, in_end=1, stop=False)
144144
return self._BUFFER[0]
145145

146146
def _write_u8(self, address, val):
@@ -163,8 +163,9 @@ def read_raw_accel_mag(self):
163163
# Read accelerometer data from sensor.
164164
with self._device as i2c:
165165
self._BUFFER[0] = _FXOS8700_REGISTER_OUT_X_MSB
166-
i2c.write(self._BUFFER, end=1, stop=False)
167-
i2c.readinto(self._BUFFER, end=6)
166+
i2c.write_then_readinto(self._BUFFER, self._BUFFER,
167+
out_end=1, in_end=6,
168+
stop=False)
168169
accel_raw_x = struct.unpack_from('>H', self._BUFFER[0:2])[0]
169170
accel_raw_y = struct.unpack_from('>H', self._BUFFER[2:4])[0]
170171
accel_raw_z = struct.unpack_from('>H', self._BUFFER[4:6])[0]
@@ -177,8 +178,9 @@ def read_raw_accel_mag(self):
177178
# 16-bit signed data so struct parsing can handle it directly.
178179
with self._device as i2c:
179180
self._BUFFER[0] = _FXOS8700_REGISTER_MOUT_X_MSB
180-
i2c.write(self._BUFFER, end=1, stop=False)
181-
i2c.readinto(self._BUFFER, end=6)
181+
i2c.write_then_readinto(self._BUFFER, self._BUFFER,
182+
out_end=1, in_end=6,
183+
stop=False)
182184
mag_raw_x = struct.unpack_from('>h', self._BUFFER[0:2])[0]
183185
mag_raw_y = struct.unpack_from('>h', self._BUFFER[2:4])[0]
184186
mag_raw_z = struct.unpack_from('>h', self._BUFFER[4:6])[0]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Adafruit-Blinka
2-
adafruit-circuitpython-busdevice
2+
adafruit-circuitpython-busdevice>=2.2.5

0 commit comments

Comments
 (0)