diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-09-26 13:07:18 -0400 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2018-10-01 11:12:30 -0400 |
commit | 33887b8c396c5933cf6bd3ad653eec32834f2c9f (patch) | |
tree | c37b0c049088529b123dfadb64a8f13af1cdc564 /klippy | |
parent | 0e9b8abde2940eb17aad0337cb0dd55f6fadffb9 (diff) | |
download | kutter-33887b8c396c5933cf6bd3ad653eec32834f2c9f.tar.gz kutter-33887b8c396c5933cf6bd3ad653eec32834f2c9f.tar.xz kutter-33887b8c396c5933cf6bd3ad653eec32834f2c9f.zip |
probe: Support manual probing at runtime
Don't require the config file to specify manual probing. Instead,
allow the user to select manual probing on each ProbePointsHelper
invocation.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r-- | klippy/extras/bed_mesh.py | 8 | ||||
-rw-r--r-- | klippy/extras/bed_tilt.py | 2 | ||||
-rw-r--r-- | klippy/extras/delta_calibrate.py | 2 | ||||
-rw-r--r-- | klippy/extras/probe.py | 38 | ||||
-rw-r--r-- | klippy/extras/quad_gantry_level.py | 2 | ||||
-rw-r--r-- | klippy/extras/z_tilt.py | 2 |
6 files changed, 27 insertions, 27 deletions
diff --git a/klippy/extras/bed_mesh.py b/klippy/extras/bed_mesh.py index d31c2609..5a7a622d 100644 --- a/klippy/extras/bed_mesh.py +++ b/klippy/extras/bed_mesh.py @@ -204,15 +204,15 @@ class BedMeshCalibrate: cmd_BED_MESH_MAP_help = "Probe the bed and serialize output" def cmd_BED_MESH_MAP(self, params): self.build_map = True - self.start_calibration() + self.start_calibration(params) cmd_BED_MESH_CALIBRATE_help = "Perform Mesh Bed Leveling" def cmd_BED_MESH_CALIBRATE(self, params): self.build_map = False - self.start_calibration() - def start_calibration(self): + self.start_calibration(params) + def start_calibration(self, params): self.bedmesh.set_mesh(None) self.gcode.run_script_from_command("G28") - self.probe_helper.start_probe() + self.probe_helper.start_probe(params) def print_probed_positions(self, print_func): if self.probed_z_table is not None: msg = "Mesh Leveling Probed Z positions:\n" diff --git a/klippy/extras/bed_tilt.py b/klippy/extras/bed_tilt.py index 558047cc..67c61a62 100644 --- a/klippy/extras/bed_tilt.py +++ b/klippy/extras/bed_tilt.py @@ -56,7 +56,7 @@ class BedTiltCalibrate: cmd_BED_TILT_CALIBRATE_help = "Bed tilt calibration script" def cmd_BED_TILT_CALIBRATE(self, params): self.gcode.run_script_from_command("G28") - self.probe_helper.start_probe() + self.probe_helper.start_probe(params) def probe_finalize(self, offsets, positions): z_offset = offsets[2] logging.info("Calculating bed_tilt with: %s", positions) diff --git a/klippy/extras/delta_calibrate.py b/klippy/extras/delta_calibrate.py index 78a46586..b30ffaf2 100644 --- a/klippy/extras/delta_calibrate.py +++ b/klippy/extras/delta_calibrate.py @@ -275,7 +275,7 @@ class DeltaCalibrate: cmd_DELTA_CALIBRATE_help = "Delta calibration script" def cmd_DELTA_CALIBRATE(self, params): self.gcode.run_script_from_command("G28") - self.probe_helper.start_probe() + self.probe_helper.start_probe(params) def do_extended_calibration(self): # Extract distance positions if len(self.delta_analyze_entry) <= 1: diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py index 3b96a9a3..df5f9268 100644 --- a/klippy/extras/probe.py +++ b/klippy/extras/probe.py @@ -155,23 +155,10 @@ class ProbePointsHelper: config.get_name())) self.horizontal_move_z = config.getfloat('horizontal_move_z', 5.) self.speed = self.lift_speed = config.getfloat('speed', 50., above=0.) - # Lookup probe object - self.probe = None self.probe_offsets = (0., 0., 0.) self.samples = config.getint('samples', 1, minval=1) self.sample_retract_dist = config.getfloat( 'sample_retract_dist', 2., above=0.) - manual_probe = config.getboolean('manual_probe', None) - if manual_probe is None: - manual_probe = not config.has_section('probe') - if not manual_probe: - self.printer.try_load_module(config, 'probe') - self.probe = self.printer.lookup_object('probe') - self.lift_speed = min(self.speed, self.probe.speed) - self.probe_offsets = self.probe.get_offsets() - if self.horizontal_move_z < self.probe_offsets[2]: - raise config.error("horizontal_move_z can't be less than probe's" - " z_offset in %s" % (config.get_name())) # Internal probing state self.results = [] self.busy = False @@ -179,10 +166,10 @@ class ProbePointsHelper: def get_lift_speed(self): return self.lift_speed def get_last_xy_home_positon(self): - if self.probe is not None: - return self.probe.last_home_position() - else: + probe = self.printer.lookup_object('probe', None) + if probe is None: return None + return probe.last_home_position() def _lift_z(self, z_pos, add=False, speed=None): # Lift toolhead curpos = self.toolhead.get_position() @@ -232,15 +219,28 @@ class ProbePointsHelper: avg_pos = [sum([pos[i] for pos in positions]) / self.samples for i in range(3)] self.results.append(avg_pos) - def start_probe(self): - # Begin probing + def start_probe(self, params): + # Lookup objects self.toolhead = self.printer.lookup_object('toolhead') self.gcode = self.printer.lookup_object('gcode') + 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.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.lift_speed = self.speed + self.probe_offsets = (0., 0., 0.) + # Start probe self.results = [] self.busy = True self._lift_z(self.horizontal_move_z, speed=self.speed) self._move_next() - if self.probe is None: + if probe is None: # Setup for manual probing self.gcode.register_command('NEXT', None) self.gcode.register_command('NEXT', self.cmd_NEXT, diff --git a/klippy/extras/quad_gantry_level.py b/klippy/extras/quad_gantry_level.py index 9eb1810c..b9f91f1f 100644 --- a/klippy/extras/quad_gantry_level.py +++ b/klippy/extras/quad_gantry_level.py @@ -38,7 +38,7 @@ class QuadGantryLevel: self.z_steppers = z_steppers cmd_QUAD_GANTRY_LEVEL_help = "Conform a moving, twistable gantry to the shape of a stationary bed" def cmd_QUAD_GANTRY_LEVEL(self, params): - self.probe_helper.start_probe() + self.probe_helper.start_probe(params) def probe_finalize(self, offsets, positions): logging.info("quad_gantry_level Calculating gantry geometry with: %s", positions) p1 = [positions[0][0] + offsets[0],positions[0][2]] diff --git a/klippy/extras/z_tilt.py b/klippy/extras/z_tilt.py index f5c4614d..e6e1aab8 100644 --- a/klippy/extras/z_tilt.py +++ b/klippy/extras/z_tilt.py @@ -39,7 +39,7 @@ class ZTilt: self.z_steppers = z_steppers cmd_Z_TILT_ADJUST_help = "Adjust the Z tilt" def cmd_Z_TILT_ADJUST(self, params): - self.probe_helper.start_probe() + self.probe_helper.start_probe(params) def probe_finalize(self, offsets, positions): z_offset = offsets[2] logging.info("Calculating bed tilt with: %s", positions) |