aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorArksine <arksine.code@gmail.com>2020-08-23 07:35:51 -0400
committerKevinOConnor <kevin@koconnor.net>2020-09-15 20:36:55 -0400
commit6e77fd27cdf8374fae19e403083c6dd1abc86211 (patch)
treeba6321169081f88e2b603568189a212ef3195bb7 /klippy
parent98931789d863aa3dcef139e8294d8a18be53d206 (diff)
downloadkutter-6e77fd27cdf8374fae19e403083c6dd1abc86211.tar.gz
kutter-6e77fd27cdf8374fae19e403083c6dd1abc86211.tar.xz
kutter-6e77fd27cdf8374fae19e403083c6dd1abc86211.zip
bed_mesh: move algorithm verification to its own method
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/extras/bed_mesh.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/klippy/extras/bed_mesh.py b/klippy/extras/bed_mesh.py
index 86058f5c..5a497197 100644
--- a/klippy/extras/bed_mesh.py
+++ b/klippy/extras/bed_mesh.py
@@ -343,26 +343,33 @@ class BedMeshCalibrate:
params['mesh_x_pps'] = pps[0]
params['mesh_y_pps'] = pps[1]
params['algo'] = config.get('algorithm', 'lagrange').strip().lower()
+ params['tension'] = config.getfloat(
+ 'bicubic_tension', .2, minval=0., maxval=2.)
+ self._verify_algorithm(config.error)
+ def _verify_algorithm(self, error):
+ params = self.mesh_config
+ x_pps = params['mesh_x_pps']
+ y_pps = params['mesh_y_pps']
if params['algo'] not in self.ALGOS:
- raise config.error(
+ raise error(
"bed_mesh: Unknown algorithm <%s>"
% (self.mesh_config['algo']))
# Check the algorithm against the current configuration
max_probe_cnt = max(params['x_count'], params['y_count'])
min_probe_cnt = min(params['x_count'], params['y_count'])
- if max(pps[0], pps[1]) == 0:
+ if max(x_pps, y_pps) == 0:
# Interpolation disabled
self.mesh_config['algo'] = 'direct'
elif params['algo'] == 'lagrange' and max_probe_cnt > 6:
# Lagrange interpolation tends to oscillate when using more
# than 6 samples
- raise config.error(
+ raise error(
"bed_mesh: cannot exceed a probe_count of 6 when using "
"lagrange interpolation. Configured Probe Count: %d, %d" %
(self.mesh_config['x_count'], self.mesh_config['y_count']))
elif params['algo'] == 'bicubic' and min_probe_cnt < 4:
if max_probe_cnt > 6:
- raise config.error(
+ raise error(
"bed_mesh: invalid probe_count option when using bicubic "
"interpolation. Combination of 3 points on one axis with "
"more than 6 on another is not permitted. "
@@ -375,8 +382,6 @@ class BedMeshCalibrate:
"interpolation. Configured Probe Count: %d, %d" %
(self.mesh_config['x_count'], self.mesh_config['y_count']))
params['algo'] = 'lagrange'
- params['tension'] = config.getfloat(
- 'bicubic_tension', .2, minval=0., maxval=2.)
cmd_BED_MESH_CALIBRATE_help = "Perform Mesh Bed Leveling"
def cmd_BED_MESH_CALIBRATE(self, gcmd):
self.bedmesh.set_mesh(None)