diff --git a/klippy/extras/heaters.py b/klippy/extras/heaters.py index 1c29aae81..6c8fb8224 100644 --- a/klippy/extras/heaters.py +++ b/klippy/extras/heaters.py @@ -18,7 +18,8 @@ PID_PARAM_BASE = 255. class Heater: def __init__(self, config, sensor): self.printer = config.get_printer() - self.name = config.get_name().split()[-1] + self.name = config.get_name() + self.short_name = short_name = self.name.split()[-1] # Setup sensor self.sensor = sensor self.min_temp = config.getfloat('min_temp', minval=KELVIN_TO_CELSIUS) @@ -55,11 +56,11 @@ class Heater: self.mcu_pwm.setup_cycle_time(pwm_cycle_time) self.mcu_pwm.setup_max_duration(MAX_HEAT_TIME) # Load additional modules - self.printer.load_object(config, "verify_heater %s" % (self.name,)) + self.printer.load_object(config, "verify_heater %s" % (short_name,)) self.printer.load_object(config, "pid_calibrate") gcode = self.printer.lookup_object("gcode") gcode.register_mux_command("SET_HEATER_TEMPERATURE", "HEATER", - self.name, self.cmd_SET_HEATER_TEMPERATURE, + short_name, self.cmd_SET_HEATER_TEMPERATURE, desc=self.cmd_SET_HEATER_TEMPERATURE_help) def set_pwm(self, read_time, value): if self.target_temp <= 0.: @@ -87,6 +88,8 @@ class Heater: self.can_extrude = (self.smoothed_temp >= self.min_extrude_temp) #logging.debug("temp: %.3f %f = %f", read_time, temp) # External commands + def get_name(self): + return self.name def get_pwm_delay(self): return self.pwm_delay def get_max_power(self): @@ -127,7 +130,7 @@ class Heater: last_pwm_value = self.last_pwm_value is_active = target_temp or last_temp > 50. return is_active, '%s: target=%.0f temp=%.1f pwm=%.3f' % ( - self.name, target_temp, last_temp, last_pwm_value) + self.short_name, target_temp, last_temp, last_pwm_value) def get_status(self, eventtime): with self.lock: target_temp = self.target_temp diff --git a/klippy/extras/pid_calibrate.py b/klippy/extras/pid_calibrate.py index f32f1be79..206411672 100644 --- a/klippy/extras/pid_calibrate.py +++ b/klippy/extras/pid_calibrate.py @@ -43,11 +43,12 @@ class PIDCalibrate: "The SAVE_CONFIG command will update the printer config file\n" "with these parameters and restart the printer." % (Kp, Ki, Kd)) # Store results for SAVE_CONFIG + cfgname = heater.get_name() configfile = self.printer.lookup_object('configfile') - configfile.set(heater_name, 'control', 'pid') - configfile.set(heater_name, 'pid_Kp', "%.3f" % (Kp,)) - configfile.set(heater_name, 'pid_Ki', "%.3f" % (Ki,)) - configfile.set(heater_name, 'pid_Kd', "%.3f" % (Kd,)) + configfile.set(cfgname, 'control', 'pid') + configfile.set(cfgname, 'pid_Kp', "%.3f" % (Kp,)) + configfile.set(cfgname, 'pid_Ki', "%.3f" % (Ki,)) + configfile.set(cfgname, 'pid_Kd', "%.3f" % (Kd,)) TUNE_PID_DELTA = 5.0