toolhead: Add a move.move_error() helper

Move the EndstopMoveError() code from homing.py to a new method in the
toolhead Move class.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2020-09-03 16:22:54 -04:00
parent d0ed6e5705
commit 1f3a160f47
9 changed files with 21 additions and 26 deletions

View file

@ -94,18 +94,17 @@ class PolarKinematics:
xy2 = end_pos[0]**2 + end_pos[1]**2
if xy2 > self.limit_xy2:
if self.limit_xy2 < 0.:
raise homing.EndstopMoveError(end_pos, "Must home axis first")
raise homing.EndstopMoveError(end_pos)
raise move.move_error("Must home axis first")
raise move.move_error()
if move.axes_d[2]:
if end_pos[2] < self.limit_z[0] or end_pos[2] > self.limit_z[1]:
if self.limit_z[0] > self.limit_z[1]:
raise homing.EndstopMoveError(
end_pos, "Must home axis first")
raise homing.EndstopMoveError(end_pos)
raise move.move_error("Must home axis first")
raise move.move_error()
# Move with Z - update velocity and accel for slower Z axis
z_ratio = move.move_d / abs(move.axes_d[2])
move.limit_speed(
self.max_z_velocity * z_ratio, self.max_z_accel * z_ratio)
move.limit_speed(self.max_z_velocity * z_ratio,
self.max_z_accel * z_ratio)
def get_status(self, eventtime):
xy_home = "xy" if self.limit_xy2 >= 0. else ""
z_home = "z" if self.limit_z[0] <= self.limit_z[1] else ""