This commit is contained in:
Lexi 2026-03-01 15:04:30 -05:00 committed by GitHub
commit 0bf71816e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 0 deletions

View file

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

View file

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