Skip to content

Remove stop kwarg and use write_then_readinto. #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions adafruit_ccs811.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(self, i2c_bus, address=0x5A):
buf = bytearray(1)
buf[0] = 0xF4
with self.i2c_device as i2c:
i2c.write(buf, end=1, stop=True)
i2c.write(buf, end=1)
time.sleep(.1)

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

def _update_data(self):
if self.data_ready:
buf = bytearray(9)
buf[0] = _ALG_RESULT_DATA
with self.i2c_device as i2c:
i2c.write(buf, end=1, stop=False)
i2c.readinto(buf, start=1)
i2c.write_then_readinto(buf, buf, out_end=1, in_start=1)

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

vref = (buf[1] << 8) | buf[2]
vntc = (buf[3] << 8) | buf[4]
Expand Down