probe: Use manual_probe helper when performing manual probes

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-02-09 22:54:24 -05:00
parent 35ea4a137d
commit b0b9fc6f4a
2 changed files with 24 additions and 27 deletions

View File

@ -190,10 +190,10 @@ The following commands are available when the "delta_calibrate" config
section is enabled: section is enabled:
- `DELTA_CALIBRATE [METHOD=manual]`: This command will probe seven - `DELTA_CALIBRATE [METHOD=manual]`: This command will probe seven
points on the bed and recommend updated endstop positions, tower points on the bed and recommend updated endstop positions, tower
angles, and radius. angles, and radius. If METHOD=manual is specified then the manual
- `NEXT`: If manual bed probing is enabled, then one can use this probing tool is activated - see the MANUAL_PROBE command above for
command to move to the next probing point during a DELTA_CALIBRATE details on the additional commands available while this tool is
operation. active.
- `DELTA_ANALYZE`: This command is used during enhanced delta - `DELTA_ANALYZE`: This command is used during enhanced delta
calibration. See [Delta Calibrate](Delta_Calibrate.md) for details. calibration. See [Delta Calibrate](Delta_Calibrate.md) for details.
@ -203,10 +203,10 @@ The following commands are available when the "bed_tilt" config
section is enabled: section is enabled:
- `BED_TILT_CALIBRATE [METHOD=manual]`: This command will probe the - `BED_TILT_CALIBRATE [METHOD=manual]`: This command will probe the
points specified in the config and then recommend updated x and y points specified in the config and then recommend updated x and y
tilt adjustments. tilt adjustments. If METHOD=manual is specified then the manual
- `NEXT`: If manual bed probing is enabled, then one can use this probing tool is activated - see the MANUAL_PROBE command above for
command to move to the next probing point during a details on the additional commands available while this tool is
BED_TILT_CALIBRATE operation. active.
## Mesh Bed Leveling ## Mesh Bed Leveling
@ -215,10 +215,10 @@ section is enabled:
- `BED_MESH_CALIBRATE [METHOD=manual]`: This command probes the bed - `BED_MESH_CALIBRATE [METHOD=manual]`: This command probes the bed
using generated points specified by the parameters in the using generated points specified by the parameters in the
config. After probing, a mesh is generated and z-movement is config. After probing, a mesh is generated and z-movement is
adjusted according to the mesh. adjusted according to the mesh. If METHOD=manual is specified then
- `NEXT`: If manual bed probing is enabled, then one can use this the manual probing tool is activated - see the MANUAL_PROBE command
command to move to the next probing point during a above for details on the additional commands available while this
BED_MESH_CALIBRATE operation. tool is active.
- `BED_MESH_OUTPUT`: This command outputs the current probed z values - `BED_MESH_OUTPUT`: This command outputs the current probed z values
and current mesh values to the terminal. and current mesh values to the terminal.
- `BED_MESH_MAP`: This command probes the bed in a similar fashion - `BED_MESH_MAP`: This command probes the bed in a similar fashion

View File

@ -169,7 +169,7 @@ class ProbePointsHelper:
'sample_retract_dist', 2., above=0.) 'sample_retract_dist', 2., above=0.)
# Internal probing state # Internal probing state
self.results = [] self.results = []
self.busy = False self.busy = self.manual_probe = False
self.gcode = self.toolhead = None self.gcode = self.toolhead = None
def get_lift_speed(self): def get_lift_speed(self):
return self.lift_speed return self.lift_speed
@ -207,6 +207,9 @@ class ProbePointsHelper:
self._finalize(False) self._finalize(False)
raise self.gcode.error(str(e)) raise self.gcode.error(str(e))
self.gcode.reset_last_position() self.gcode.reset_last_position()
if self.manual_probe:
manual_probe.ManualProbeHelper(self.printer, {},
self._manual_probe_finalize)
def _automatic_probe_point(self): def _automatic_probe_point(self):
positions = [] positions = []
for i in range(self.samples): for i in range(self.samples):
@ -229,13 +232,14 @@ class ProbePointsHelper:
probe = self.printer.lookup_object('probe', None) probe = self.printer.lookup_object('probe', None)
method = self.gcode.get_str('METHOD', params, 'automatic').lower() method = self.gcode.get_str('METHOD', params, 'automatic').lower()
if probe is not None and method == 'automatic': if probe is not None and method == 'automatic':
self.manual_probe = False
self.lift_speed = min(self.speed, probe.speed) self.lift_speed = min(self.speed, probe.speed)
self.probe_offsets = probe.get_offsets() self.probe_offsets = probe.get_offsets()
if self.horizontal_move_z < self.probe_offsets[2]: if self.horizontal_move_z < self.probe_offsets[2]:
raise self.gcode.error("horizontal_move_z can't be less than" raise self.gcode.error("horizontal_move_z can't be less than"
" probe's z_offset") " probe's z_offset")
else: else:
probe = None self.manual_probe = True
self.lift_speed = self.speed self.lift_speed = self.speed
self.probe_offsets = (0., 0., 0.) self.probe_offsets = (0., 0., 0.)
# Start probe # Start probe
@ -243,27 +247,20 @@ class ProbePointsHelper:
self.busy = True self.busy = True
self._lift_z(self.horizontal_move_z, speed=self.speed) self._lift_z(self.horizontal_move_z, speed=self.speed)
self._move_next() self._move_next()
if probe is None: if not self.manual_probe:
# Setup for manual probing
self.gcode.register_command('NEXT', None)
self.gcode.register_command('NEXT', self.cmd_NEXT,
desc=self.cmd_NEXT_help)
else:
# Perform automatic probing # Perform automatic probing
while self.busy: while self.busy:
self._automatic_probe_point() self._automatic_probe_point()
self._move_next() self._move_next()
cmd_NEXT_help = "Move to the next XY position to probe" def _manual_probe_finalize(self, kin_pos):
def cmd_NEXT(self, params): if kin_pos is None:
# Record current position for manual probe self._finalize(False)
self.toolhead.get_last_move_time() return
self.results.append(self.toolhead.get_kinematics().calc_position()) self.results.append(kin_pos)
# Move to next position
self._move_next() self._move_next()
def _finalize(self, success): def _finalize(self, success):
self.busy = False self.busy = False
self.gcode.reset_last_position() self.gcode.reset_last_position()
self.gcode.register_command('NEXT', None)
if success: if success:
self.finalize_callback(self.probe_offsets, self.results) self.finalize_callback(self.probe_offsets, self.results)