From f6f77d34a1712c308d260e8436109ea4995d8122 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Nov 2016 23:32:47 -0600 Subject: [PATCH] Add a fade factor for mesh leveling --- Marlin/Configuration.h | 12 +++++ Marlin/Marlin_main.cpp | 36 ++++++++++++++- .../Cartesio/Configuration.h | 12 +++++ .../Felix/Configuration.h | 12 +++++ .../Felix/DUAL/Configuration.h | 12 +++++ .../Hephestos/Configuration.h | 12 +++++ .../Hephestos_2/Configuration.h | 12 +++++ .../K8200/Configuration.h | 12 +++++ .../K8400/Configuration.h | 12 +++++ .../K8400/Dual-head/Configuration.h | 12 +++++ .../RepRapWorld/Megatronics/Configuration.h | 12 +++++ .../RigidBot/Configuration.h | 12 +++++ .../SCARA/Configuration.h | 12 +++++ .../TAZ4/Configuration.h | 12 +++++ .../WITBOX/Configuration.h | 12 +++++ .../adafruit/ST7565/Configuration.h | 12 +++++ .../delta/biv2.5/Configuration.h | 12 +++++ .../delta/generic/Configuration.h | 12 +++++ .../delta/kossel_mini/Configuration.h | 12 +++++ .../delta/kossel_pro/Configuration.h | 12 +++++ .../delta/kossel_xl/Configuration.h | 12 +++++ .../makibox/Configuration.h | 12 +++++ .../tvrrug/Round2/Configuration.h | 12 +++++ Marlin/planner.cpp | 44 ++++++++++++++++--- Marlin/planner.h | 12 +++-- 25 files changed, 345 insertions(+), 11 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 382247479..b70b57dbb 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -745,6 +745,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -802,6 +807,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index ef17e7159..ad5a1a803 100755 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2270,6 +2270,30 @@ static void clean_up_after_endstop_or_probe_move() { #endif } + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + + void set_z_fade_height(const float zfh) { + planner.z_fade_height = zfh; + planner.inverse_z_fade_height = RECIPROCAL(zfh); + + if ( + #if ENABLED(MESH_BED_LEVELING) + mbl.active() + #else + planner.abl_enabled + #endif + ) { + set_current_from_steppers_for_axis( + #if ABL_PLANAR + ALL_AXES + #else + Z_AXIS + #endif + ); + } + } + + #endif // LEVELING_FADE_HEIGHT /** * Reset calibration results to zero. @@ -6788,9 +6812,17 @@ void quickstop_stepper() { #if PLANNER_LEVELING /** - * M420: Enable/Disable Bed Leveling + * M420: Enable/Disable Bed Leveling and/or set the Z fade height. + * + * S[bool] Turns leveling on or off + * Z[height] Sets the Z fade height (0 or none to disable) */ - inline void gcode_M420() { if (code_seen('S')) set_bed_leveling_enabled(code_value_bool()); } + inline void gcode_M420() { + if (code_seen('S')) set_bed_leveling_enabled(code_value_bool()); + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + if (code_seen('Z')) set_z_fade_height(code_value_linear_units()); + #endif + } #endif #if ENABLED(MESH_BED_LEVELING) diff --git a/Marlin/example_configurations/Cartesio/Configuration.h b/Marlin/example_configurations/Cartesio/Configuration.h index beff3e661..e34be9f4a 100644 --- a/Marlin/example_configurations/Cartesio/Configuration.h +++ b/Marlin/example_configurations/Cartesio/Configuration.h @@ -745,6 +745,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -802,6 +807,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index a7901df4a..923cd3a41 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -728,6 +728,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -785,6 +790,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/Felix/DUAL/Configuration.h b/Marlin/example_configurations/Felix/DUAL/Configuration.h index 47942e610..0a202134f 100644 --- a/Marlin/example_configurations/Felix/DUAL/Configuration.h +++ b/Marlin/example_configurations/Felix/DUAL/Configuration.h @@ -728,6 +728,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -785,6 +790,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 6499466eb..cae5d1e01 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -737,6 +737,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -794,6 +799,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/Hephestos_2/Configuration.h b/Marlin/example_configurations/Hephestos_2/Configuration.h index 0349dd1e4..64f39a2f0 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration.h @@ -739,6 +739,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -796,6 +801,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index ee2c7e144..a76ad5ea9 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -774,6 +774,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -831,6 +836,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/K8400/Configuration.h b/Marlin/example_configurations/K8400/Configuration.h index c3096703e..ab24c1b03 100644 --- a/Marlin/example_configurations/K8400/Configuration.h +++ b/Marlin/example_configurations/K8400/Configuration.h @@ -745,6 +745,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -802,6 +807,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/K8400/Dual-head/Configuration.h b/Marlin/example_configurations/K8400/Dual-head/Configuration.h index b3b75ba4c..ca4cff7cb 100644 --- a/Marlin/example_configurations/K8400/Dual-head/Configuration.h +++ b/Marlin/example_configurations/K8400/Dual-head/Configuration.h @@ -745,6 +745,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -802,6 +807,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h index 6ea7806a1..726aff69c 100644 --- a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h +++ b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h @@ -745,6 +745,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -802,6 +807,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/RigidBot/Configuration.h b/Marlin/example_configurations/RigidBot/Configuration.h index cda18275a..54e9d86db 100644 --- a/Marlin/example_configurations/RigidBot/Configuration.h +++ b/Marlin/example_configurations/RigidBot/Configuration.h @@ -743,6 +743,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -800,6 +805,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 193c9ef1a..2ef277244 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -760,6 +760,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -817,6 +822,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/TAZ4/Configuration.h b/Marlin/example_configurations/TAZ4/Configuration.h index e963f2cde..be7d9d25f 100644 --- a/Marlin/example_configurations/TAZ4/Configuration.h +++ b/Marlin/example_configurations/TAZ4/Configuration.h @@ -766,6 +766,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -823,6 +828,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index 598b7535a..b1cba78d8 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -737,6 +737,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -794,6 +799,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/adafruit/ST7565/Configuration.h b/Marlin/example_configurations/adafruit/ST7565/Configuration.h index e2c048905..837b6c268 100644 --- a/Marlin/example_configurations/adafruit/ST7565/Configuration.h +++ b/Marlin/example_configurations/adafruit/ST7565/Configuration.h @@ -745,6 +745,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -802,6 +807,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration.h b/Marlin/example_configurations/delta/biv2.5/Configuration.h index 5ea14c181..cd16f383c 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration.h @@ -840,6 +840,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -899,6 +904,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index ce8cbefa4..3ace6e84c 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -834,6 +834,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -893,6 +898,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index af6ef53bf..a39855417 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -837,6 +837,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -896,6 +901,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index 0bfcacd94..e66863fba 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -836,6 +836,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -895,6 +900,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration.h b/Marlin/example_configurations/delta/kossel_xl/Configuration.h index d17455561..076a08515 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration.h @@ -840,6 +840,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -899,6 +904,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index da27397ca..4364fdfa4 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -748,6 +748,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -805,6 +810,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 47f5ec658..ec57e3034 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -741,6 +741,11 @@ #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. #endif // MANUAL_BED_LEVELING + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif // MESH_BED_LEVELING //=========================================================================== @@ -798,6 +803,13 @@ // Probe along the Y axis, advancing X after each column //#define PROBE_Y_FIRST + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Gradually reduce leveling correction until a set height is reached, + // at which point movement will be level to the machine's XY plane. + // The height can be set with M420 Z + #define ENABLE_LEVELING_FADE_HEIGHT + #endif + #elif ENABLED(AUTO_BED_LEVELING_3POINT) // 3 arbitrary points to probe. diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index c9d681e9b..14ca80c5c 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -104,6 +104,11 @@ float Planner::min_feedrate_mm_s, matrix_3x3 Planner::bed_level_matrix; // Transform to compensate for bed level #endif +#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + float Planner::z_fade_height = 0.0, + Planner::inverse_z_fade_height = 0.0; +#endif + #if ENABLED(AUTOTEMP) float Planner::autotemp_max = 250, Planner::autotemp_min = 210, @@ -531,10 +536,24 @@ void Planner::check_axes_activity() { if (!abl_enabled) return; #endif + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + static float z_fade_factor = 1.0, last_raw_lz = -999.0; + if (z_fade_height) { + const float raw_lz = RAW_Z_POSITION(lz); + if (raw_lz >= z_fade_height) return; + if (last_raw_lz != raw_lz) { + last_raw_lz = raw_lz; + z_fade_factor = 1.0 - raw_lz * inverse_z_fade_height; + } + } + else + z_fade_factor = 1.0; + #endif + #if ENABLED(MESH_BED_LEVELING) if (mbl.active()) - lz += mbl.get_z(RAW_X_POSITION(lx), RAW_Y_POSITION(ly)); + lz += mbl.get_z(RAW_X_POSITION(lx), RAW_Y_POSITION(ly)) * z_fade_factor; #elif ABL_PLANAR @@ -551,7 +570,7 @@ void Planner::check_axes_activity() { #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) float tmp[XYZ] = { lx, ly, 0 }; - lz += bilinear_z_offset(tmp); + lz += bilinear_z_offset(tmp) * z_fade_factor; #endif } @@ -562,10 +581,20 @@ void Planner::check_axes_activity() { if (!abl_enabled) return; #endif + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + if (z_fade_height && RAW_Z_POSITION(logical[Z_AXIS]) >= z_fade_height) return; + #endif + #if ENABLED(MESH_BED_LEVELING) - if (mbl.active()) - logical[Z_AXIS] -= mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS])); + if (mbl.active()) { + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + const float c = mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS])); + logical[Z_AXIS] = (z_fade_height * (RAW_Z_POSITION(logical[Z_AXIS]) - c)) / (z_fade_height - c); + #else + logical[Z_AXIS] -= mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS])); + #endif + } #elif ABL_PLANAR @@ -583,7 +612,12 @@ void Planner::check_axes_activity() { #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - logical[Z_AXIS] -= bilinear_z_offset(logical); + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + const float c = bilinear_z_offset(logical); + logical[Z_AXIS] = (z_fade_height * (RAW_Z_POSITION(logical[Z_AXIS]) - c)) / (z_fade_height - c); + #else + logical[Z_AXIS] -= bilinear_z_offset(logical); + #endif #endif } diff --git a/Marlin/planner.h b/Marlin/planner.h index 3121f1943..8bc96ad14 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -162,6 +162,10 @@ class Planner { static matrix_3x3 bed_level_matrix; // Transform to compensate for bed level #endif + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + static float z_fade_height, inverse_z_fade_height; + #endif + private: /** @@ -180,10 +184,10 @@ class Planner { */ static float previous_nominal_speed; - /** - * Limit where 64bit math is necessary for acceleration calculation - */ - static uint32_t cutoff_long; + /** + * Limit where 64bit math is necessary for acceleration calculation + */ + static uint32_t cutoff_long; #if ENABLED(DISABLE_INACTIVE_EXTRUDER) /**