From da08e11acd82c6db4168da352baf202c5b1341b2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 4 May 2017 00:19:07 -0500 Subject: [PATCH] Add EXTRAPOLATE_BEYOND_GRID option to bilinear leveling --- Marlin/Configuration.h | 4 +++ Marlin/Marlin_main.cpp | 26 ++++++++++++++++--- .../Cartesio/Configuration.h | 4 +++ .../Felix/Configuration.h | 4 +++ .../Felix/DUAL/Configuration.h | 4 +++ .../FolgerTech-i3-2020/Configuration.h | 4 +++ .../Hephestos/Configuration.h | 4 +++ .../Hephestos_2/Configuration.h | 4 +++ .../K8200/Configuration.h | 4 +++ .../K8400/Configuration.h | 4 +++ .../K8400/Dual-head/Configuration.h | 4 +++ .../RepRapWorld/Megatronics/Configuration.h | 4 +++ .../RigidBot/Configuration.h | 4 +++ .../SCARA/Configuration.h | 4 +++ .../TAZ4/Configuration.h | 4 +++ .../TinyBoy2/Configuration.h | 4 +++ .../WITBOX/Configuration.h | 4 +++ .../adafruit/ST7565/Configuration.h | 4 +++ .../FLSUN/auto_calibrate/Configuration.h | 4 +++ .../delta/kossel_mini/Configuration.h | 4 +++ .../delta/kossel_pro/Configuration.h | 4 +++ .../gCreate_gMax1.5+/Configuration.h | 4 +++ .../makibox/Configuration.h | 4 +++ .../tvrrug/Round2/Configuration.h | 4 +++ .../wt150/Configuration.h | 4 +++ 25 files changed, 118 insertions(+), 4 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 0bd552262..478bb9a1e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -825,6 +825,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index fcf92c677..e318052a7 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -10592,12 +10592,25 @@ void ok_to_send() { const float x = RAW_X_POSITION(logical[X_AXIS]) - bilinear_start[X_AXIS], y = RAW_Y_POSITION(logical[Y_AXIS]) - bilinear_start[Y_AXIS]; + #if ENABLED(EXTRAPOLATE_BEYOND_GRID) + // Keep using the last grid box + #define FAR_EDGE_OR_BOX 2 + #else + // Just use the grid far edge + #define FAR_EDGE_OR_BOX 1 + #endif + if (last_x != x) { last_x = x; ratio_x = x * ABL_BG_FACTOR(X_AXIS); - const float gx = constrain(floor(ratio_x), 0, ABL_BG_POINTS_X - 1); + const float gx = constrain(floor(ratio_x), 0, ABL_BG_POINTS_X - FAR_EDGE_OR_BOX); ratio_x -= gx; // Subtract whole to get the ratio within the grid box - NOLESS(ratio_x, 0); // Never < 0.0. (> 1.0 is ok when nextx==gridx.) + + #if DISABLED(EXTRAPOLATE_BEYOND_GRID) + // Beyond the grid maintain height at grid edges + NOLESS(ratio_x, 0); // Never < 0.0. (> 1.0 is ok when nextx==gridx.) + #endif + gridx = gx; nextx = min(gridx + 1, ABL_BG_POINTS_X - 1); } @@ -10607,9 +10620,14 @@ void ok_to_send() { if (last_y != y) { last_y = y; ratio_y = y * ABL_BG_FACTOR(Y_AXIS); - const float gy = constrain(floor(ratio_y), 0, ABL_BG_POINTS_Y - 1); + const float gy = constrain(floor(ratio_y), 0, ABL_BG_POINTS_Y - FAR_EDGE_OR_BOX); ratio_y -= gy; - NOLESS(ratio_y, 0); + + #if DISABLED(EXTRAPOLATE_BEYOND_GRID) + // Beyond the grid maintain height at grid edges + NOLESS(ratio_y, 0); // Never < 0.0. (> 1.0 is ok when nexty==gridy.) + #endif + gridy = gy; nexty = min(gridy + 1, ABL_BG_POINTS_Y - 1); } diff --git a/Marlin/example_configurations/Cartesio/Configuration.h b/Marlin/example_configurations/Cartesio/Configuration.h index 15d9db90f..1c363e529 100644 --- a/Marlin/example_configurations/Cartesio/Configuration.h +++ b/Marlin/example_configurations/Cartesio/Configuration.h @@ -823,6 +823,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index d65dfb078..477063b4f 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -807,6 +807,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/Felix/DUAL/Configuration.h b/Marlin/example_configurations/Felix/DUAL/Configuration.h index a0721fe19..f3d60d472 100644 --- a/Marlin/example_configurations/Felix/DUAL/Configuration.h +++ b/Marlin/example_configurations/Felix/DUAL/Configuration.h @@ -807,6 +807,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/FolgerTech-i3-2020/Configuration.h b/Marlin/example_configurations/FolgerTech-i3-2020/Configuration.h index 7eb0f214c..e467d3eed 100644 --- a/Marlin/example_configurations/FolgerTech-i3-2020/Configuration.h +++ b/Marlin/example_configurations/FolgerTech-i3-2020/Configuration.h @@ -827,6 +827,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 3f503db69..ceee2afdf 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -815,6 +815,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/Hephestos_2/Configuration.h b/Marlin/example_configurations/Hephestos_2/Configuration.h index 4ac164b0c..9ca6416e4 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration.h @@ -818,6 +818,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index 8bc6e04da..1f4964895 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -853,6 +853,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/K8400/Configuration.h b/Marlin/example_configurations/K8400/Configuration.h index 0b07f8d27..6705dc9fd 100644 --- a/Marlin/example_configurations/K8400/Configuration.h +++ b/Marlin/example_configurations/K8400/Configuration.h @@ -824,6 +824,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/K8400/Dual-head/Configuration.h b/Marlin/example_configurations/K8400/Dual-head/Configuration.h index 4d8df13fa..dd0ab0e12 100644 --- a/Marlin/example_configurations/K8400/Dual-head/Configuration.h +++ b/Marlin/example_configurations/K8400/Dual-head/Configuration.h @@ -824,6 +824,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h index 783508ec5..aff721065 100644 --- a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h +++ b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h @@ -824,6 +824,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/RigidBot/Configuration.h b/Marlin/example_configurations/RigidBot/Configuration.h index f4b73b1c8..d90db6f6e 100644 --- a/Marlin/example_configurations/RigidBot/Configuration.h +++ b/Marlin/example_configurations/RigidBot/Configuration.h @@ -823,6 +823,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 79c2670ec..55d991b20 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -839,6 +839,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/TAZ4/Configuration.h b/Marlin/example_configurations/TAZ4/Configuration.h index ea4d534fb..83c7a1873 100644 --- a/Marlin/example_configurations/TAZ4/Configuration.h +++ b/Marlin/example_configurations/TAZ4/Configuration.h @@ -844,6 +844,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/TinyBoy2/Configuration.h b/Marlin/example_configurations/TinyBoy2/Configuration.h index 57e038c03..966ec447f 100644 --- a/Marlin/example_configurations/TinyBoy2/Configuration.h +++ b/Marlin/example_configurations/TinyBoy2/Configuration.h @@ -880,6 +880,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index 1ebd9ecbc..5143d7bd7 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -815,6 +815,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/adafruit/ST7565/Configuration.h b/Marlin/example_configurations/adafruit/ST7565/Configuration.h index 2188ffe85..1874b12d3 100644 --- a/Marlin/example_configurations/adafruit/ST7565/Configuration.h +++ b/Marlin/example_configurations/adafruit/ST7565/Configuration.h @@ -824,6 +824,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h index 1439a40cd..e7a7fd20b 100644 --- a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h +++ b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h @@ -943,6 +943,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index 1e3d3ed43..7d6754fc4 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -935,6 +935,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index 91897cdfb..244976604 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -941,6 +941,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/gCreate_gMax1.5+/Configuration.h b/Marlin/example_configurations/gCreate_gMax1.5+/Configuration.h index bb97cdaad..a841fb604 100644 --- a/Marlin/example_configurations/gCreate_gMax1.5+/Configuration.h +++ b/Marlin/example_configurations/gCreate_gMax1.5+/Configuration.h @@ -809,6 +809,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index 8d023dacb..1a4d79019 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -827,6 +827,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index ad1aadaf2..0caad869f 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -820,6 +820,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. diff --git a/Marlin/example_configurations/wt150/Configuration.h b/Marlin/example_configurations/wt150/Configuration.h index bfb749719..dde673fc9 100644 --- a/Marlin/example_configurations/wt150/Configuration.h +++ b/Marlin/example_configurations/wt150/Configuration.h @@ -829,6 +829,10 @@ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Beyond the probed grid, continue the implied tilt? + // Default is to maintain the height of the nearest edge. + //#define EXTRAPOLATE_BEYOND_GRID + // // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh.