use planner.z_fade_height, etc. instead of private, ubl-specific g29 fade height

This commit is contained in:
Brian 2017-04-20 18:45:58 -04:00 committed by Roxy-3D
parent e66d9f1313
commit 88649b06a6
4 changed files with 12 additions and 33 deletions

14
Marlin/configuration_store.cpp Normal file → Executable file
View File

@ -212,13 +212,7 @@ void MarlinSettings::postprocess() {
#endif #endif
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
set_z_fade_height( set_z_fade_height(planner.z_fade_height);
//#if ENABLED(AUTO_BED_LEVELING_UBL)
// ubl.state.g29_correction_fade_height
//#else
planner.z_fade_height
//#endif
);
#endif #endif
#if HAS_BED_PROBE #if HAS_BED_PROBE
@ -1412,9 +1406,9 @@ void MarlinSettings::reset() {
} }
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" M420 S", ubl.state.active ? 1 : 0); SERIAL_ECHOPAIR(" M420 S", ubl.state.active ? 1 : 0);
//#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
// SERIAL_ECHOPAIR(" Z", ubl.state.g29_correction_fade_height); SERIAL_ECHOPAIR(" Z", planner.z_fade_height);
//#endif #endif
SERIAL_EOL; SERIAL_EOL;
if (!forReplay) { if (!forReplay) {

8
Marlin/ubl.cpp Normal file → Executable file
View File

@ -90,14 +90,6 @@
if (sanity_check()) if (sanity_check())
SERIAL_PROTOCOLLNPGM("?In load_state() sanity_check() failed.\n"); 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) { void unified_bed_leveling::load_mesh(const int16_t m) {

17
Marlin/ubl.h Normal file → Executable file
View File

@ -30,6 +30,7 @@
#include "Marlin.h" #include "Marlin.h"
#include "math.h" #include "math.h"
#include "vector_3.h" #include "vector_3.h"
#include "planner.h"
#define UBL_VERSION "1.00" #define UBL_VERSION "1.00"
#define UBL_OK false #define UBL_OK false
@ -97,15 +98,9 @@
mesh_x_dist = MESH_X_DIST, mesh_x_dist = MESH_X_DIST,
mesh_y_dist = MESH_Y_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 // 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 // padding provides space to add state variables without
// changing the location of data structures in the EEPROM. // 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, * This function sets the Z leveling fade factor based on the given Z height,
* only re-calculating when necessary. * 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'. * Returns 0.0 if Z is past the specified 'Fade Height'.
*/ */
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
static FORCE_INLINE float fade_scaling_factor_for_z(const float &lz) { 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; static float fade_scaling_factor = 1.0;
const float rz = RAW_Z_POSITION(lz); const float rz = RAW_Z_POSITION(lz);
if (last_specified_z != rz) { if (last_specified_z != rz) {
last_specified_z = rz; last_specified_z = rz;
fade_scaling_factor = fade_scaling_factor =
rz < state.g29_correction_fade_height rz < planner.z_fade_height
? 1.0 - (rz * state.g29_fade_height_multiplier) ? 1.0 - (rz * planner.inverse_z_fade_height)
: 0.0; : 0.0;
} }
return fade_scaling_factor; return fade_scaling_factor;

6
Marlin/ubl_G29.cpp Normal file → Executable file
View File

@ -30,7 +30,6 @@
#include "Marlin.h" #include "Marlin.h"
#include "hex_print_routines.h" #include "hex_print_routines.h"
#include "configuration_store.h" #include "configuration_store.h"
#include "planner.h"
#include "ultralcd.h" #include "ultralcd.h"
#include <math.h> #include <math.h>
@ -1068,8 +1067,7 @@
SERIAL_PROTOCOLLNPGM("?Bed Level Correction Fade Height Not Plausible.\n"); SERIAL_PROTOCOLLNPGM("?Bed Level Correction Fade Height Not Plausible.\n");
return UBL_ERR; return UBL_ERR;
} }
ubl.state.g29_correction_fade_height = fh; set_z_fade_height(fh);
ubl.state.g29_fade_height_multiplier = 1.0 / fh;
} }
#endif #endif
@ -1166,7 +1164,7 @@
safe_delay(50); safe_delay(50);
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) #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 #endif
SERIAL_PROTOCOLPGM("z_offset: "); SERIAL_PROTOCOLPGM("z_offset: ");