extruder_stepper: Support changing synced extruder on the fly (#2824)
Signed-off-by: Christopher Meredith <chmeredith@gmail.com>
This commit is contained in:
parent
967fe1c01c
commit
518fe023b4
|
@ -278,6 +278,15 @@ section is enabled:
|
||||||
future G-Code movement commands may run in parallel with the stepper
|
future G-Code movement commands may run in parallel with the stepper
|
||||||
movement.
|
movement.
|
||||||
|
|
||||||
|
## Extruder stepper Commands
|
||||||
|
|
||||||
|
The following command is available when an "extruder_stepper" config
|
||||||
|
section is enabled:
|
||||||
|
- `SYNC_STEPPER_TO_EXTRUDER STEPPER=<extruder_stepper config_name>
|
||||||
|
[EXTRUDER=<extruder config_name>]`: This command will cause the given
|
||||||
|
STEPPER to become synchronized to the given EXTRUDER, overriding
|
||||||
|
the extruder defined in the "extruder_stepper" config section.
|
||||||
|
|
||||||
## Probe
|
## Probe
|
||||||
|
|
||||||
The following commands are available when a "probe" config section is
|
The following commands are available when a "probe" config section is
|
||||||
|
|
|
@ -9,17 +9,37 @@ import stepper
|
||||||
class ExtruderStepper:
|
class ExtruderStepper:
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
|
stepper_name = config.get_name().split()[1]
|
||||||
self.extruder_name = config.get('extruder', 'extruder')
|
self.extruder_name = config.get('extruder', 'extruder')
|
||||||
self.stepper = stepper.PrinterStepper(config)
|
self.stepper = stepper.PrinterStepper(config)
|
||||||
self.stepper.set_max_jerk(9999999.9, 9999999.9)
|
self.stepper.set_max_jerk(9999999.9, 9999999.9)
|
||||||
self.stepper.setup_itersolve('extruder_stepper_alloc')
|
self.stepper.setup_itersolve('extruder_stepper_alloc')
|
||||||
self.printer.register_event_handler("klippy:connect",
|
self.printer.register_event_handler("klippy:connect",
|
||||||
self.handle_connect)
|
self.handle_connect)
|
||||||
|
gcode = self.printer.lookup_object('gcode')
|
||||||
|
gcode.register_mux_command("SYNC_STEPPER_TO_EXTRUDER", "STEPPER",
|
||||||
|
stepper_name,
|
||||||
|
self.cmd_SYNC_STEPPER_TO_EXTRUDER,
|
||||||
|
desc=self.cmd_SYNC_STEPPER_TO_EXTRUDER_help)
|
||||||
def handle_connect(self):
|
def handle_connect(self):
|
||||||
extruder = self.printer.lookup_object(self.extruder_name)
|
extruder = self.printer.lookup_object(self.extruder_name)
|
||||||
self.stepper.set_trapq(extruder.get_trapq())
|
self.stepper.set_trapq(extruder.get_trapq())
|
||||||
toolhead = self.printer.lookup_object('toolhead')
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
toolhead.register_step_generator(self.stepper.generate_steps)
|
toolhead.register_step_generator(self.stepper.generate_steps)
|
||||||
|
cmd_SYNC_STEPPER_TO_EXTRUDER_help = "Set extruder stepper"
|
||||||
|
def cmd_SYNC_STEPPER_TO_EXTRUDER(self, gcmd):
|
||||||
|
gcode = self.printer.lookup_object('gcode')
|
||||||
|
self.extruder_name = gcmd.get('EXTRUDER', None)
|
||||||
|
extruder = self.printer.lookup_object(self.extruder_name, None)
|
||||||
|
if extruder is not None:
|
||||||
|
epos = extruder.stepper.get_commanded_position()
|
||||||
|
self.stepper.set_position([epos, 0., 0.])
|
||||||
|
self.stepper.set_trapq(extruder.get_trapq())
|
||||||
|
gcode.respond_info("Extruder stepper now syncing with '%s'"
|
||||||
|
% (self.extruder_name))
|
||||||
|
else:
|
||||||
|
raise gcmd.error("'%s' is not a valid extruder."
|
||||||
|
% (self.extruder_name))
|
||||||
|
|
||||||
def load_config_prefix(config):
|
def load_config_prefix(config):
|
||||||
return ExtruderStepper(config)
|
return ExtruderStepper(config)
|
||||||
|
|
Loading…
Reference in New Issue