aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/safe_z_home.py
diff options
context:
space:
mode:
authorFlorian Heilmann <Florian.Heilmann@gmx.net>2020-08-05 17:52:23 +0200
committerGitHub <noreply@github.com>2020-08-05 11:52:23 -0400
commit10987003b09a5b88fa0d7cbfff76ffa2f857b445 (patch)
tree1382f81283a42c4271a3ab23b3f6bdf00b8d5b79 /klippy/extras/safe_z_home.py
parentfe84968bdcb1d17455ca6c2ffb9ed8d209dc85ed (diff)
downloadkutter-10987003b09a5b88fa0d7cbfff76ffa2f857b445.tar.gz
kutter-10987003b09a5b88fa0d7cbfff76ffa2f857b445.tar.xz
kutter-10987003b09a5b88fa0d7cbfff76ffa2f857b445.zip
safe_z_home: Make sure X and Y are homed before homing Z (#3153)
In it's current behavior, safe_z_home will attempt to home Z if it thinks the toolhead is above the z endstop even if the motors have since been disabled and the toolhead was moved to another position Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
Diffstat (limited to 'klippy/extras/safe_z_home.py')
-rw-r--r--klippy/extras/safe_z_home.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/klippy/extras/safe_z_home.py b/klippy/extras/safe_z_home.py
index eaaee965..9f6dd7bd 100644
--- a/klippy/extras/safe_z_home.py
+++ b/klippy/extras/safe_z_home.py
@@ -30,12 +30,12 @@ class SafeZHoming:
def cmd_G28(self, gcmd):
toolhead = self.printer.lookup_object('toolhead')
+ curtime = self.printer.get_reactor().monotonic()
+ kin_status = toolhead.get_kinematics().get_status(curtime)
# Perform Z Hop if necessary
if self.z_hop != 0.0:
pos = toolhead.get_position()
- curtime = self.printer.get_reactor().monotonic()
- kin_status = toolhead.get_kinematics().get_status(curtime)
# Check if Z axis is homed or has a known position
if 'z' in kin_status['homed_axes']:
# Check if the zhop would exceed the printer limits
@@ -65,14 +65,23 @@ class SafeZHoming:
if new_params:
g28_gcmd = self.gcode.create_gcode_command("G28", "G28", new_params)
self.prev_G28(g28_gcmd)
+
+ # Update the currently homed axes
+ curtime = self.printer.get_reactor().monotonic()
+ kin_status = toolhead.get_kinematics().get_status(curtime)
+
# Home Z axis if necessary
if need_z:
- # Move to safe XY homing position
pos = toolhead.get_position()
prev_x = pos[0]
prev_y = pos[1]
pos[0] = self.home_x_pos
pos[1] = self.home_y_pos
+ # Throw an error if X or Y are not homed
+ if ('x' not in kin_status['homed_axes'] or
+ 'y' not in kin_status['homed_axes']):
+ raise gcmd.error("Must home X and Y axes first")
+ # Move to safe XY homing position
toolhead.move(pos, self.speed)
self.gcode.reset_last_position()
# Home Z