aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfess <fess@fess.org>2019-05-17 20:47:27 -0700
committerKevinOConnor <kevin@koconnor.net>2019-05-21 14:17:09 -0400
commit9887e725702aa4867f4fa03fecb243a32e5c8880 (patch)
treeed176ac791b984dba33aaf9a900bf7b3b56e05dc
parent84bae6ff41283a161b16321c72a68813d4ff333a (diff)
downloadkutter-9887e725702aa4867f4fa03fecb243a32e5c8880.tar.gz
kutter-9887e725702aa4867f4fa03fecb243a32e5c8880.tar.xz
kutter-9887e725702aa4867f4fa03fecb243a32e5c8880.zip
probe: ProbePointsHelper adjustable minimum points
Factor out minimum required points check for ProbePointsHelper in prep for setting different values for quad_gantry_level and z_tilt_adjust Signed-off-by: John "Fess" Fessenden <fess@fess.org>
-rw-r--r--klippy/extras/bed_mesh.py1
-rw-r--r--klippy/extras/bed_tilt.py1
-rw-r--r--klippy/extras/delta_calibrate.py1
-rw-r--r--klippy/extras/probe.py10
-rw-r--r--klippy/extras/quad_gantry_level.py1
-rw-r--r--klippy/extras/screws_tilt_adjust.py1
-rw-r--r--klippy/extras/z_tilt.py1
7 files changed, 12 insertions, 4 deletions
diff --git a/klippy/extras/bed_mesh.py b/klippy/extras/bed_mesh.py
index ec2b88ad..84977805 100644
--- a/klippy/extras/bed_mesh.py
+++ b/klippy/extras/bed_mesh.py
@@ -195,6 +195,7 @@ class BedMeshCalibrate:
self._init_probe_params(config, points)
self.probe_helper = probe.ProbePointsHelper(
config, self.probe_finalize, points)
+ self.probe_helper.minimum_points(3)
# setup persistent storage
self.profiles = {}
self._load_storage(config)
diff --git a/klippy/extras/bed_tilt.py b/klippy/extras/bed_tilt.py
index b94bf189..0826f765 100644
--- a/klippy/extras/bed_tilt.py
+++ b/klippy/extras/bed_tilt.py
@@ -44,6 +44,7 @@ class BedTiltCalibrate:
self.printer = config.get_printer()
self.bedtilt = bedtilt
self.probe_helper = probe.ProbePointsHelper(config, self.probe_finalize)
+ self.probe_helper.minimum_points(3)
# Register BED_TILT_CALIBRATE command
self.gcode = self.printer.lookup_object('gcode')
self.gcode.register_command(
diff --git a/klippy/extras/delta_calibrate.py b/klippy/extras/delta_calibrate.py
index 429779aa..cc74c0b8 100644
--- a/klippy/extras/delta_calibrate.py
+++ b/klippy/extras/delta_calibrate.py
@@ -143,6 +143,7 @@ class DeltaCalibrate:
points.append((math.cos(r) * dist, math.sin(r) * dist))
self.probe_helper = probe.ProbePointsHelper(
config, self.probe_finalize, default_points=points)
+ self.probe_helper.minimum_points(3)
# Restore probe stable positions
self.last_probe_positions = []
for i in range(999):
diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py
index 09363056..84bf5c9d 100644
--- a/klippy/extras/probe.py
+++ b/klippy/extras/probe.py
@@ -226,6 +226,7 @@ class ProbePointsHelper:
self.printer = config.get_printer()
self.finalize_callback = finalize_callback
self.probe_points = default_points
+ self.name = config.get_name()
# Read config settings
if default_points is None or config.get('points', None) is not None:
points = config.get('points').split('\n')
@@ -235,10 +236,7 @@ class ProbePointsHelper:
for p in points]
except:
raise config.error("Unable to parse probe points in %s" % (
- config.get_name()))
- if len(self.probe_points) < 3:
- raise config.error("Need at least 3 probe points for %s" % (
- config.get_name()))
+ self.name))
self.horizontal_move_z = config.getfloat('horizontal_move_z', 5.)
self.speed = self.lift_speed = config.getfloat('speed', 50., above=0.)
self.probe_offsets = (0., 0., 0.)
@@ -252,6 +250,10 @@ class ProbePointsHelper:
self.results = []
self.busy = self.manual_probe = False
self.gcode = self.toolhead = None
+ def minimum_points(self,n):
+ if len(self.probe_points) < n:
+ raise self.printer.config_error(
+ "Need at least %d probe points for %s" % (n, self.name))
def get_lift_speed(self):
return self.lift_speed
def _lift_z(self, z_pos, add=False, speed=None):
diff --git a/klippy/extras/quad_gantry_level.py b/klippy/extras/quad_gantry_level.py
index 32dd3b7d..09f7e886 100644
--- a/klippy/extras/quad_gantry_level.py
+++ b/klippy/extras/quad_gantry_level.py
@@ -14,6 +14,7 @@ class QuadGantryLevel:
self.printer.register_event_handler("klippy:connect",
self.handle_connect)
self.probe_helper = probe.ProbePointsHelper(config, self.probe_finalize)
+ self.probe_helper.minimum_points(3)
gantry_corners = config.get('gantry_corners').split('\n')
try:
gantry_corners = [line.split(',', 1)
diff --git a/klippy/extras/screws_tilt_adjust.py b/klippy/extras/screws_tilt_adjust.py
index 663127c2..35a87699 100644
--- a/klippy/extras/screws_tilt_adjust.py
+++ b/klippy/extras/screws_tilt_adjust.py
@@ -46,6 +46,7 @@ class ScrewsTiltAdjust:
self.probe_helper = probe.ProbePointsHelper(self.config,
self.probe_finalize,
default_points=points)
+ self.probe_helper.minimum_points(3)
# Register command
self.gcode = self.printer.lookup_object('gcode')
self.gcode.register_command("SCREWS_TILT_CALCULATE",
diff --git a/klippy/extras/z_tilt.py b/klippy/extras/z_tilt.py
index d679d398..db8f76dd 100644
--- a/klippy/extras/z_tilt.py
+++ b/klippy/extras/z_tilt.py
@@ -23,6 +23,7 @@ class ZTilt:
if len(z_positions) < 2:
raise config.error("z_tilt requires at least two z_positions")
self.probe_helper = probe.ProbePointsHelper(config, self.probe_finalize)
+ self.probe_helper.minimum_points(3)
self.z_steppers = []
# Register Z_TILT_ADJUST command
self.gcode = self.printer.lookup_object('gcode')