Skip to content

Commit

Permalink
Add sync_extruder_steppers
Browse files Browse the repository at this point in the history
Add ability to synchronize extruder steppers.
  • Loading branch information
Tircown committed Jan 10, 2022
1 parent 6e6ad7b commit 9502863
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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
19 changes: 19 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,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:
Expand Down

0 comments on commit 9502863

Please sign in to comment.