File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,6 +107,13 @@ def trigger_one_shot(self):
107107 self ._write_reg (HTS221_CTRL_REG2 , ctrl2 | HTS221_CTRL2_ONE_SHOT )
108108 sleep_ms (15 )
109109
110+ def reboot (self ):
111+ ctrl2 = self ._read_reg (HTS221_CTRL_REG2 )
112+ self ._write_reg (HTS221_CTRL_REG2 , ctrl2 | HTS221_CTRL2_BOOT )
113+ sleep_ms (15 )
114+ self ._read_temperature_calibration ()
115+ self ._read_humidity_calibration ()
116+
110117 def _ensure_data (self ):
111118 if self ._is_power_down () or self ._is_one_shot_mode ():
112119 self .trigger_one_shot ()
Original file line number Diff line number Diff line change @@ -109,6 +109,25 @@ tests:
109109 expect_not_none : true
110110 mode : [mock]
111111
112+ - name : " Reboot reloads calibration"
113+ action : script
114+ script : |
115+ dev.reboot()
116+ result = isinstance(dev.temperature(), float)
117+ expect_true : true
118+ mode : [mock]
119+
120+ - name : " Reboot writes BOOT bit"
121+ action : script
122+ script : |
123+ i2c.clear_write_log()
124+ dev.reboot()
125+ log = i2c.get_write_log()
126+ wrote_boot = any(reg == 0x21 and (data[0] & 0x80) for reg, data in log)
127+ result = wrote_boot
128+ expect_true : true
129+ mode : [mock]
130+
112131 - name : " Temperature with offset"
113132 action : script
114133 script : |
You can’t perform that action at this time.
0 commit comments