lm75: Implement support for min_temp/max_temp checks
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
7775e0ed54
commit
333f8c210f
|
@ -31,7 +31,7 @@ class LM75:
|
||||||
self.mcu = self.i2c.get_mcu()
|
self.mcu = self.i2c.get_mcu()
|
||||||
self.report_time = config.getfloat('lm75_report_time', LM75_REPORT_TIME,
|
self.report_time = config.getfloat('lm75_report_time', LM75_REPORT_TIME,
|
||||||
minval=LM75_MIN_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.sample_timer = self.reactor.register_timer(self._sample_lm75)
|
||||||
self.printer.add_object("lm75 " + self.name, self)
|
self.printer.add_object("lm75 " + self.name, self)
|
||||||
self.printer.register_event_handler("klippy:connect",
|
self.printer.register_event_handler("klippy:connect",
|
||||||
|
@ -42,7 +42,8 @@ class LM75:
|
||||||
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
|
||||||
|
@ -73,6 +74,11 @@ class LM75:
|
||||||
self.temp = 0.0
|
self.temp = 0.0
|
||||||
return self.reactor.NEVER
|
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()
|
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 + self.report_time
|
return measured_time + self.report_time
|
||||||
|
|
Loading…
Reference in New Issue