Skip to content

Remove ready-wait in temperature read. #8

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 4 commits into from
Feb 21, 2020
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: 6 additions & 5 deletions adafruit_adt7410.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,11 @@ def __init__(self, i2c_bus, address=0x48):
_id = (self._read_register(_ADT7410_ID)[0]) & 0xF8
if _id != 0xC8:
raise ValueError("Unable to find ADT7410 at i2c address " + str(hex(address)))
# Perform a software reset
self._write_register(_ADT7410_SWRST)
time.sleep(0.01)
self.reset()

@property
def temperature(self):
"""The temperature in celsius"""
while not self.ready:
pass
temp = self._read_register(_ADT7410_TEMPMSB, 2)
return struct.unpack('>h', temp)[0] / 128

Expand All @@ -106,6 +102,11 @@ def configuration(self):
def configuration(self, val):
return self._write_register(_ADT7410_CONFIG, val)

def reset(self):
"""Perform a software reset"""
self._write_register(_ADT7410_SWRST)
time.sleep(0.5)

def _read_register(self, addr, num=1):
self._buf[0] = addr
with self.i2c_device as i2c:
Expand Down