From c7eb62e0feff2ecc42cbd021cec70904cdac8cb9 Mon Sep 17 00:00:00 2001 From: Timofey Titovets Date: Sat, 23 May 2026 04:06:24 +0200 Subject: [PATCH] pid_calibrate: Use register_mux_command Signed-off-by: Timofey Titovets --- klippy/extras/pid_calibrate.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/klippy/extras/pid_calibrate.py b/klippy/extras/pid_calibrate.py index 572252e2c..ba3a6a14a 100644 --- a/klippy/extras/pid_calibrate.py +++ b/klippy/extras/pid_calibrate.py @@ -9,19 +9,24 @@ from . import heaters class PIDCalibrate: def __init__(self, config): self.printer = config.get_printer() + self.printer.register_event_handler("klippy:connect", + self._handle_connect) + def _handle_connect(self): gcode = self.printer.lookup_object('gcode') - gcode.register_command('PID_CALIBRATE', self.cmd_PID_CALIBRATE, - desc=self.cmd_PID_CALIBRATE_help) + pheaters = self.printer.lookup_object('heaters') + all_heaters = pheaters.get_all_heaters() + for name in all_heaters: + short_name = name.split()[-1] + gcode.register_mux_command('PID_CALIBRATE', 'HEATER', short_name, + self.cmd_PID_CALIBRATE, + desc=self.cmd_PID_CALIBRATE_help) cmd_PID_CALIBRATE_help = "Run PID calibration test" def cmd_PID_CALIBRATE(self, gcmd): heater_name = gcmd.get('HEATER') target = gcmd.get_float('TARGET') write_file = gcmd.get_int('WRITE_FILE', 0) pheaters = self.printer.lookup_object('heaters') - try: - heater = pheaters.lookup_heater(heater_name) - except self.printer.config_error as e: - raise gcmd.error(str(e)) + heater = pheaters.lookup_heater(heater_name) self.printer.lookup_object('toolhead').get_last_move_time() calibrate = ControlAutoTune(heater, target) old_control = heater.set_control(calibrate)