|
|
@ -98,9 +98,6 @@
|
|
|
|
float g29_correction_fade_height = 10.0,
|
|
|
|
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,
|
|
|
|
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.
|
|
|
|
// so keep this value and its reciprocal.
|
|
|
|
#else
|
|
|
|
|
|
|
|
const float g29_correction_fade_height = 10.0,
|
|
|
|
|
|
|
|
g29_fade_height_multiplier = 1.0 / 10.0;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// If you change this struct, adjust TOTAL_STRUCT_SIZE
|
|
|
|
// If you change this struct, adjust TOTAL_STRUCT_SIZE
|
|
|
@ -118,8 +115,7 @@
|
|
|
|
class unified_bed_leveling {
|
|
|
|
class unified_bed_leveling {
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
static float last_specified_z,
|
|
|
|
static float last_specified_z;
|
|
|
|
fade_scaling_factor_for_current_height;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
@ -307,32 +303,29 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* This routine is used to scale the Z correction depending upon the current nozzle height. It is
|
|
|
|
* This function sets the Z leveling fade factor based on the given Z height,
|
|
|
|
* optimized for speed. It avoids floating point operations by checking if the requested scaling
|
|
|
|
* only re-calculating when necessary.
|
|
|
|
* factor is going to be the same as the last time the function calculated a value. If so, it just
|
|
|
|
|
|
|
|
* returns it.
|
|
|
|
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* It returns a scaling factor of 1.0 if UBL is inactive.
|
|
|
|
* Returns 1.0 if g29_correction_fade_height is 0.0.
|
|
|
|
* It returns a scaling factor of 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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_for_current_height =
|
|
|
|
fade_scaling_factor =
|
|
|
|
state.active && rz < state.g29_correction_fade_height
|
|
|
|
rz < state.g29_correction_fade_height
|
|
|
|
? 1.0 - (rz * state.g29_fade_height_multiplier)
|
|
|
|
? 1.0 - (rz * state.g29_fade_height_multiplier)
|
|
|
|
: 0.0;
|
|
|
|
: 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fade_scaling_factor_for_current_height;
|
|
|
|
return fade_scaling_factor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static constexpr float fade_scaling_factor_for_z(const float &lz) { UNUSED(lz); return 1.0; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
}; // class unified_bed_leveling
|
|
|
|
}; // class unified_bed_leveling
|
|
|
|