diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 8035ce68..14377202 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -1520,6 +1520,10 @@ stepper_z config section. [probe] pin: # Probe detection pin. This parameter must be provided. +#deactivate_on_each_sample: True +# This determines if Klipper should execute deactivation gcode +# between each probe attempt when performing a multiple probe +# sequence. The default is True. #x_offset: 0.0 # The distance (in mm) between the probe and the nozzle along the # x-axis. The default is 0. diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py index e4f7a9ac..47f438db 100644 --- a/klippy/extras/probe.py +++ b/klippy/extras/probe.py @@ -268,6 +268,8 @@ class ProbeEndstopWrapper: def __init__(self, config): self.printer = config.get_printer() self.position_endstop = config.getfloat('z_offset') + self.stow_on_each_sample = config.getboolean( + 'deactivate_on_each_sample', True) gcode_macro = self.printer.load_object(config, 'gcode_macro') self.activate_gcode = gcode_macro.load_template( config, 'activate_gcode', '') @@ -287,29 +289,44 @@ class ProbeEndstopWrapper: self.home_start = self.mcu_endstop.home_start self.home_wait = self.mcu_endstop.home_wait self.query_endstop = self.mcu_endstop.query_endstop + # multi probes state + self.multi = 'OFF' def _build_config(self): kin = self.printer.lookup_object('toolhead').get_kinematics() for stepper in kin.get_steppers(): if stepper.is_active_axis('z'): self.add_stepper(stepper) - def multi_probe_begin(self): - pass - def multi_probe_end(self): - pass - def probe_prepare(self, hmove): - toolhead = self.printer.lookup_object('toolhead') - start_pos = toolhead.get_position() - self.activate_gcode.run_gcode_from_command() - if toolhead.get_position()[:3] != start_pos[:3]: - raise self.printer.command_error( - "Toolhead moved during probe activate_gcode script") - def probe_finish(self, hmove): + def raise_probe(self): toolhead = self.printer.lookup_object('toolhead') start_pos = toolhead.get_position() self.deactivate_gcode.run_gcode_from_command() + if toolhead.get_position()[:3] != start_pos[:3]: + raise self.printer.command_error( + "Toolhead moved during probe activate_gcode script") + def lower_probe(self): + toolhead = self.printer.lookup_object('toolhead') + start_pos = toolhead.get_position() + self.activate_gcode.run_gcode_from_command() if toolhead.get_position()[:3] != start_pos[:3]: raise self.printer.command_error( "Toolhead moved during probe deactivate_gcode script") + def multi_probe_begin(self): + if self.stow_on_each_sample: + return + self.multi = 'FIRST' + def multi_probe_end(self): + if self.stow_on_each_sample: + return + self.raise_probe() + self.multi = 'OFF' + def probe_prepare(self, hmove): + if self.multi == 'OFF' or self.multi == 'FIRST': + self.lower_probe() + if self.multi == 'FIRST': + self.multi = 'ON' + def probe_finish(self, hmove): + if self.multi == 'OFF': + self.raise_probe() def get_position_endstop(self): return self.position_endstop