Skip to content

Update _reset() #13

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 2 commits into from
Dec 6, 2021
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
20 changes: 10 additions & 10 deletions adafruit_ltr390.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,16 @@ def initialize(self):
# ltr.configInterrupt(true, LTR390_MODE_UVS);

def _reset(self):
try:
self._reset_bit = True
except OSError:
# The write to the reset bit will fail because it seems to not ACK before it resets
pass

sleep(0.1)
# check that reset is complete w/ the bit unset
if self._reset_bit:
raise RuntimeError("Unable to reset sensor")
# The LTR390 software reset is ill behaved and can leave I2C bus in bad state.
# Instead, just manually set register reset values per datasheet.
with self.i2c_device as i2c:
i2c.write(bytes((_CTRL, 0x00)))
i2c.write(bytes((_MEAS_RATE, 0x22)))
i2c.write(bytes((_GAIN, 0x01)))
i2c.write(bytes((_INT_CFG, 0x10)))
i2c.write(bytes((_INT_PST, 0x00)))
i2c.write(bytes((_THRESH_UP, 0xFF, 0xFF, 0x0F)))
i2c.write(bytes((_THRESH_LOW, 0x00, 0x00, 0x00)))

@property
def _mode(self):
Expand Down