rpi_temperature: Minor formatting changes
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
db86a4edcb
commit
29831a2f69
|
@ -19,24 +19,19 @@ class RPiTemperature:
|
||||||
|
|
||||||
self.printer.add_object("rpi_temperature " + self.name, self)
|
self.printer.add_object("rpi_temperature " + self.name, self)
|
||||||
self.sample_timer = self.reactor.register_timer(
|
self.sample_timer = self.reactor.register_timer(
|
||||||
self._sample_pi_temperature
|
self._sample_pi_temperature)
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
self.file_handle = open(PROC_TEMP_FILE, "r")
|
self.file_handle = open(PROC_TEMP_FILE, "r")
|
||||||
except:
|
except:
|
||||||
raise config.error(
|
raise config.error("Unable to open temperature file '%s'"
|
||||||
"Unable to open temperature file '%s'" % (PROC_TEMP_FILE)
|
% (PROC_TEMP_FILE,))
|
||||||
)
|
|
||||||
|
|
||||||
self.printer.register_event_handler(
|
|
||||||
"klippy:connect", self.handle_connect
|
|
||||||
)
|
|
||||||
|
|
||||||
|
self.printer.register_event_handler("klippy:connect",
|
||||||
|
self.handle_connect)
|
||||||
|
|
||||||
def handle_connect(self):
|
def handle_connect(self):
|
||||||
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):
|
||||||
self.min_temp = min_temp
|
self.min_temp = min_temp
|
||||||
self.max_temp = max_temp
|
self.max_temp = max_temp
|
||||||
|
@ -55,14 +50,12 @@ class RPiTemperature:
|
||||||
|
|
||||||
if self.temp < self.min_temp:
|
if self.temp < self.min_temp:
|
||||||
self.printer.invoke_shutdown(
|
self.printer.invoke_shutdown(
|
||||||
"RPi temperature %0.1f below minimum"
|
"RPi temperature %0.1f below minimum temperature of %0.1f."
|
||||||
" temperature of %0.1f." % (self.temp, self.min_temp,)
|
% (self.temp, self.min_temp,))
|
||||||
)
|
|
||||||
if self.temp > self.max_temp:
|
if self.temp > self.max_temp:
|
||||||
self.printer.invoke_shutdown(
|
self.printer.invoke_shutdown(
|
||||||
"RPi temperature %0.1f above maximum"
|
"RPi temperature %0.1f above maximum temperature of %0.1f."
|
||||||
" temperature of %0.1f." % (self.temp, self.max_temp,)
|
% (self.temp, self.max_temp,))
|
||||||
)
|
|
||||||
|
|
||||||
measured_time = self.reactor.monotonic()
|
measured_time = self.reactor.monotonic()
|
||||||
self._callback(measured_time, self.temp)
|
self._callback(measured_time, self.temp)
|
||||||
|
@ -77,6 +70,4 @@ class RPiTemperature:
|
||||||
def load_config(config):
|
def load_config(config):
|
||||||
# Register sensor
|
# Register sensor
|
||||||
pheaters = config.get_printer().load_object(config, "heaters")
|
pheaters = config.get_printer().load_object(config, "heaters")
|
||||||
pheaters.add_sensor_factory(
|
pheaters.add_sensor_factory("rpi_temperature", RPiTemperature)
|
||||||
"rpi_temperature", RPiTemperature
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in New Issue