From 8ed0f7c5c37a3e2a3c38d19b19bbd6846453a6df Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 13 Jan 2020 21:39:55 -0500 Subject: [PATCH] kinematics: Remove support for identifying Z steppers The caller can now determine which steppers are connected to cartesian Z movement via the new stepper.is_active_axis() method. It is therefore no longer necessary for the kinematic code to identify these steppers. Signed-off-by: Kevin O'Connor --- klippy/extras/bltouch.py | 5 +++-- klippy/extras/probe.py | 5 +++-- klippy/extras/z_tilt.py | 2 +- klippy/kinematics/cartesian.py | 4 +--- klippy/kinematics/corexy.py | 4 +--- klippy/kinematics/delta.py | 2 +- klippy/kinematics/none.py | 2 +- klippy/kinematics/polar.py | 4 +--- klippy/kinematics/rotary_delta.py | 2 +- klippy/kinematics/winch.py | 2 +- 10 files changed, 14 insertions(+), 18 deletions(-) diff --git a/klippy/extras/bltouch.py b/klippy/extras/bltouch.py index f372b1ab..c4556342 100644 --- a/klippy/extras/bltouch.py +++ b/klippy/extras/bltouch.py @@ -62,8 +62,9 @@ class BLTouchEndstopWrapper: desc=self.cmd_BLTOUCH_DEBUG_help) def _build_config(self): kin = self.printer.lookup_object('toolhead').get_kinematics() - for stepper in kin.get_steppers('Z'): - self.add_stepper(stepper) + for stepper in kin.get_steppers(): + if stepper.is_active_axis('z'): + self.add_stepper(stepper) def handle_connect(self): try: self.raise_probe() diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py index b87aff62..f5c69ec7 100644 --- a/klippy/extras/probe.py +++ b/klippy/extras/probe.py @@ -241,8 +241,9 @@ class ProbeEndstopWrapper: self.TimeoutError = self.mcu_endstop.TimeoutError def _build_config(self): kin = self.printer.lookup_object('toolhead').get_kinematics() - for stepper in kin.get_steppers('Z'): - self.add_stepper(stepper) + for stepper in kin.get_steppers(): + if stepper.is_active_axis('z'): + self.add_stepper(stepper) def home_prepare(self): toolhead = self.printer.lookup_object('toolhead') start_pos = toolhead.get_position() diff --git a/klippy/extras/z_tilt.py b/klippy/extras/z_tilt.py index e6680a75..9784372e 100644 --- a/klippy/extras/z_tilt.py +++ b/klippy/extras/z_tilt.py @@ -16,7 +16,7 @@ class ZAdjustHelper: self.handle_connect) def handle_connect(self): kin = self.printer.lookup_object('toolhead').get_kinematics() - z_steppers = kin.get_steppers('Z') + z_steppers = [s for s in kin.get_steppers() if s.is_active_axis('z')] if len(z_steppers) != self.z_count: raise self.printer.config_error( "%s z_positions needs exactly %d items" % ( diff --git a/klippy/kinematics/cartesian.py b/klippy/kinematics/cartesian.py index c44ad857..c9ed31ff 100644 --- a/klippy/kinematics/cartesian.py +++ b/klippy/kinematics/cartesian.py @@ -49,9 +49,7 @@ class CartKinematics: self.printer.lookup_object('gcode').register_command( 'SET_DUAL_CARRIAGE', self.cmd_SET_DUAL_CARRIAGE, desc=self.cmd_SET_DUAL_CARRIAGE_help) - def get_steppers(self, flags=""): - if flags == "Z": - return self.rails[2].get_steppers() + def get_steppers(self): rails = self.rails if self.dual_carriage_axis is not None: dca = self.dual_carriage_axis diff --git a/klippy/kinematics/corexy.py b/klippy/kinematics/corexy.py index 98c66dd5..cc94d56c 100644 --- a/klippy/kinematics/corexy.py +++ b/klippy/kinematics/corexy.py @@ -39,9 +39,7 @@ class CoreXYKinematics: self.rails[1].set_max_jerk(max_xy_halt_velocity, max_xy_accel) self.rails[2].set_max_jerk( min(max_halt_velocity, self.max_z_velocity), self.max_z_accel) - def get_steppers(self, flags=""): - if flags == "Z": - return self.rails[2].get_steppers() + def get_steppers(self): return [s for rail in self.rails for s in rail.get_steppers()] def calc_tag_position(self): pos = [rail.get_tag_position() for rail in self.rails] diff --git a/klippy/kinematics/delta.py b/klippy/kinematics/delta.py index f58902b2..057e9241 100644 --- a/klippy/kinematics/delta.py +++ b/klippy/kinematics/delta.py @@ -87,7 +87,7 @@ class DeltaKinematics: math.sqrt(self.max_xy2), math.sqrt(self.slow_xy2), math.sqrt(self.very_slow_xy2))) self.set_position([0., 0., 0.], ()) - def get_steppers(self, flags=""): + def get_steppers(self): return [s for rail in self.rails for s in rail.get_steppers()] def _actuator_to_cartesian(self, spos): sphere_coords = [(t[0], t[1], sp) for t, sp in zip(self.towers, spos)] diff --git a/klippy/kinematics/none.py b/klippy/kinematics/none.py index 7df1010a..6ce461a5 100644 --- a/klippy/kinematics/none.py +++ b/klippy/kinematics/none.py @@ -7,7 +7,7 @@ class NoneKinematics: def __init__(self, toolhead, config): pass - def get_steppers(self, flags=""): + def get_steppers(self): return [] def calc_tag_position(self): return [0, 0, 0] diff --git a/klippy/kinematics/polar.py b/klippy/kinematics/polar.py index 6b86a8c8..565525f2 100644 --- a/klippy/kinematics/polar.py +++ b/klippy/kinematics/polar.py @@ -37,9 +37,7 @@ class PolarKinematics: stepper_bed.set_max_jerk(max_halt_velocity, max_accel) rail_arm.set_max_jerk(max_halt_velocity, max_accel) rail_z.set_max_jerk(max_halt_velocity, max_accel) - def get_steppers(self, flags=""): - if flags == "Z": - return self.rails[1].get_steppers() + def get_steppers(self): return list(self.steppers) def calc_tag_position(self): bed_angle = self.steppers[0].get_tag_position() diff --git a/klippy/kinematics/rotary_delta.py b/klippy/kinematics/rotary_delta.py index 9e928d39..a7ab940f 100644 --- a/klippy/kinematics/rotary_delta.py +++ b/klippy/kinematics/rotary_delta.py @@ -77,7 +77,7 @@ class RotaryDeltaKinematics: "Delta max build height %.2fmm (radius tapered above %.2fmm)" % (self.max_z, self.limit_z)) self.set_position([0., 0., 0.], ()) - def get_steppers(self, flags=""): + def get_steppers(self): return [s for rail in self.rails for s in rail.get_steppers()] def calc_tag_position(self): spos = [rail.get_tag_position() for rail in self.rails] diff --git a/klippy/kinematics/winch.py b/klippy/kinematics/winch.py index 37494c4e..04e2d498 100644 --- a/klippy/kinematics/winch.py +++ b/klippy/kinematics/winch.py @@ -29,7 +29,7 @@ class WinchKinematics: s.set_max_jerk(max_halt_velocity, max_accel) # Setup boundary checks self.set_position([0., 0., 0.], ()) - def get_steppers(self, flags=""): + def get_steppers(self): return list(self.steppers) def calc_tag_position(self): # Use only first three steppers to calculate cartesian position