@@ -107,17 +107,15 @@ def _read_u8(self, address):
107
107
# Read an 8-bit unsigned value from the specified 8-bit address.
108
108
with self ._device as i2c :
109
109
self ._BUFFER [0 ] = address & 0xFF
110
- i2c .write (self ._BUFFER , end = 1 , stop = False )
111
- i2c .readinto (self ._BUFFER , end = 1 )
112
- return self ._BUFFER [0 ]
110
+ i2c .write_then_readinto (self ._BUFFER , self ._BUFFER , out_end = 1 , in_start = 1 )
111
+ return self ._BUFFER [1 ]
113
112
114
113
def _read_u16BE (self , address ):
115
114
# Read a 16-bit big-endian unsigned value from the specified 8-bit address.
116
115
with self ._device as i2c :
117
116
self ._BUFFER [0 ] = address & 0xFF
118
- i2c .write (self ._BUFFER , end = 1 , stop = False )
119
- i2c .readinto (self ._BUFFER , end = 2 )
120
- return (self ._BUFFER [0 ] << 8 ) | self ._BUFFER [1 ]
117
+ i2c .write_then_readinto (self ._BUFFER , self ._BUFFER , out_end = 1 , in_start = 1 )
118
+ return (self ._BUFFER [1 ] << 8 ) | self ._BUFFER [2 ]
121
119
122
120
def _write_u8 (self , address , val ):
123
121
# Write an 8-bit unsigned value to the specified 8-bit address.
0 commit comments