aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/example-extras.cfg8
-rw-r--r--klippy/extras/homing_override.py22
2 files changed, 29 insertions, 1 deletions
diff --git a/config/example-extras.cfg b/config/example-extras.cfg
index b849b4c2..81231f75 100644
--- a/config/example-extras.cfg
+++ b/config/example-extras.cfg
@@ -486,10 +486,16 @@
#[homing_override]
#gcode:
# A list of G-Code commands (one per line) to execute in place of
-# all G28 commands found in the normal g-code input. If a G28 is
+# G28 commands found in the normal g-code input. If a G28 is
# contained in this list of commands then it will invoke the normal
# homing procedure for the printer. The commands listed here must
# home all axes. This parameter must be provided.
+#axes: xyz
+# The axes to override. For example, if this is set to "z" then the
+# override script will only be run when the z axis is homed (eg, via
+# a "G28" or "G28 Z0" command). Note, the override script should
+# still home all axes. The default is "xyz" which causes the
+# override script to be run in place of all G28 commands.
#set_position_x:
#set_position_y:
#set_position_z:
diff --git a/klippy/extras/homing_override.py b/klippy/extras/homing_override.py
index f69298aa..17a3911e 100644
--- a/klippy/extras/homing_override.py
+++ b/klippy/extras/homing_override.py
@@ -9,6 +9,7 @@ class HomingOverride:
self.printer = config.get_printer()
self.start_pos = [config.getfloat('set_position_' + a, None)
for a in 'xyz']
+ self.axes = config.get('axes', 'XYZ').upper()
self.script = config.get('gcode')
self.in_script = False
self.gcode = self.printer.lookup_object('gcode')
@@ -19,6 +20,27 @@ class HomingOverride:
# Was called recursively - invoke the real G28 command
self.gcode.cmd_G28(params)
return
+
+ # if no axis is given as parameter we assume the override
+ no_axis = True
+ for axis in 'XYZ':
+ if axis in params:
+ no_axis = False
+ break
+
+ if no_axis:
+ override = True
+ else:
+ # check if we home an axsis which needs the override
+ override = False
+ for axis in self.axes:
+ if axis in params:
+ override = True
+
+ if not override:
+ self.gcode.cmd_G28(params)
+ return
+
# Calculate forced position (if configured)
toolhead = self.printer.lookup_object('toolhead')
pos = toolhead.get_position()