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>
This commit is contained in:
fess 2019-05-17 20:47:27 -07:00 committed by KevinOConnor
parent 84bae6ff41
commit 9887e72570
7 changed files with 12 additions and 4 deletions

View File

@ -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)

View File

@ -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(

View File

@ -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):

View File

@ -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):

View File

@ -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)

View File

@ -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",

View File

@ -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')