@@ -75,16 +75,16 @@ def __init__(self, i2c_bus, address=0x18):
7575 self .buf = bytearray (3 )
7676 self .buf [0 ] = 0x06
7777 with self .i2c_device as i2c :
78- i2c .write (self .buf , end = 1 , stop = False )
79- i2c . readinto ( self . buf , start = 1 )
78+ i2c .write_then_readinto (self .buf , self . buf ,
79+ out_end = 1 , in_start = 1 )
8080
8181 ok = self .buf [2 ] == 0x54 and self .buf [1 ] == 0
8282
8383 # Check device id.
8484 self .buf [0 ] = 0x07
8585 with self .i2c_device as i2c :
86- i2c .write (self .buf , end = 1 , stop = False )
87- i2c . readinto ( self . buf , start = 1 )
86+ i2c .write_then_readinto (self .buf , self . buf ,
87+ out_end = 1 , in_start = 1 )
8888
8989 if not ok or self .buf [1 ] != 0x04 :
9090 raise ValueError ("Unable to find MCP9808 at i2c address " + str (hex (address )))
@@ -94,8 +94,8 @@ def temperature(self):
9494 """Temperature in celsius. Read-only."""
9595 self .buf [0 ] = 0x05
9696 with self .i2c_device as i2c :
97- i2c .write (self .buf , end = 1 , stop = False )
98- i2c . readinto ( self . buf , start = 1 )
97+ i2c .write_then_readinto (self .buf , self . buf ,
98+ out_end = 1 , in_start = 1 )
9999
100100 # Clear flags from the value
101101 self .buf [1 ] = self .buf [1 ] & 0x1f
0 commit comments