diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 382247479eb076838a038e6c09f9b1378ee56c87..b70b57dbbb28616f2e09ad093b6befd4cd546761 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<height> + #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<height> + #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 ef17e7159f022e472bc1aafabe2b4014a8e3f1ef..ad5a1a8038b442fac6c690ee30ed3cea09679d54 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 beff3e6616e81b7efda22e76c795f9c4f085ef43..e34be9f4a2713ab8177ae0b722a3d58307701a62 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<height> + #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<height> + #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 a7901df4abe42f302bd01b588e604b07f982bbd4..923cd3a41fecc6a4436340252f5cca270837993e 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<height> + #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<height> + #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 47942e610a37321b21d3784d4684edd2dab8d3a6..0a202134f1ba4c2cec716436bab6a6933e286bc6 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<height> + #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<height> + #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 6499466eb16cfe1731fcc617ec6879475993ced8..cae5d1e015468311c60269125c342c13bca9efa1 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<height> + #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<height> + #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 0349dd1e492a37d0913e9c5cb8e39e31734ffa3a..64f39a2f0ded5b2a75ba698424e528206c958c7a 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<height> + #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<height> + #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 ee2c7e1446aad0ceac12e7b20a7aff4431e2afa4..a76ad5ea9205df7130b5ace345b7972df90d416a 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<height> + #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<height> + #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 c3096703ee6de725465614782b2fb4fe74ce9466..ab24c1b03964b8859a3a735f89cfbcfcd4c2e5ec 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<height> + #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<height> + #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 b3b75ba4cfc079e01ddcd49bea26874db688cf9f..ca4cff7cbe0c37d9acebafcc44f8d2bf482aaadf 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<height> + #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<height> + #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 6ea7806a1cb46f1fad2ab8966a63b297349b9319..726aff69ccb8b9ca580846138adef769e6fc4227 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<height> + #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<height> + #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 cda18275a0e35aec85323cc70a7c5af743a5f3fb..54e9d86db5494303075e345495da07ce5b6dbcd8 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<height> + #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<height> + #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 193c9ef1aa8566a61239d1b6899360ec364e7d53..2ef2772447993620884428d9053462b73de80db9 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<height> + #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<height> + #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 e963f2cde6f579d667919eb29d2e8308e0bd2a9e..be7d9d25f98cca33bf6bd2acda2a624a1ceba20b 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<height> + #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<height> + #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 598b7535adac7949c3f6ae065d273589d2ad238f..b1cba78d8264f1c940e8c38c0f308f27511f7a55 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<height> + #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<height> + #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 e2c048905babb5dca82c09547abf85a9a5e3169a..837b6c26844d3090b41c262f9a4d0f337557eb10 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<height> + #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<height> + #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 5ea14c18114e4e0214de1ce50e33fa71fea1d3a6..cd16f383c3404f9f237895fac7243d68b16c8858 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<height> + #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<height> + #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 ce8cbefa46ed9958d48f5103f78174c49d1a7b9e..3ace6e84cad6a0fe9eb86b05765a9dc9f89523ae 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<height> + #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<height> + #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 af6ef53bfdd17cc4e13d21d44cb4d7bb01a348f5..a39855417c8317dc3ab01a1fb78d58cb02339b66 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<height> + #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<height> + #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 0bfcacd9402a73e53887f57f424e7558de83983b..e66863fba0e64db8eba360f16c44a847244073c8 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<height> + #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<height> + #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 d17455561288436a6655dd45063e215c3a0f6dd7..076a085156ccc390fc828d3e3e50bfb50254bff6 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<height> + #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<height> + #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 da27397ca77fa9b6f8805414035edbec5ff7873f..4364fdfa496aeae37268581435ab8e5cacbe15ae 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<height> + #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<height> + #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 47f5ec6587759f2ae6f6c408a38ae5be600df863..ec57e303489cac35da428b95102bf366f8d7d772 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<height> + #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<height> + #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 c9d681e9beb7b1a533d42cd0915e370f8d31f810..14ca80c5cdddfd9b5811565b7ade33f9191af226 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 3121f19431d471d870f7798084134b5966b0c3b2..8bc96ad14538b281462a8c6fce58a6338dca08e5 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) /**