@@ -75,16 +75,16 @@ def __init__(self, i2c_bus, address=0x18):
75
75
self .buf = bytearray (3 )
76
76
self .buf [0 ] = 0x06
77
77
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 )
80
80
81
81
ok = self .buf [2 ] == 0x54 and self .buf [1 ] == 0
82
82
83
83
# Check device id.
84
84
self .buf [0 ] = 0x07
85
85
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 )
88
88
89
89
if not ok or self .buf [1 ] != 0x04 :
90
90
raise ValueError ("Unable to find MCP9808 at i2c address " + str (hex (address )))
@@ -94,8 +94,8 @@ def temperature(self):
94
94
"""Temperature in celsius. Read-only."""
95
95
self .buf [0 ] = 0x05
96
96
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 )
99
99
100
100
# Clear flags from the value
101
101
self .buf [1 ] = self .buf [1 ] & 0x1f
0 commit comments