mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-08-10 23:35:20 -06:00
homing_override: Allow moves prior to homing an axis
Add support for disabling homing checks via the homing_override mechanism. This may be useful to move an axis prior to homing it. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
01bb4b291e
commit
1a67902858
7 changed files with 42 additions and 14 deletions
|
@ -6,16 +6,29 @@
|
|||
|
||||
class HomingOverride:
|
||||
def __init__(self, config):
|
||||
printer = config.get_printer()
|
||||
self.printer = config.get_printer()
|
||||
self.start_pos = [config.getfloat('set_position_' + a, None)
|
||||
for a in 'xyz']
|
||||
self.script = config.get('gcode')
|
||||
self.in_script = False
|
||||
self.gcode = printer.lookup_object('gcode')
|
||||
self.gcode = self.printer.lookup_object('gcode')
|
||||
self.gcode.register_command("G28", self.cmd_G28)
|
||||
def cmd_G28(self, params):
|
||||
if self.in_script:
|
||||
# Was called recursively - invoke the real G28 command
|
||||
self.gcode.cmd_G28(params)
|
||||
return
|
||||
# Calculate forced position (if configured)
|
||||
toolhead = self.printer.lookup_object('toolhead')
|
||||
pos = toolhead.get_position()
|
||||
homing_axes = []
|
||||
for axis, loc in enumerate(self.start_pos):
|
||||
if loc is not None:
|
||||
pos[axis] = loc
|
||||
homing_axes.append(axis)
|
||||
toolhead.set_position(pos, homing_axes=homing_axes)
|
||||
self.gcode.reset_last_position()
|
||||
# Perform homing
|
||||
try:
|
||||
self.in_script = True
|
||||
self.gcode.run_script(self.script)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue