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:
- `DELTA_CALIBRATE [METHOD=manual]`: This command will probe seven
points on the bed and recommend updated endstop positions, tower
angles, and radius.
- `NEXT`: If manual bed probing is enabled, then one can use this
command to move to the next probing point during a DELTA_CALIBRATE
operation.
angles, and radius. If METHOD=manual is specified then the manual
probing tool is activated - see the MANUAL_PROBE command above for
details on the additional commands available while this tool is
active.
- `DELTA_ANALYZE`: This command is used during enhanced delta
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:
- `BED_TILT_CALIBRATE [METHOD=manual]`: This command will probe the
points specified in the config and then recommend updated x and y
tilt adjustments.
- `NEXT`: If manual bed probing is enabled, then one can use this
command to move to the next probing point during a
BED_TILT_CALIBRATE operation.
tilt adjustments. If METHOD=manual is specified then the manual
probing tool is activated - see the MANUAL_PROBE command above for
details on the additional commands available while this tool is
active.
## Mesh Bed Leveling
@ -215,10 +215,10 @@ section is enabled:
- `BED_MESH_CALIBRATE [METHOD=manual]`: This command probes the bed
using generated points specified by the parameters in the
config. After probing, a mesh is generated and z-movement is
adjusted according to the mesh.
- `NEXT`: If manual bed probing is enabled, then one can use this
command to move to the next probing point during a
BED_MESH_CALIBRATE operation.
adjusted according to the mesh. If METHOD=manual is specified then
the manual probing tool is activated - see the MANUAL_PROBE command
above for details on the additional commands available while this
tool is active.
- `BED_MESH_OUTPUT`: This command outputs the current probed z values
and current mesh values to the terminal.
- `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.)
# Internal probing state
self.results = []
self.busy = False
self.busy = self.manual_probe = False
self.gcode = self.toolhead = None
def get_lift_speed(self):
return self.lift_speed
@ -207,6 +207,9 @@ class ProbePointsHelper:
self._finalize(False)
raise self.gcode.error(str(e))
self.gcode.reset_last_position()
if self.manual_probe:
manual_probe.ManualProbeHelper(self.printer, {},
self._manual_probe_finalize)
def _automatic_probe_point(self):
positions = []
for i in range(self.samples):
@ -229,13 +232,14 @@ class ProbePointsHelper:
probe = self.printer.lookup_object('probe', None)
method = self.gcode.get_str('METHOD', params, 'automatic').lower()
if probe is not None and method == 'automatic':
self.manual_probe = False
self.lift_speed = min(self.speed, probe.speed)
self.probe_offsets = probe.get_offsets()
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")
else:
probe = None
self.manual_probe = True
self.lift_speed = self.speed
self.probe_offsets = (0., 0., 0.)
# Start probe
@ -243,27 +247,20 @@ class ProbePointsHelper:
self.busy = True
self._lift_z(self.horizontal_move_z, speed=self.speed)
self._move_next()
if probe is None:
# Setup for manual probing
self.gcode.register_command('NEXT', None)
self.gcode.register_command('NEXT', self.cmd_NEXT,
desc=self.cmd_NEXT_help)
else:
if not self.manual_probe:
# Perform automatic probing
while self.busy:
self._automatic_probe_point()
self._move_next()
cmd_NEXT_help = "Move to the next XY position to probe"
def cmd_NEXT(self, params):
# Record current position for manual probe
self.toolhead.get_last_move_time()
self.results.append(self.toolhead.get_kinematics().calc_position())
# Move to next position
def _manual_probe_finalize(self, kin_pos):
if kin_pos is None:
self._finalize(False)
return
self.results.append(kin_pos)
self._move_next()
def _finalize(self, success):
self.busy = False
self.gcode.reset_last_position()
self.gcode.register_command('NEXT', None)
if success:
self.finalize_callback(self.probe_offsets, self.results)