diff options
Diffstat (limited to 'klippy/extras/temperature_host.py')
-rw-r--r-- | klippy/extras/temperature_host.py | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/klippy/extras/temperature_host.py b/klippy/extras/temperature_host.py index 94a73603..c2e116de 100644 --- a/klippy/extras/temperature_host.py +++ b/klippy/extras/temperature_host.py @@ -9,6 +9,7 @@ import logging HOST_REPORT_TIME = 1.0 RPI_PROC_TEMP_FILE = "/sys/class/thermal/thermal_zone0/temp" + class Temperature_HOST: def __init__(self, config): self.printer = config.get_printer() @@ -19,18 +20,15 @@ class Temperature_HOST: self.temp = self.min_temp = self.max_temp = 0.0 self.printer.add_object("temperature_host " + self.name, self) - if self.printer.get_start_args().get('debugoutput') is not None: + if self.printer.get_start_args().get("debugoutput") is not None: return - self.sample_timer = self.reactor.register_timer( - self._sample_pi_temperature) + self.sample_timer = self.reactor.register_timer(self._sample_pi_temperature) try: self.file_handle = open(self.path, "r") except: - raise config.error("Unable to open temperature file '%s'" - % (self.path,)) + raise config.error("Unable to open temperature file '%s'" % (self.path,)) - self.printer.register_event_handler("klippy:connect", - self.handle_connect) + self.printer.register_event_handler("klippy:connect", self.handle_connect) def handle_connect(self): self.reactor.update_timer(self.sample_timer, self.reactor.NOW) @@ -48,7 +46,7 @@ class Temperature_HOST: def _sample_pi_temperature(self, eventtime): try: self.file_handle.seek(0) - self.temp = float(self.file_handle.read())/1000.0 + self.temp = float(self.file_handle.read()) / 1000.0 except Exception: logging.exception("temperature_host: Error reading data") self.temp = 0.0 @@ -57,20 +55,28 @@ class Temperature_HOST: if self.temp < self.min_temp: self.printer.invoke_shutdown( "HOST temperature %0.1f below minimum temperature of %0.1f." - % (self.temp, self.min_temp,)) + % ( + self.temp, + self.min_temp, + ) + ) if self.temp > self.max_temp: self.printer.invoke_shutdown( "HOST temperature %0.1f above maximum temperature of %0.1f." - % (self.temp, self.max_temp,)) + % ( + self.temp, + self.max_temp, + ) + ) - mcu = self.printer.lookup_object('mcu') + mcu = self.printer.lookup_object("mcu") measured_time = self.reactor.monotonic() self._callback(mcu.estimated_print_time(measured_time), self.temp) return measured_time + HOST_REPORT_TIME def get_status(self, eventtime): return { - 'temperature': round(self.temp, 2), + "temperature": round(self.temp, 2), } |