aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2024-03-05 20:50:09 -0500
committerKevin O'Connor <kevin@koconnor.net>2024-03-13 21:42:57 -0400
commitbb512ef5d7cf746d4864cb4f4fbdcf91fbf7f832 (patch)
treea72dd67418d40608bb06c214bd17e4ff5bfaf4e4
parentbddefdde36cab33b19df7e46824e922e9c045527 (diff)
downloadkutter-bb512ef5d7cf746d4864cb4f4fbdcf91fbf7f832.tar.gz
kutter-bb512ef5d7cf746d4864cb4f4fbdcf91fbf7f832.tar.xz
kutter-bb512ef5d7cf746d4864cb4f4fbdcf91fbf7f832.zip
heaters: Clarify reported stats after a shutdown
The pid logic can continue after a shutdown, even though the pin commands sent to the mcu are ignored. However, this behavior can result in confusing "stats" messages in the log. Explicitly disable updates after a shutdown event so that the log statistics are more clear. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/extras/heaters.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/klippy/extras/heaters.py b/klippy/extras/heaters.py
index 6c8fb822..54805013 100644
--- a/klippy/extras/heaters.py
+++ b/klippy/extras/heaters.py
@@ -37,6 +37,7 @@ class Heater:
self.max_power = config.getfloat('max_power', 1., above=0., maxval=1.)
self.smooth_time = config.getfloat('smooth_time', 1., above=0.)
self.inv_smooth_time = 1. / self.smooth_time
+ self.is_shutdown = False
self.lock = threading.Lock()
self.last_temp = self.smoothed_temp = self.target_temp = 0.
self.last_temp_time = 0.
@@ -62,8 +63,10 @@ class Heater:
gcode.register_mux_command("SET_HEATER_TEMPERATURE", "HEATER",
short_name, self.cmd_SET_HEATER_TEMPERATURE,
desc=self.cmd_SET_HEATER_TEMPERATURE_help)
+ self.printer.register_event_handler("klippy:shutdown",
+ self._handle_shutdown)
def set_pwm(self, read_time, value):
- if self.target_temp <= 0.:
+ if self.target_temp <= 0. or self.is_shutdown:
value = 0.
if ((read_time < self.next_pwm_time or not self.last_pwm_value)
and abs(value - self.last_pwm_value) < 0.05):
@@ -87,6 +90,8 @@ class Heater:
self.smoothed_temp += temp_diff * adj_time
self.can_extrude = (self.smoothed_temp >= self.min_extrude_temp)
#logging.debug("temp: %.3f %f = %f", read_time, temp)
+ def _handle_shutdown(self):
+ self.is_shutdown = True
# External commands
def get_name(self):
return self.name