aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/bed_mesh.py
diff options
context:
space:
mode:
authorArksine <arksine.code@gmail.com>2018-08-25 12:00:08 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-08-29 12:01:19 -0400
commit40b7ba5111fefe34f7d251ecb7d6c5278784c912 (patch)
tree9e30f547831c24b4abf1b25afe8a7ee5b854b56e /klippy/extras/bed_mesh.py
parent1588426229909809db017f76b086ce7c8da16677 (diff)
downloadkutter-40b7ba5111fefe34f7d251ecb7d6c5278784c912.tar.gz
kutter-40b7ba5111fefe34f7d251ecb7d6c5278784c912.tar.xz
kutter-40b7ba5111fefe34f7d251ecb7d6c5278784c912.zip
probe: Add ability to multi-sample points to ProbePointsHelper
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Diffstat (limited to 'klippy/extras/bed_mesh.py')
-rw-r--r--klippy/extras/bed_mesh.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/klippy/extras/bed_mesh.py b/klippy/extras/bed_mesh.py
index 97a87ef9..490148c1 100644
--- a/klippy/extras/bed_mesh.py
+++ b/klippy/extras/bed_mesh.py
@@ -245,9 +245,15 @@ class BedMeshCalibrate:
# create a 2-D array representing the probed z-positions.
self.probed_z_table = [
[0. for i in range(x_cnt)] for j in range(y_cnt)]
- # Extract probed z-positions from probed positions and add
- # them to organized list
- for i, pos in enumerate(positions):
+ # Check for multi-sampled points
+ z_table_len = x_cnt * y_cnt
+ if len(positions) % z_table_len:
+ raise self.gcode.error(
+ ("bed_mesh: Invalid probe table length:\n"
+ "Sampled table length: %d") % len(positions))
+ samples = len(positions) / z_table_len
+ # Populate the organized probed table
+ for i in range(z_table_len):
y_position = i / x_cnt
x_position = 0
if y_position & 1 == 0:
@@ -256,8 +262,11 @@ class BedMeshCalibrate:
else:
# Odd y count, x probed in the negative directon
x_position = (x_cnt - 1) - (i % x_cnt)
+ idx = i * samples
+ end = idx + samples
+ avg_z = sum(p[2] for p in positions[idx:end]) / samples
self.probed_z_table[y_position][x_position] = \
- pos[2] - z_offset
+ avg_z - z_offset
if self.build_map:
outdict = {'z_probe_offsets:': self.probed_z_table}
self.gcode.respond(json.dumps(outdict))