mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-03-04 17:14:38 -07:00
Merge 37f09ef573 into 0624cce4b3
This commit is contained in:
commit
0bf71816e2
2 changed files with 23 additions and 0 deletions
|
|
@ -1503,6 +1503,10 @@ gcode:
|
|||
# disables homing checks for that axis. This may be useful if the
|
||||
# head must move prior to invoking the normal G28 mechanism for an
|
||||
# axis. The default is to not force a position for an axis.
|
||||
#rename_existing:
|
||||
# If specified, this option will rename the original G28 command to
|
||||
# the value specified here, allowing the unmodified homing sequence
|
||||
# to be used outside of this block.
|
||||
```
|
||||
|
||||
### [endstop_phase]
|
||||
|
|
|
|||
|
|
@ -15,8 +15,27 @@ class HomingOverride:
|
|||
self.in_script = False
|
||||
self.printer.load_object(config, 'homing')
|
||||
self.gcode = self.printer.lookup_object('gcode')
|
||||
self.rename_existing = config.get('rename_existing', None)
|
||||
self.prev_G28 = self.gcode.register_command("G28", None)
|
||||
if self.rename_existing is not None:
|
||||
# Verify that the alias is also a traditional G-Code command
|
||||
if not self.gcode.is_traditional_gcode(self.rename_existing):
|
||||
raise config.error("Homing override: rename command '%s' is"
|
||||
"not a traditional G-Code command"
|
||||
% self.rename_existing)
|
||||
# Register connect handler to rename the existing command
|
||||
self.printer.register_event_handler("klippy:connect",
|
||||
self.handle_connect)
|
||||
|
||||
else:
|
||||
self.gcode.register_command("G28", self.cmd_G28)
|
||||
|
||||
def handle_connect(self):
|
||||
pdesc = "Renamed builtin of 'G28'"
|
||||
self.gcode.register_command(self.rename_existing,
|
||||
self.prev_G28, desc=pdesc)
|
||||
self.gcode.register_command("G28", self.cmd_G28)
|
||||
|
||||
def cmd_G28(self, gcmd):
|
||||
if self.in_script:
|
||||
# Was called recursively - invoke the real G28 command
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue