aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2021-02-01 11:30:27 -0500
committerKevin O'Connor <kevin@koconnor.net>2021-02-01 11:30:27 -0500
commit6e79152f47b67a7090d57efe93cb6b7219a9ea55 (patch)
tree4dca0777bd1a0743b524ebe5f917ee50da4449c8
parenta15952770bfce2fe68a754f4d1a4348a9bbd8393 (diff)
downloadkutter-6e79152f47b67a7090d57efe93cb6b7219a9ea55.tar.gz
kutter-6e79152f47b67a7090d57efe93cb6b7219a9ea55.tar.xz
kutter-6e79152f47b67a7090d57efe93cb6b7219a9ea55.zip
htu21d: Implement support for min_temp/max_temp checks
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/extras/htu21d.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/klippy/extras/htu21d.py b/klippy/extras/htu21d.py
index 2a7237da..571642de 100644
--- a/klippy/extras/htu21d.py
+++ b/klippy/extras/htu21d.py
@@ -92,7 +92,7 @@ class HTU21D:
raise config.error("Invalid HTU21D Resolution. Valid are %s"
% '|'.join(HTU21D_RESOLUTIONS.keys()))
self.deviceId = config.get('sensor_type')
- self.temp = self.humidity = 0.
+ self.temp = self.min_temp = self.max_temp = self.humidity = 0.
self.sample_timer = self.reactor.register_timer(self._sample_htu21d)
self.printer.add_object("htu21d " + self.name, self)
self.printer.register_event_handler("klippy:connect",
@@ -103,7 +103,8 @@ class HTU21D:
self.reactor.update_timer(self.sample_timer, self.reactor.NOW)
def setup_minmax(self, min_temp, max_temp):
- pass
+ self.min_temp = min_temp
+ self.max_temp = max_temp
def setup_callback(self, cb):
self._callback = cb
@@ -211,6 +212,11 @@ class HTU21D:
self.temp = self.humidity = .0
return self.reactor.NEVER
+ if self.temp < self.min_temp or self.temp > self.max_temp:
+ self.printer.invoke_shutdown(
+ "HTU21D temperature %0.1f outside range of %0.1f:%.01f"
+ % (self.temp, self.min_temp, self.max_temp))
+
measured_time = self.reactor.monotonic()
print_time = self.i2c.get_mcu().estimated_print_time(measured_time)
self._callback(print_time, self.temp)