extruder_stepper: Don't directly access extruder member variables
Rework extruder.get_trapq() into extruder.sync_stepper() so that extruder_stepper.py does not need to directly access the extruder internals. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
518fe023b4
commit
739e6e7396
|
@ -23,23 +23,18 @@ class ExtruderStepper:
|
||||||
desc=self.cmd_SYNC_STEPPER_TO_EXTRUDER_help)
|
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())
|
extruder.sync_stepper(self.stepper)
|
||||||
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"
|
cmd_SYNC_STEPPER_TO_EXTRUDER_help = "Set extruder stepper"
|
||||||
def cmd_SYNC_STEPPER_TO_EXTRUDER(self, gcmd):
|
def cmd_SYNC_STEPPER_TO_EXTRUDER(self, gcmd):
|
||||||
gcode = self.printer.lookup_object('gcode')
|
ename = gcmd.get('EXTRUDER')
|
||||||
self.extruder_name = gcmd.get('EXTRUDER', None)
|
extruder = self.printer.lookup_object(ename, None)
|
||||||
extruder = self.printer.lookup_object(self.extruder_name, None)
|
if extruder is None:
|
||||||
if extruder is not None:
|
raise gcmd.error("'%s' is not a valid extruder." % (ename,))
|
||||||
epos = extruder.stepper.get_commanded_position()
|
extruder.sync_stepper(self.stepper)
|
||||||
self.stepper.set_position([epos, 0., 0.])
|
self.extruder_name = ename
|
||||||
self.stepper.set_trapq(extruder.get_trapq())
|
gcmd.respond_info("Extruder stepper now syncing with '%s'" % (ename,))
|
||||||
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)
|
||||||
|
|
|
@ -98,8 +98,10 @@ class PrinterExtruder:
|
||||||
return self.name
|
return self.name
|
||||||
def get_heater(self):
|
def get_heater(self):
|
||||||
return self.heater
|
return self.heater
|
||||||
def get_trapq(self):
|
def sync_stepper(self, stepper):
|
||||||
return self.trapq
|
epos = self.stepper.get_commanded_position()
|
||||||
|
stepper.set_position([epos, 0., 0.])
|
||||||
|
stepper.set_trapq(self.trapq)
|
||||||
def stats(self, eventtime):
|
def stats(self, eventtime):
|
||||||
return self.heater.stats(eventtime)
|
return self.heater.stats(eventtime)
|
||||||
def check_move(self, move):
|
def check_move(self, move):
|
||||||
|
|
Loading…
Reference in New Issue