From 333f8c210fa70db53923660738dca118a3323064 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 1 Feb 2021 10:28:44 -0500 Subject: [PATCH] lm75: Implement support for min_temp/max_temp checks Signed-off-by: Kevin O'Connor --- klippy/extras/lm75.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/klippy/extras/lm75.py b/klippy/extras/lm75.py index c1a4a9a0..44e9a6ec 100644 --- a/klippy/extras/lm75.py +++ b/klippy/extras/lm75.py @@ -31,7 +31,7 @@ class LM75: self.mcu = self.i2c.get_mcu() self.report_time = config.getfloat('lm75_report_time', LM75_REPORT_TIME, minval=LM75_MIN_REPORT_TIME) - self.temp = 0.0 + self.temp = self.min_temp = self.max_temp = 0.0 self.sample_timer = self.reactor.register_timer(self._sample_lm75) self.printer.add_object("lm75 " + self.name, self) self.printer.register_event_handler("klippy:connect", @@ -42,7 +42,8 @@ class LM75: 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 @@ -73,6 +74,11 @@ class LM75: self.temp = 0.0 return self.reactor.NEVER + if self.temp < self.min_temp or self.temp > self.max_temp: + self.printer.invoke_shutdown( + "LM75 temperature %0.1f outside range of %0.1f:%.01f" + % (self.temp, self.min_temp, self.max_temp)) + measured_time = self.reactor.monotonic() self._callback(self.mcu.estimated_print_time(measured_time), self.temp) return measured_time + self.report_time