Skip to content

Commit cb29ed9

Browse files
committed
Remove stop kwarg and use write_then_readinto.
See adafruit/circuitpython#2082 for details.
1 parent 8511972 commit cb29ed9

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

adafruit_ccs811.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __init__(self, i2c_bus, address=0x5A):
107107
buf = bytearray(1)
108108
buf[0] = 0xF4
109109
with self.i2c_device as i2c:
110-
i2c.write(buf, end=1, stop=True)
110+
i2c.write(buf, end=1)
111111
time.sleep(.1)
112112

113113
#make sure there are no errors and we have entered application mode
@@ -132,17 +132,15 @@ def error_code(self):
132132
buf = bytearray(2)
133133
buf[0] = 0xE0
134134
with self.i2c_device as i2c:
135-
i2c.write(buf, end=1, stop=False)
136-
i2c.readinto(buf, start=1)
135+
i2c.write_then_readinto(buf, buf, out_end=1, in_start=1)
137136
return buf[1]
138137

139138
def _update_data(self):
140139
if self.data_ready:
141140
buf = bytearray(9)
142141
buf[0] = _ALG_RESULT_DATA
143142
with self.i2c_device as i2c:
144-
i2c.write(buf, end=1, stop=False)
145-
i2c.readinto(buf, start=1)
143+
i2c.write_then_readinto(buf, buf, out_end=1, in_start=1)
146144

147145
self._eco2 = (buf[1] << 8) | (buf[2])
148146
self._tvoc = (buf[3] << 8) | (buf[4])
@@ -168,8 +166,7 @@ def temperature(self):
168166
buf = bytearray(5)
169167
buf[0] = _NTC
170168
with self.i2c_device as i2c:
171-
i2c.write(buf, end=1, stop=False)
172-
i2c.readinto(buf, start=1)
169+
i2c.write_then_readinto(buf, buf, out_end=1, in_start=1)
173170

174171
vref = (buf[1] << 8) | buf[2]
175172
vntc = (buf[3] << 8) | buf[4]

0 commit comments

Comments
 (0)