Skip to content

Commit

Permalink
Merge pull request #8 from caternuson/iss7
Browse files Browse the repository at this point in the history
Remove ready-wait in temperature read.
  • Loading branch information
ladyada authored Feb 21, 2020
2 parents 595bec6 + a7d0f0f commit e8c81bf
Showing 1 changed file with 6 additions and 5 deletions.
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

0 comments on commit e8c81bf

Please sign in to comment.