homing_override: Add basic support for running custom g-code on G28
Allow users to override the behavior of G28 using a new "homing_override" config section. This may be used on printers that require specific steps during the homing process. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
39d62556b1
commit
3001a089c0
|
@ -267,6 +267,19 @@
|
||||||
# default is to not scale the 'channel_x' parameters.
|
# default is to not scale the 'channel_x' parameters.
|
||||||
|
|
||||||
|
|
||||||
|
# Homing override. One may use this mechanism to run a series of
|
||||||
|
# g-code commands in place of a G28 found in the normal g-code input.
|
||||||
|
# This may be useful on printers that require a specific procedure to
|
||||||
|
# home the machine.
|
||||||
|
#[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
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
|
||||||
# Replicape support - see the generic-replicape.cfg file for further
|
# Replicape support - see the generic-replicape.cfg file for further
|
||||||
# details.
|
# details.
|
||||||
#[replicape]
|
#[replicape]
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Run user defined actions in place of a normal G28 homing command
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
|
||||||
|
#
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
|
class HomingOverride:
|
||||||
|
def __init__(self, config):
|
||||||
|
printer = config.get_printer()
|
||||||
|
self.script = config.get('gcode')
|
||||||
|
self.in_script = False
|
||||||
|
self.gcode = 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
|
||||||
|
try:
|
||||||
|
self.in_script = True
|
||||||
|
self.gcode.run_script(self.script)
|
||||||
|
finally:
|
||||||
|
self.in_script = False
|
||||||
|
|
||||||
|
def load_config(config):
|
||||||
|
if config.get_name() != 'homing_override':
|
||||||
|
raise config.error("Invalid homing_override config name")
|
||||||
|
return HomingOverride(config)
|
Loading…
Reference in New Issue