mirror of https://github.com/Desuuuu/klipper.git
probe: Add deactivate_on_each_sample: param for Probe (#4161)
Signed-off-by: Nick Lefskiy <n.lefskiy@yandex.ru>
This commit is contained in:
parent
200b62bcb4
commit
2d2db0f839
|
@ -1520,6 +1520,10 @@ stepper_z config section.
|
||||||
[probe]
|
[probe]
|
||||||
pin:
|
pin:
|
||||||
# Probe detection pin. This parameter must be provided.
|
# 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
|
#x_offset: 0.0
|
||||||
# The distance (in mm) between the probe and the nozzle along the
|
# The distance (in mm) between the probe and the nozzle along the
|
||||||
# x-axis. The default is 0.
|
# x-axis. The default is 0.
|
||||||
|
|
|
@ -268,6 +268,8 @@ class ProbeEndstopWrapper:
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.position_endstop = config.getfloat('z_offset')
|
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')
|
gcode_macro = self.printer.load_object(config, 'gcode_macro')
|
||||||
self.activate_gcode = gcode_macro.load_template(
|
self.activate_gcode = gcode_macro.load_template(
|
||||||
config, 'activate_gcode', '')
|
config, 'activate_gcode', '')
|
||||||
|
@ -287,29 +289,44 @@ class ProbeEndstopWrapper:
|
||||||
self.home_start = self.mcu_endstop.home_start
|
self.home_start = self.mcu_endstop.home_start
|
||||||
self.home_wait = self.mcu_endstop.home_wait
|
self.home_wait = self.mcu_endstop.home_wait
|
||||||
self.query_endstop = self.mcu_endstop.query_endstop
|
self.query_endstop = self.mcu_endstop.query_endstop
|
||||||
|
# multi probes state
|
||||||
|
self.multi = 'OFF'
|
||||||
def _build_config(self):
|
def _build_config(self):
|
||||||
kin = self.printer.lookup_object('toolhead').get_kinematics()
|
kin = self.printer.lookup_object('toolhead').get_kinematics()
|
||||||
for stepper in kin.get_steppers():
|
for stepper in kin.get_steppers():
|
||||||
if stepper.is_active_axis('z'):
|
if stepper.is_active_axis('z'):
|
||||||
self.add_stepper(stepper)
|
self.add_stepper(stepper)
|
||||||
def multi_probe_begin(self):
|
def raise_probe(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):
|
|
||||||
toolhead = self.printer.lookup_object('toolhead')
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
start_pos = toolhead.get_position()
|
start_pos = toolhead.get_position()
|
||||||
self.deactivate_gcode.run_gcode_from_command()
|
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]:
|
if toolhead.get_position()[:3] != start_pos[:3]:
|
||||||
raise self.printer.command_error(
|
raise self.printer.command_error(
|
||||||
"Toolhead moved during probe deactivate_gcode script")
|
"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):
|
def get_position_endstop(self):
|
||||||
return self.position_endstop
|
return self.position_endstop
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue