aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Stuettgen <johannes.stuettgen@gmail.com>2021-02-08 17:52:46 +0100
committerKevinOConnor <kevin@koconnor.net>2021-04-28 11:53:18 -0400
commited6ab6b9cc2841a6dda8103fee01a18d1a43c76a (patch)
tree115045e5f00fee3b0944e9ac3f959e5e57b5d433
parentd36dbfebd17500f0af176abd88d8b258c7940e47 (diff)
downloadkutter-ed6ab6b9cc2841a6dda8103fee01a18d1a43c76a.tar.gz
kutter-ed6ab6b9cc2841a6dda8103fee01a18d1a43c76a.tar.xz
kutter-ed6ab6b9cc2841a6dda8103fee01a18d1a43c76a.zip
screws_tilt_adjust: Add MAX_DEVIATION parameter for bed level invariant.
This is useful when a saved bed mesh is used to ensure that the bed level has not drifted too far from where it was when the mesh was created. Signed-off-by: Johannes Stuettgen <johannes.stuettgen@gmail.com>
-rw-r--r--docs/Manual_Level.md7
-rw-r--r--klippy/extras/screws_tilt_adjust.py8
-rw-r--r--test/klippy/screws_tilt_adjust.test1
3 files changed, 16 insertions, 0 deletions
diff --git a/docs/Manual_Level.md b/docs/Manual_Level.md
index 3ae75447..a50e6daf 100644
--- a/docs/Manual_Level.md
+++ b/docs/Manual_Level.md
@@ -191,3 +191,10 @@ it has an X or Y offset) then note that adjusting the bed tilt will
invalidate any previous probe calibration that was performed with a
tilted bed. Be sure to run [probe calibration](Probe_Calibrate.md)
after the bed screws have been adjusted.
+
+The `MAX_DEVIATION` parameter is useful when a saved bed mesh is used,
+to ensure that the bed level has not drifted too far from where it was when
+the mesh was created. For example, `SCREWS_TILT_CALCULATE MAX_DEVIATION=0.01`
+can be added to the custom start gcode of the slicer before the mesh is loaded.
+It will abort the print if the configured limit is exceeded (0.01mm in this
+example), giving the user a chance to adjust the screws and restart the print.
diff --git a/klippy/extras/screws_tilt_adjust.py b/klippy/extras/screws_tilt_adjust.py
index 2dd54af3..30e091ff 100644
--- a/klippy/extras/screws_tilt_adjust.py
+++ b/klippy/extras/screws_tilt_adjust.py
@@ -19,6 +19,7 @@ class ScrewsTiltAdjust:
self.config = config
self.printer = config.get_printer()
self.screws = []
+ self.max_diff = None
# Read config
for i in range(99):
prefix = "screw%d" % (i + 1,)
@@ -51,11 +52,13 @@ class ScrewsTiltAdjust:
"of turns to level it."
def cmd_SCREWS_TILT_CALCULATE(self, gcmd):
+ self.max_diff = gcmd.get_float("MAX_DEVIATION", None)
self.probe_helper.start_probe(gcmd)
def probe_finalize(self, offsets, positions):
# Factors used for CW-M3, CCW-M3, CW-M4, CCW-M4, CW-M5 and CCW-M5
threads_factor = {0: 0.5, 1: 0.5, 2: 0.7, 3: 0.7, 4: 0.8, 5: 0.8}
+ screw_diff = []
# Process the read Z values and
for i, screw in enumerate(self.screws):
if i == 0:
@@ -71,6 +74,7 @@ class ScrewsTiltAdjust:
z = positions[i][2]
coord, name = screw
diff = z_base - z
+ screw_diff.append(abs(diff))
if abs(diff) < 0.001:
adjust = 0
else:
@@ -87,6 +91,10 @@ class ScrewsTiltAdjust:
"Adjust -> %s %02d:%02d" %
(name, coord[0], coord[1], z, sign,
abs(full_turns), abs(minutes)))
+ if self.max_diff and any((d > self.max_diff) for d in screw_diff):
+ raise self.gcode.error(
+ "bed level exceeds configured limits ({}mm)! " \
+ "Adjust screws and restart print.".format(self.max_diff))
def load_config(config):
return ScrewsTiltAdjust(config)
diff --git a/test/klippy/screws_tilt_adjust.test b/test/klippy/screws_tilt_adjust.test
index 2ad683fa..7ac538cf 100644
--- a/test/klippy/screws_tilt_adjust.test
+++ b/test/klippy/screws_tilt_adjust.test
@@ -5,3 +5,4 @@ DICTIONARY atmega2560.dict
# Simple script to test
G28
SCREWS_TILT_CALCULATE
+SCREWS_TILT_CALCULATE MAX_DEVIATION=0.01