From 9502863677d051dae306af850f40ff9e143ffb4e Mon Sep 17 00:00:00 2001 From: Tircown Date: Wed, 14 Jul 2021 20:48:13 +0200 Subject: [PATCH 1/3] Add sync_extruder_steppers Add ability to synchronize extruder steppers. --- docs/G-Codes.md | 3 +++ klippy/kinematics/extruder.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/docs/G-Codes.md b/docs/G-Codes.md index b4cb63a3ab63..d13b40c64828 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -170,6 +170,9 @@ The following standard commands are supported: - `ACTIVATE_EXTRUDER EXTRUDER=`: In a printer with multiple extruders this command is used to change the active extruder. +- `SYNC_EXTRUDER_STEPPERS EXTRUDER= [TO=]`: + Synchronize extruders steppers. To unsynchronize an extruder, omits the TO + parameter. - `SET_PRESSURE_ADVANCE [EXTRUDER=] [ADVANCE=] [SMOOTH_TIME=]`: Set pressure advance parameters. If EXTRUDER is not specified, it defaults to the active diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py index 76ca7b2e50f5..cc68eff3b4ba 100644 --- a/klippy/kinematics/extruder.py +++ b/klippy/kinematics/extruder.py @@ -74,6 +74,9 @@ def __init__(self, config, extruder_num): gcode.register_mux_command("SET_EXTRUDER_STEP_DISTANCE", "EXTRUDER", self.name, self.cmd_SET_E_STEP_DISTANCE, desc=self.cmd_SET_E_STEP_DISTANCE_help) + gcode.register_mux_command("SYNC_EXTRUDER_STEPPERS", "EXTRUDER", + self.name, self.cmd_SYNC_EXTRUDER_STEPPERS, + desc=self.cmd_SYNC_EXTRUDER_STEPPERS_help) def update_move_time(self, flush_time): self.trapq_finalize_moves(self.trapq, flush_time) def _set_pressure_advance(self, pressure_advance, smooth_time): @@ -216,6 +219,22 @@ def cmd_ACTIVATE_EXTRUDER(self, gcmd): toolhead.flush_step_generation() toolhead.set_extruder(self, self.stepper.get_commanded_position()) self.printer.send_event("extruder:activate_extruder") + cmd_SYNC_EXTRUDER_STEPPERS_help = "Synchronize extruders heaters and motors" + def cmd_SYNC_EXTRUDER_STEPPERS(self, gcmd): + name_master = gcmd.get('TO', None) + heater = self.get_heater() + if name_master == self.name or name_master is None: + # unsync + self.sync_stepper(self.stepper) + gcmd.respond_info("Extruder '%s' is now unsynchronized" % self.name) + return + extruder_master = self.printer.lookup_object(name_master, None) + if extruder_master is None: + gcmd.error("'%s' is not a valid extruder." % (name_master,)) + else: + extruder_master.sync_stepper(self.stepper) + gcmd.respond_info("Extruder '%s' now synchronized with '%s'" + % (self.name, name_master,)) # Dummy extruder class used when a printer has no extruder at all class DummyExtruder: From 1bae6607b9656553f2516e98b36bb1d340f83658 Mon Sep 17 00:00:00 2001 From: Tircown Date: Mon, 26 Jul 2021 20:21:25 +0200 Subject: [PATCH 2/3] Help line Help line correction: no heaters are synchronized in this version. --- klippy/kinematics/extruder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py index cc68eff3b4ba..6f5e48ef9140 100644 --- a/klippy/kinematics/extruder.py +++ b/klippy/kinematics/extruder.py @@ -219,7 +219,7 @@ def cmd_ACTIVATE_EXTRUDER(self, gcmd): toolhead.flush_step_generation() toolhead.set_extruder(self, self.stepper.get_commanded_position()) self.printer.send_event("extruder:activate_extruder") - cmd_SYNC_EXTRUDER_STEPPERS_help = "Synchronize extruders heaters and motors" + cmd_SYNC_EXTRUDER_STEPPERS_help = "Synchronize extruders steppers" def cmd_SYNC_EXTRUDER_STEPPERS(self, gcmd): name_master = gcmd.get('TO', None) heater = self.get_heater() From 49a9e4b62db865b9a3696ecbf7d4b87ee0e8773c Mon Sep 17 00:00:00 2001 From: Tircown Date: Mon, 10 Jan 2022 21:25:30 +0100 Subject: [PATCH 3/3] Remove unused 'heater' line An oversight from a previous version. The heater is not used anymore. --- klippy/kinematics/extruder.py | 1 - 1 file changed, 1 deletion(-) diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py index 6f5e48ef9140..07e3e5daac7f 100644 --- a/klippy/kinematics/extruder.py +++ b/klippy/kinematics/extruder.py @@ -222,7 +222,6 @@ def cmd_ACTIVATE_EXTRUDER(self, gcmd): cmd_SYNC_EXTRUDER_STEPPERS_help = "Synchronize extruders steppers" def cmd_SYNC_EXTRUDER_STEPPERS(self, gcmd): name_master = gcmd.get('TO', None) - heater = self.get_heater() if name_master == self.name or name_master is None: # unsync self.sync_stepper(self.stepper)