From 1a75165f35f6466738590643bc2c9df8a68c8c52 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 29 Mar 2018 18:16:20 -0500 Subject: [PATCH] For set_z_fade_height use set_bed_leveling_enabled --- Marlin/src/feature/bedlevel/bedlevel.cpp | 24 +++++------------------- Marlin/src/gcode/calibrate/G28.cpp | 4 ++-- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index ec93172cd2..ea1284efc0 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -138,30 +138,16 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) { void set_z_fade_height(const float zfh, const bool do_report/*=true*/) { - if (planner.z_fade_height == zfh) return; // do nothing if no change + if (planner.z_fade_height == zfh) return; - const bool level_active = planner.leveling_active; - - #if ENABLED(AUTO_BED_LEVELING_UBL) - if (level_active) set_bed_leveling_enabled(false); // turn off before changing fade height for proper apply/unapply leveling to maintain current_position - #endif + const bool leveling_was_active = planner.leveling_active; + set_bed_leveling_enabled(false); planner.set_z_fade_height(zfh); - if (level_active) { + if (leveling_was_active) { const float oldpos[] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] }; - #if ENABLED(AUTO_BED_LEVELING_UBL) - set_bed_leveling_enabled(true); // turn back on after changing fade height - #else - set_current_from_steppers_for_axis( - #if ABL_PLANAR - ALL_AXES - #else - Z_AXIS - #endif - ); - SYNC_PLAN_POSITION_KINEMATIC(); - #endif + set_bed_leveling_enabled(true); if (do_report && memcmp(oldpos, current_position, sizeof(oldpos))) report_current_position(); } diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 221195c8f0..0416ad6d41 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -179,7 +179,7 @@ void GcodeSuite::G28(const bool always_home_all) { // Disable the leveling matrix before homing #if HAS_LEVELING #if ENABLED(RESTORE_LEVELING_AFTER_G28) - const bool leveling_state_at_entry = planner.leveling_active; + const bool leveling_was_active = planner.leveling_active; #endif set_bed_leveling_enabled(false); #endif @@ -326,7 +326,7 @@ void GcodeSuite::G28(const bool always_home_all) { #endif #if ENABLED(RESTORE_LEVELING_AFTER_G28) - set_bed_leveling_enabled(leveling_state_at_entry); + set_bed_leveling_enabled(leveling_was_active); #endif clean_up_after_endstop_or_probe_move();