diff --git a/docs/Command_Templates.md b/docs/Command_Templates.md index 125436ee..afa390af 100644 --- a/docs/Command_Templates.md +++ b/docs/Command_Templates.md @@ -267,7 +267,7 @@ The following are common printer attributes: from the sensor. - `printer["lm75 "].temperature`: The last read temperature from the sensor. -- `printer["rpi_temperature "].temperature`: The last read +- `printer["temperature_host "].temperature`: The last read temperature from the sensor. - `printer["temperature_sensor "].temperature`: The last read temperature from the sensor. diff --git a/docs/Config_Changes.md b/docs/Config_Changes.md index 19b745d2..ffc9a1fb 100644 --- a/docs/Config_Changes.md +++ b/docs/Config_Changes.md @@ -6,6 +6,12 @@ All dates in this document are approximate. # Changes +20210219: The `rpi_temperature` module has been renamed to +`temperature_host`. Replace any occurrences of `sensor_type: +rpi_temperature` with `sensor_type: temperature_host`. The +`rpi_temperature` name is deprecated and will be removed in the near +future. + 20210201: The `TEST_RESONANCES` command will now disable input shaping if it was previously enabled (and re-enable it after the test). In order to override this behavior and keep the input shaping enabled, one can diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 57fbe3df..701c32a3 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -2145,12 +2145,16 @@ sensor_type: temperature_mcu # micro-controller specification. ``` -## RPi temperature sensor +## Host temperature sensor -CPU temperature from the Raspberry Pi running the host software. +Temperature from the machine (eg Raspberry Pi) running the host software. ``` -sensor_type: rpi_temperature +sensor_type: temperature_host +#path: +# The path to temperature system file. The default is +# "/sys/class/thermal/thermal_zone0/temp" which is the temperature +# system file on a Raspberry Pi computer. ``` ## DS18B20 temperature sensor diff --git a/klippy/extras/heaters.py b/klippy/extras/heaters.py index a7aec4fa..cf7fd909 100644 --- a/klippy/extras/heaters.py +++ b/klippy/extras/heaters.py @@ -264,7 +264,7 @@ class PrinterHeaters: return self.heaters[heater_name] def setup_sensor(self, config): modules = ["thermistor", "adc_temperature", "spi_temperature", - "bme280", "htu21d", "lm75", "rpi_temperature", + "bme280", "htu21d", "lm75", "temperature_host", "temperature_mcu", "ds18b20"] for module_name in modules: diff --git a/klippy/extras/rpi_temperature.py b/klippy/extras/temperature_host.py similarity index 72% rename from klippy/extras/rpi_temperature.py rename to klippy/extras/temperature_host.py index f49bce1b..98f29a87 100644 --- a/klippy/extras/rpi_temperature.py +++ b/klippy/extras/temperature_host.py @@ -6,27 +6,29 @@ import logging -RPI_REPORT_TIME = 1.0 -PROC_TEMP_FILE = "/sys/class/thermal/thermal_zone0/temp" +HOST_REPORT_TIME = 1.0 +RPI_PROC_TEMP_FILE = "/sys/class/thermal/thermal_zone0/temp" -class RPiTemperature: +class Temperature_HOST: def __init__(self, config): self.printer = config.get_printer() self.reactor = self.printer.get_reactor() self.name = config.get_name().split()[-1] + self.path = config.get("path", RPI_PROC_TEMP_FILE) self.temp = self.min_temp = self.max_temp = 0.0 - self.printer.add_object("rpi_temperature " + self.name, self) + self.printer.add_object("rpi_temperature " + self.name, self) # XXX + self.printer.add_object("temperature_host " + self.name, self) if self.printer.get_start_args().get('debugoutput') is not None: return self.sample_timer = self.reactor.register_timer( self._sample_pi_temperature) try: - self.file_handle = open(PROC_TEMP_FILE, "r") + self.file_handle = open(self.path, "r") except: raise config.error("Unable to open temperature file '%s'" - % (PROC_TEMP_FILE,)) + % (self.path,)) self.printer.register_event_handler("klippy:connect", self.handle_connect) @@ -42,30 +44,30 @@ class RPiTemperature: self._callback = cb def get_report_time_delta(self): - return RPI_REPORT_TIME + return HOST_REPORT_TIME def _sample_pi_temperature(self, eventtime): try: self.file_handle.seek(0) self.temp = float(self.file_handle.read())/1000.0 except Exception: - logging.exception("rpi_temperature: Error reading data") + logging.exception("temperature_host: Error reading data") self.temp = 0.0 return self.reactor.NEVER if self.temp < self.min_temp: self.printer.invoke_shutdown( - "RPi temperature %0.1f below minimum temperature of %0.1f." + "HOST temperature %0.1f below minimum temperature of %0.1f." % (self.temp, self.min_temp,)) if self.temp > self.max_temp: self.printer.invoke_shutdown( - "RPi temperature %0.1f above maximum temperature of %0.1f." + "HOST temperature %0.1f above maximum temperature of %0.1f." % (self.temp, self.max_temp,)) mcu = self.printer.lookup_object('mcu') measured_time = self.reactor.monotonic() self._callback(mcu.estimated_print_time(measured_time), self.temp) - return measured_time + RPI_REPORT_TIME + return measured_time + HOST_REPORT_TIME def get_status(self, eventtime): return { @@ -76,4 +78,5 @@ class RPiTemperature: def load_config(config): # Register sensor pheaters = config.get_printer().load_object(config, "heaters") - pheaters.add_sensor_factory("rpi_temperature", RPiTemperature) + pheaters.add_sensor_factory("temperature_host", Temperature_HOST) + pheaters.add_sensor_factory("rpi_temperature", Temperature_HOST) # XXX