Skip to content

Commit

Permalink
heaters: Clarify reported stats after a shutdown
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
KevinOConnor committed Mar 14, 2024
1 parent bddefdd commit bb512ef
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion klippy/extras/heaters.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, config, sensor):
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.
Expand All @@ -62,8 +63,10 @@ def __init__(self, config, sensor):
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):
Expand All @@ -87,6 +90,8 @@ def temperature_callback(self, read_time, temp):
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
Expand Down

0 comments on commit bb512ef

Please sign in to comment.