probe: Add multi_probe_begin() / multi_probe_end() callbacks
Add support for notifying the low-level probing handlers that a multiple probe sequence is occurring. This is in preparation for the bltouch code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
5bca4e6fa1
commit
1dd952ac65
|
@ -137,6 +137,10 @@ class BLTouchEndstopWrapper:
|
|||
# Test was successful
|
||||
self.next_test_time = check_end_time + TEST_TIME
|
||||
self.sync_print_time()
|
||||
def multi_probe_begin(self):
|
||||
pass
|
||||
def multi_probe_end(self):
|
||||
pass
|
||||
def probe_prepare(self):
|
||||
self.test_sensor()
|
||||
self.sync_print_time()
|
||||
|
|
|
@ -23,6 +23,7 @@ class PrinterProbe:
|
|||
self.y_offset = config.getfloat('y_offset', 0.)
|
||||
self.z_offset = config.getfloat('z_offset')
|
||||
self.probe_calibrate_z = 0.
|
||||
self.multi_probe_pending = False
|
||||
# Infer Z position to move to during a probe
|
||||
if config.has_section('stepper_z'):
|
||||
zconfig = config.getsection('stepper_z')
|
||||
|
@ -48,6 +49,12 @@ class PrinterProbe:
|
|||
self._handle_homing_move_begin)
|
||||
self.printer.register_event_handler("homing:homing_move_end",
|
||||
self._handle_homing_move_end)
|
||||
self.printer.register_event_handler("homing:home_rails_begin",
|
||||
self._handle_home_rails_begin)
|
||||
self.printer.register_event_handler("homing:home_rails_end",
|
||||
self._handle_home_rails_end)
|
||||
self.printer.register_event_handler("gcode:command_error",
|
||||
self.multi_probe_end)
|
||||
# Register PROBE/QUERY_PROBE commands
|
||||
self.gcode = self.printer.lookup_object('gcode')
|
||||
self.gcode.register_command('PROBE', self.cmd_PROBE,
|
||||
|
@ -64,6 +71,21 @@ class PrinterProbe:
|
|||
def _handle_homing_move_end(self, endstops):
|
||||
if self.mcu_probe in endstops:
|
||||
self.mcu_probe.probe_finalize()
|
||||
def _handle_home_rails_begin(self, rails):
|
||||
endstops = [es for rail in rails for es, name in rail.get_endstops()]
|
||||
if self.mcu_probe in endstops:
|
||||
self.multi_probe_begin()
|
||||
def _handle_home_rails_end(self, rails):
|
||||
endstops = [es for rail in rails for es, name in rail.get_endstops()]
|
||||
if self.mcu_probe in endstops:
|
||||
self.multi_probe_end()
|
||||
def multi_probe_begin(self):
|
||||
self.mcu_probe.multi_probe_begin()
|
||||
self.multi_probe_pending = True
|
||||
def multi_probe_end(self):
|
||||
if self.multi_probe_pending:
|
||||
self.multi_probe_pending = False
|
||||
self.mcu_probe.multi_probe_end()
|
||||
def setup_pin(self, pin_type, pin_params):
|
||||
if pin_type != 'endstop' or pin_params['pin'] != 'z_virtual_endstop':
|
||||
raise pins.error("Probe virtual endstop only useful as endstop pin")
|
||||
|
@ -131,6 +153,9 @@ class PrinterProbe:
|
|||
"SAMPLES_TOLERANCE_RETRIES", params, self.samples_retries, minval=0)
|
||||
samples_result = self.gcode.get_str(
|
||||
"SAMPLES_RESULT", params, self.samples_result)
|
||||
must_notify_multi_probe = not self.multi_probe_pending
|
||||
if must_notify_multi_probe:
|
||||
self.multi_probe_begin()
|
||||
retries = 0
|
||||
positions = []
|
||||
while len(positions) < sample_count:
|
||||
|
@ -151,6 +176,8 @@ class PrinterProbe:
|
|||
if len(positions) < sample_count:
|
||||
liftpos = [None, None, pos[2] + sample_retract_dist]
|
||||
self._move(liftpos, lift_speed)
|
||||
if must_notify_multi_probe:
|
||||
self.multi_probe_end()
|
||||
# Calculate and return result
|
||||
if samples_result == 'median':
|
||||
return self._calc_median(positions)
|
||||
|
@ -183,6 +210,7 @@ class PrinterProbe:
|
|||
sample_count, sample_retract_dist,
|
||||
speed, lift_speed))
|
||||
# Probe bed sample_count times
|
||||
self.multi_probe_begin()
|
||||
positions = []
|
||||
while len(positions) < sample_count:
|
||||
# Probe position
|
||||
|
@ -191,6 +219,7 @@ class PrinterProbe:
|
|||
# Retract
|
||||
liftpos = [None, None, pos[2] + sample_retract_dist]
|
||||
self._move(liftpos, lift_speed)
|
||||
self.multi_probe_end()
|
||||
# Calculate maximum, minimum and average values
|
||||
max_value = max([p[2] for p in positions])
|
||||
min_value = min([p[2] for p in positions])
|
||||
|
@ -266,6 +295,10 @@ class ProbeEndstopWrapper:
|
|||
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):
|
||||
toolhead = self.printer.lookup_object('toolhead')
|
||||
start_pos = toolhead.get_position()
|
||||
|
@ -361,12 +394,14 @@ class ProbePointsHelper:
|
|||
if self.horizontal_move_z < self.probe_offsets[2]:
|
||||
raise self.gcode.error("horizontal_move_z can't be less than"
|
||||
" probe's z_offset")
|
||||
probe.multi_probe_begin()
|
||||
while 1:
|
||||
done = self._move_next()
|
||||
if done:
|
||||
break
|
||||
pos = probe.run_probe(params)
|
||||
self.results.append(pos)
|
||||
probe.multi_probe_end()
|
||||
def _manual_probe_start(self):
|
||||
done = self._move_next()
|
||||
if not done:
|
||||
|
|
Loading…
Reference in New Issue