From 88649b06a68a55450c08524be2356af8c8c4b3ab Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 20 Apr 2017 18:45:58 -0400 Subject: [PATCH] use planner.z_fade_height, etc. instead of private, ubl-specific g29 fade height --- Marlin/configuration_store.cpp | 14 ++++---------- Marlin/ubl.cpp | 8 -------- Marlin/ubl.h | 17 ++++++----------- Marlin/ubl_G29.cpp | 6 ++---- 4 files changed, 12 insertions(+), 33 deletions(-) mode change 100644 => 100755 Marlin/configuration_store.cpp mode change 100644 => 100755 Marlin/ubl.cpp mode change 100644 => 100755 Marlin/ubl.h mode change 100644 => 100755 Marlin/ubl_G29.cpp diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp old mode 100644 new mode 100755 index fb82f23704..829cb782e7 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -212,13 +212,7 @@ void MarlinSettings::postprocess() { #endif #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - set_z_fade_height( - //#if ENABLED(AUTO_BED_LEVELING_UBL) - // ubl.state.g29_correction_fade_height - //#else - planner.z_fade_height - //#endif - ); + set_z_fade_height(planner.z_fade_height); #endif #if HAS_BED_PROBE @@ -1412,9 +1406,9 @@ void MarlinSettings::reset() { } CONFIG_ECHO_START; SERIAL_ECHOPAIR(" M420 S", ubl.state.active ? 1 : 0); - //#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - // SERIAL_ECHOPAIR(" Z", ubl.state.g29_correction_fade_height); - //#endif + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + SERIAL_ECHOPAIR(" Z", planner.z_fade_height); + #endif SERIAL_EOL; if (!forReplay) { diff --git a/Marlin/ubl.cpp b/Marlin/ubl.cpp old mode 100644 new mode 100755 index 056632d24d..06ef9c6838 --- a/Marlin/ubl.cpp +++ b/Marlin/ubl.cpp @@ -90,14 +90,6 @@ if (sanity_check()) SERIAL_PROTOCOLLNPGM("?In load_state() sanity_check() failed.\n"); - - #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - const float recip = ubl.state.g29_correction_fade_height ? 1.0 / ubl.state.g29_correction_fade_height : 1.0; - if (ubl.state.g29_fade_height_multiplier != recip) { - ubl.state.g29_fade_height_multiplier = recip; - store_state(); - } - #endif } void unified_bed_leveling::load_mesh(const int16_t m) { diff --git a/Marlin/ubl.h b/Marlin/ubl.h old mode 100644 new mode 100755 index b64668280e..b168b896c6 --- a/Marlin/ubl.h +++ b/Marlin/ubl.h @@ -30,6 +30,7 @@ #include "Marlin.h" #include "math.h" #include "vector_3.h" + #include "planner.h" #define UBL_VERSION "1.00" #define UBL_OK false @@ -97,15 +98,9 @@ mesh_x_dist = MESH_X_DIST, mesh_y_dist = MESH_Y_DIST; - #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - float g29_correction_fade_height = 10.0, - g29_fade_height_multiplier = 1.0 / 10.0; // It's cheaper to do a floating point multiply than divide, - // so keep this value and its reciprocal. - #endif - // If you change this struct, adjust TOTAL_STRUCT_SIZE - #define TOTAL_STRUCT_SIZE 40 // Total size of the above fields + #define TOTAL_STRUCT_SIZE 32 // Total size of the above fields // padding provides space to add state variables without // changing the location of data structures in the EEPROM. @@ -309,21 +304,21 @@ * This function sets the Z leveling fade factor based on the given Z height, * only re-calculating when necessary. * - * Returns 1.0 if g29_correction_fade_height is 0.0. + * Returns 1.0 if planner.z_fade_height is 0.0. * Returns 0.0 if Z is past the specified 'Fade Height'. */ #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) static FORCE_INLINE float fade_scaling_factor_for_z(const float &lz) { - if (state.g29_correction_fade_height == 0.0) return 1.0; + if (planner.z_fade_height == 0.0) return 1.0; static float fade_scaling_factor = 1.0; const float rz = RAW_Z_POSITION(lz); if (last_specified_z != rz) { last_specified_z = rz; fade_scaling_factor = - rz < state.g29_correction_fade_height - ? 1.0 - (rz * state.g29_fade_height_multiplier) + rz < planner.z_fade_height + ? 1.0 - (rz * planner.inverse_z_fade_height) : 0.0; } return fade_scaling_factor; diff --git a/Marlin/ubl_G29.cpp b/Marlin/ubl_G29.cpp old mode 100644 new mode 100755 index 6c4fcd23a7..8d7f3dd82a --- a/Marlin/ubl_G29.cpp +++ b/Marlin/ubl_G29.cpp @@ -30,7 +30,6 @@ #include "Marlin.h" #include "hex_print_routines.h" #include "configuration_store.h" - #include "planner.h" #include "ultralcd.h" #include @@ -1068,8 +1067,7 @@ SERIAL_PROTOCOLLNPGM("?Bed Level Correction Fade Height Not Plausible.\n"); return UBL_ERR; } - ubl.state.g29_correction_fade_height = fh; - ubl.state.g29_fade_height_multiplier = 1.0 / fh; + set_z_fade_height(fh); } #endif @@ -1166,7 +1164,7 @@ safe_delay(50); #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - SERIAL_PROTOCOLLNPAIR("g29_correction_fade_height : ", ubl.state.g29_correction_fade_height); + SERIAL_PROTOCOLLNPAIR("planner.z_fade_height : ", planner.z_fade_height); #endif SERIAL_PROTOCOLPGM("z_offset: ");