bme280: Implement support for min_temp/max_temp checks
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
55185e9a7e
commit
a15952770b
|
@ -32,6 +32,7 @@ class BME280:
|
||||||
self.os_hum = config.getint('bme280_oversample_hum', 2)
|
self.os_hum = config.getint('bme280_oversample_hum', 2)
|
||||||
self.os_pres = config.getint('bme280_oversample_pressure', 2)
|
self.os_pres = config.getint('bme280_oversample_pressure', 2)
|
||||||
self.temp = self.pressure = self.humidity = self.t_fine = 0.
|
self.temp = self.pressure = self.humidity = self.t_fine = 0.
|
||||||
|
self.min_temp = self.max_temp = 0.
|
||||||
self.max_sample_time = \
|
self.max_sample_time = \
|
||||||
(1.25 + (2.3 * self.os_temp) + ((2.3 * self.os_pres) +
|
(1.25 + (2.3 * self.os_temp) + ((2.3 * self.os_pres) +
|
||||||
.575) + ((2.3 * self.os_hum) + .575)) / 1000
|
.575) + ((2.3 * self.os_hum) + .575)) / 1000
|
||||||
|
@ -48,7 +49,8 @@ class BME280:
|
||||||
self.reactor.update_timer(self.sample_timer, self.reactor.NOW)
|
self.reactor.update_timer(self.sample_timer, self.reactor.NOW)
|
||||||
|
|
||||||
def setup_minmax(self, min_temp, max_temp):
|
def setup_minmax(self, min_temp, max_temp):
|
||||||
pass
|
self.min_temp = min_temp
|
||||||
|
self.max_temp = max_temp
|
||||||
|
|
||||||
def setup_callback(self, cb):
|
def setup_callback(self, cb):
|
||||||
self._callback = cb
|
self._callback = cb
|
||||||
|
@ -135,6 +137,10 @@ class BME280:
|
||||||
self.temp = self._compensate_temp(temp_raw)
|
self.temp = self._compensate_temp(temp_raw)
|
||||||
self.pressure = self._compensate_pressure(pressure_raw) / 100.
|
self.pressure = self._compensate_pressure(pressure_raw) / 100.
|
||||||
self.humidity = self._compensate_humidity(humid_raw)
|
self.humidity = self._compensate_humidity(humid_raw)
|
||||||
|
if self.temp < self.min_temp or self.temp > self.max_temp:
|
||||||
|
self.printer.invoke_shutdown(
|
||||||
|
"BME280 temperature %0.1f outside range of %0.1f:%.01f"
|
||||||
|
% (self.temp, self.min_temp, self.max_temp))
|
||||||
measured_time = self.reactor.monotonic()
|
measured_time = self.reactor.monotonic()
|
||||||
self._callback(self.mcu.estimated_print_time(measured_time), self.temp)
|
self._callback(self.mcu.estimated_print_time(measured_time), self.temp)
|
||||||
return measured_time + REPORT_TIME
|
return measured_time + REPORT_TIME
|
||||||
|
|
Loading…
Reference in New Issue