@@ -122,8 +122,8 @@ def _read_u8(self, address):
122
122
# Read an 8-bit unsigned value from the specified 8-bit address.
123
123
with self ._device as i2c :
124
124
self ._BUFFER [0 ] = address & 0xFF
125
- i2c . write (self ._BUFFER , end = 1 , stop = False )
126
- i2c . readinto ( self . _BUFFER , end = 1 )
125
+ self . _device . write_then_readinto (self ._BUFFER , self . _BUFFER ,
126
+ out_end = 1 , in_end = 1 , stop = False )
127
127
return self ._BUFFER [0 ]
128
128
129
129
def _write_u8 (self , address , val ):
@@ -141,8 +141,8 @@ def read_raw(self):
141
141
# Read gyro data from the sensor.
142
142
with self ._device :
143
143
self ._BUFFER [0 ] = _GYRO_REGISTER_OUT_X_MSB
144
- self ._device .write (self ._BUFFER , end = 1 , stop = False )
145
- self . _device . readinto ( self . _BUFFER )
144
+ self ._device .write_then_readinto (self ._BUFFER , self . _BUFFER ,
145
+ out_end = 1 , stop = False )
146
146
# Parse out the gyroscope data as 16-bit signed data.
147
147
raw_x = struct .unpack_from ('>h' , self ._BUFFER [0 :2 ])[0 ]
148
148
raw_y = struct .unpack_from ('>h' , self ._BUFFER [2 :4 ])[0 ]
0 commit comments