stepper: Add get/set_tag_position() and convert calc_position()

Rename calc_position() to calc_tag_position() and have it calculate
the value of the position from the last stepper set_tag_position()
call.  This enables the calc_tag_position() code to be more flexible
as it can be run with arbitrary positions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-11-13 17:59:40 -05:00
parent e0e2f15498
commit 224574da4a
11 changed files with 56 additions and 40 deletions

View file

@ -53,8 +53,8 @@ class CartKinematics:
if flags == "Z":
return self.rails[2].get_steppers()
return [s for rail in self.rails for s in rail.get_steppers()]
def calc_position(self):
return [rail.get_commanded_position() for rail in self.rails]
def calc_tag_position(self):
return [rail.get_tag_position() for rail in self.rails]
def set_position(self, newpos, homing_axes):
for i, rail in enumerate(self.rails):
rail.set_position(newpos)
@ -125,8 +125,9 @@ class CartKinematics:
self.rails[dc_axis].set_trapq(None)
dc_rail.set_trapq(toolhead.get_trapq())
self.rails[dc_axis] = dc_rail
extruder_pos = toolhead.get_position()[3]
toolhead.set_position(self.calc_position() + [extruder_pos])
pos = toolhead.get_position()
pos[dc_axis] = dc_rail.get_commanded_position()
toolhead.set_position(pos)
if self.limits[dc_axis][0] <= self.limits[dc_axis][1]:
self.limits[dc_axis] = dc_rail.get_range()
cmd_SET_DUAL_CARRIAGE_help = "Set which carriage is active"