diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index b19bf6f2c..062f03f97 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -2405,6 +2405,11 @@ detach_position: 0,0,0 #dock_sense_pin: # This supplemental pin can be defined to determine a docked state in # addition to probe_sense_pin or check_open_attach. +#pre_attach_gcode: +#post_attach_gcode: +#pre_detach_gcode: +#post_detach_gcode: +# #x_offset: #y_offset: #z_offset: diff --git a/klippy/extras/dockable_probe.py b/klippy/extras/dockable_probe.py index c8903d26f..f61ea08f9 100644 --- a/klippy/extras/dockable_probe.py +++ b/klippy/extras/dockable_probe.py @@ -232,6 +232,20 @@ def __init__(self, config): config, "deactivate_gcode", "" ) + self.pre_attach_gcode = gcode_macro.load_template( + config, "pre_attach_gcode", "" + ) + self.post_attach_gcode = gcode_macro.load_template( + config, "post_attach_gcode", "" + ) + + self.pre_detach_gcode = gcode_macro.load_template( + config, "pre_detach_gcode", "" + ) + self.post_detach_gcode = gcode_macro.load_template( + config, "post_detach_gcode", "" + ) + # Pins ppins = self.printer.lookup_object("pins") pin = config.get("pin") @@ -493,6 +507,7 @@ def cmd_MOVE_AVOIDING_DOCK(self, gcmd): def attach_probe(self, return_pos=None, always_restore_toolhead=False): self._lower_probe() + self.pre_attach_gcode.run_gcode_from_command() retry = 0 while ( @@ -527,7 +542,10 @@ def attach_probe(self, return_pos=None, always_restore_toolhead=False): # Do NOT return to the original Z position after attach # as the probe might crash into the bed. + self.post_attach_gcode.run_gcode_from_command() + def detach_probe(self, return_pos=None): + self.pre_detach_gcode.run_gcode_from_command() retry = 0 while ( self.get_probe_state() != PROBE_DOCKED @@ -550,6 +568,8 @@ def detach_probe(self, return_pos=None): if self.get_probe_state() != PROBE_DOCKED: raise self.printer.command_error("Probe detach failed!") + self.post_detach_gcode.run_gcode_from_command() + if return_pos and self.restore_toolhead: # return to the original XY position, if inside safe_dock area # move to the closest point