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:
parent
84bae6ff41
commit
9887e72570
|
@ -195,6 +195,7 @@ class BedMeshCalibrate:
|
||||||
self._init_probe_params(config, points)
|
self._init_probe_params(config, points)
|
||||||
self.probe_helper = probe.ProbePointsHelper(
|
self.probe_helper = probe.ProbePointsHelper(
|
||||||
config, self.probe_finalize, points)
|
config, self.probe_finalize, points)
|
||||||
|
self.probe_helper.minimum_points(3)
|
||||||
# setup persistent storage
|
# setup persistent storage
|
||||||
self.profiles = {}
|
self.profiles = {}
|
||||||
self._load_storage(config)
|
self._load_storage(config)
|
||||||
|
|
|
@ -44,6 +44,7 @@ class BedTiltCalibrate:
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.bedtilt = bedtilt
|
self.bedtilt = bedtilt
|
||||||
self.probe_helper = probe.ProbePointsHelper(config, self.probe_finalize)
|
self.probe_helper = probe.ProbePointsHelper(config, self.probe_finalize)
|
||||||
|
self.probe_helper.minimum_points(3)
|
||||||
# Register BED_TILT_CALIBRATE command
|
# Register BED_TILT_CALIBRATE command
|
||||||
self.gcode = self.printer.lookup_object('gcode')
|
self.gcode = self.printer.lookup_object('gcode')
|
||||||
self.gcode.register_command(
|
self.gcode.register_command(
|
||||||
|
|
|
@ -143,6 +143,7 @@ class DeltaCalibrate:
|
||||||
points.append((math.cos(r) * dist, math.sin(r) * dist))
|
points.append((math.cos(r) * dist, math.sin(r) * dist))
|
||||||
self.probe_helper = probe.ProbePointsHelper(
|
self.probe_helper = probe.ProbePointsHelper(
|
||||||
config, self.probe_finalize, default_points=points)
|
config, self.probe_finalize, default_points=points)
|
||||||
|
self.probe_helper.minimum_points(3)
|
||||||
# Restore probe stable positions
|
# Restore probe stable positions
|
||||||
self.last_probe_positions = []
|
self.last_probe_positions = []
|
||||||
for i in range(999):
|
for i in range(999):
|
||||||
|
|
|
@ -226,6 +226,7 @@ class ProbePointsHelper:
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.finalize_callback = finalize_callback
|
self.finalize_callback = finalize_callback
|
||||||
self.probe_points = default_points
|
self.probe_points = default_points
|
||||||
|
self.name = config.get_name()
|
||||||
# Read config settings
|
# Read config settings
|
||||||
if default_points is None or config.get('points', None) is not None:
|
if default_points is None or config.get('points', None) is not None:
|
||||||
points = config.get('points').split('\n')
|
points = config.get('points').split('\n')
|
||||||
|
@ -235,10 +236,7 @@ class ProbePointsHelper:
|
||||||
for p in points]
|
for p in points]
|
||||||
except:
|
except:
|
||||||
raise config.error("Unable to parse probe points in %s" % (
|
raise config.error("Unable to parse probe points in %s" % (
|
||||||
config.get_name()))
|
self.name))
|
||||||
if len(self.probe_points) < 3:
|
|
||||||
raise config.error("Need at least 3 probe points for %s" % (
|
|
||||||
config.get_name()))
|
|
||||||
self.horizontal_move_z = config.getfloat('horizontal_move_z', 5.)
|
self.horizontal_move_z = config.getfloat('horizontal_move_z', 5.)
|
||||||
self.speed = self.lift_speed = config.getfloat('speed', 50., above=0.)
|
self.speed = self.lift_speed = config.getfloat('speed', 50., above=0.)
|
||||||
self.probe_offsets = (0., 0., 0.)
|
self.probe_offsets = (0., 0., 0.)
|
||||||
|
@ -252,6 +250,10 @@ class ProbePointsHelper:
|
||||||
self.results = []
|
self.results = []
|
||||||
self.busy = self.manual_probe = False
|
self.busy = self.manual_probe = False
|
||||||
self.gcode = self.toolhead = None
|
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):
|
def get_lift_speed(self):
|
||||||
return self.lift_speed
|
return self.lift_speed
|
||||||
def _lift_z(self, z_pos, add=False, speed=None):
|
def _lift_z(self, z_pos, add=False, speed=None):
|
||||||
|
|
|
@ -14,6 +14,7 @@ class QuadGantryLevel:
|
||||||
self.printer.register_event_handler("klippy:connect",
|
self.printer.register_event_handler("klippy:connect",
|
||||||
self.handle_connect)
|
self.handle_connect)
|
||||||
self.probe_helper = probe.ProbePointsHelper(config, self.probe_finalize)
|
self.probe_helper = probe.ProbePointsHelper(config, self.probe_finalize)
|
||||||
|
self.probe_helper.minimum_points(3)
|
||||||
gantry_corners = config.get('gantry_corners').split('\n')
|
gantry_corners = config.get('gantry_corners').split('\n')
|
||||||
try:
|
try:
|
||||||
gantry_corners = [line.split(',', 1)
|
gantry_corners = [line.split(',', 1)
|
||||||
|
|
|
@ -46,6 +46,7 @@ class ScrewsTiltAdjust:
|
||||||
self.probe_helper = probe.ProbePointsHelper(self.config,
|
self.probe_helper = probe.ProbePointsHelper(self.config,
|
||||||
self.probe_finalize,
|
self.probe_finalize,
|
||||||
default_points=points)
|
default_points=points)
|
||||||
|
self.probe_helper.minimum_points(3)
|
||||||
# Register command
|
# Register command
|
||||||
self.gcode = self.printer.lookup_object('gcode')
|
self.gcode = self.printer.lookup_object('gcode')
|
||||||
self.gcode.register_command("SCREWS_TILT_CALCULATE",
|
self.gcode.register_command("SCREWS_TILT_CALCULATE",
|
||||||
|
|
|
@ -23,6 +23,7 @@ class ZTilt:
|
||||||
if len(z_positions) < 2:
|
if len(z_positions) < 2:
|
||||||
raise config.error("z_tilt requires at least two z_positions")
|
raise config.error("z_tilt requires at least two z_positions")
|
||||||
self.probe_helper = probe.ProbePointsHelper(config, self.probe_finalize)
|
self.probe_helper = probe.ProbePointsHelper(config, self.probe_finalize)
|
||||||
|
self.probe_helper.minimum_points(3)
|
||||||
self.z_steppers = []
|
self.z_steppers = []
|
||||||
# Register Z_TILT_ADJUST command
|
# Register Z_TILT_ADJUST command
|
||||||
self.gcode = self.printer.lookup_object('gcode')
|
self.gcode = self.printer.lookup_object('gcode')
|
||||||
|
|
Loading…
Reference in New Issue