homing_override: Add axes config parameter

Added a config parameter to define the homing override axes. This way
one can still home x and y axis without the z-probe cycle coming in the
way.

Signed-off-by: Hans Raaf <hr-klipper@oderwat.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Hans Raaf 2018-06-10 14:23:40 +02:00 committed by Kevin O'Connor
parent 5f640699b7
commit e110e1fecc
2 changed files with 29 additions and 1 deletions

View File

@ -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:

View File

@ -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()