@@ -210,8 +210,8 @@ def gesture(self): #pylint: disable-msg=too-many-branches
210
210
if n_recs :
211
211
212
212
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 ))
215
215
upp , down , left , right = buffer [1 :5 ]
216
216
217
217
if abs (upp - down ) > 13 :
@@ -356,8 +356,7 @@ def _read8(self, command):
356
356
buf = self .buf2
357
357
buf [0 ] = command
358
358
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 )
361
360
return buf [0 ]
362
361
363
362
def _color_data16 (self , command ):
@@ -366,6 +365,5 @@ def _color_data16(self, command):
366
365
buf = self .buf2
367
366
buf [0 ] = command
368
367
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 )
371
369
return buf [1 ] << 8 | buf [0 ]
0 commit comments