Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sync_extruder_steppers #4489

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/G-Codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ The following standard commands are supported:
- `ACTIVATE_EXTRUDER EXTRUDER=<config_name>`: In a printer with
multiple extruders this command is used to change the active
extruder.
- `SYNC_EXTRUDER_STEPPERS EXTRUDER=<config_name> [TO=<config_name>]`:
Synchronize extruders steppers. To unsynchronize an extruder, omits the TO
parameter.
- `SET_PRESSURE_ADVANCE [EXTRUDER=<config_name>] [ADVANCE=<pressure_advance>]
[SMOOTH_TIME=<pressure_advance_smooth_time>]`: Set pressure advance
parameters. If EXTRUDER is not specified, it defaults to the active
Expand Down
18 changes: 18 additions & 0 deletions klippy/kinematics/extruder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -216,6 +219,21 @@ 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 steppers"
def cmd_SYNC_EXTRUDER_STEPPERS(self, gcmd):
name_master = gcmd.get('TO', None)
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:
Expand Down