Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions lib/hts221/hts221/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ def trigger_one_shot(self):
self._write_reg(HTS221_CTRL_REG2, ctrl2 | HTS221_CTRL2_ONE_SHOT)
sleep_ms(15)

def reboot(self):
ctrl2 = self._read_reg(HTS221_CTRL_REG2)
self._write_reg(HTS221_CTRL_REG2, ctrl2 | HTS221_CTRL2_BOOT)
sleep_ms(15)
self._read_temperature_calibration()
self._read_humidity_calibration()

def _ensure_data(self):
if self._is_power_down() or self._is_one_shot_mode():
self.trigger_one_shot()
Expand Down
23 changes: 23 additions & 0 deletions tests/scenarios/hts221.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,29 @@ tests:
expect_not_none: true
mode: [mock]

- name: "Reboot re-reads calibration registers"
action: script
script: |
i2c.clear_write_log()
dev.reboot()
# After reboot, calibration registers (0x3C-0x3F) should be re-read
# Verify T0_OUT and T1_OUT are still valid by checking temperature works
t = dev.temperature()
result = isinstance(t, float) and t != 0.0
expect_true: true
mode: [mock]

- name: "Reboot writes BOOT bit"
action: script
script: |
i2c.clear_write_log()
dev.reboot()
log = i2c.get_write_log()
wrote_boot = any(reg == 0x21 and (data[0] & 0x80) for reg, data in log)
result = wrote_boot
expect_true: true
mode: [mock]

- name: "Temperature with offset"
action: script
script: |
Expand Down