2019-10-13 12:59:43 +02:00
|
|
|
# Code for supporting multiple steppers in single filament extruder.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2019 Simo Apell <simo.apell@live.fi>
|
|
|
|
#
|
|
|
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
|
|
|
import logging
|
|
|
|
import stepper
|
|
|
|
|
|
|
|
class ExtruderStepper:
|
|
|
|
def __init__(self, config):
|
|
|
|
self.printer = config.get_printer()
|
2020-06-06 20:30:58 +02:00
|
|
|
stepper_name = config.get_name().split()[1]
|
2019-10-13 12:59:43 +02:00
|
|
|
self.extruder_name = config.get('extruder', 'extruder')
|
|
|
|
self.stepper = stepper.PrinterStepper(config)
|
|
|
|
self.stepper.set_max_jerk(9999999.9, 9999999.9)
|
|
|
|
self.stepper.setup_itersolve('extruder_stepper_alloc')
|
|
|
|
self.printer.register_event_handler("klippy:connect",
|
|
|
|
self.handle_connect)
|
2020-06-06 20:30:58 +02:00
|
|
|
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)
|
2019-10-13 12:59:43 +02:00
|
|
|
def handle_connect(self):
|
|
|
|
extruder = self.printer.lookup_object(self.extruder_name)
|
2020-06-06 20:41:15 +02:00
|
|
|
extruder.sync_stepper(self.stepper)
|
2019-10-13 12:59:43 +02:00
|
|
|
toolhead = self.printer.lookup_object('toolhead')
|
|
|
|
toolhead.register_step_generator(self.stepper.generate_steps)
|
2020-06-06 20:30:58 +02:00
|
|
|
cmd_SYNC_STEPPER_TO_EXTRUDER_help = "Set extruder stepper"
|
|
|
|
def cmd_SYNC_STEPPER_TO_EXTRUDER(self, gcmd):
|
2020-06-06 20:41:15 +02:00
|
|
|
ename = gcmd.get('EXTRUDER')
|
|
|
|
extruder = self.printer.lookup_object(ename, None)
|
|
|
|
if extruder is None:
|
|
|
|
raise gcmd.error("'%s' is not a valid extruder." % (ename,))
|
|
|
|
extruder.sync_stepper(self.stepper)
|
|
|
|
self.extruder_name = ename
|
|
|
|
gcmd.respond_info("Extruder stepper now syncing with '%s'" % (ename,))
|
2019-10-13 12:59:43 +02:00
|
|
|
|
|
|
|
def load_config_prefix(config):
|
|
|
|
return ExtruderStepper(config)
|