Skip to content

Commit 64231e2

Browse files
authored
Merge pull request #34 from tannewt/remove_stop
Remove stop kwarg and use write_then_readinto.
2 parents 021a42b + cb29ed9 commit 64231e2

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])
@@ -172,8 +170,7 @@ def temperature(self):
172170
buf = bytearray(5)
173171
buf[0] = _NTC
174172
with self.i2c_device as i2c:
175-
i2c.write(buf, end=1, stop=False)
176-
i2c.readinto(buf, start=1)
173+
i2c.write_then_readinto(buf, buf, out_end=1, in_start=1)
177174

178175
vref = (buf[1] << 8) | buf[2]
179176
vntc = (buf[3] << 8) | buf[4]

0 commit comments

Comments
 (0)