|
@@ -98,9 +98,6 @@
|
98
|
98
|
float g29_correction_fade_height = 10.0,
|
99
|
99
|
g29_fade_height_multiplier = 1.0 / 10.0; // It's cheaper to do a floating point multiply than divide,
|
100
|
100
|
// so keep this value and its reciprocal.
|
101
|
|
- #else
|
102
|
|
- const float g29_correction_fade_height = 10.0,
|
103
|
|
- g29_fade_height_multiplier = 1.0 / 10.0;
|
104
|
101
|
#endif
|
105
|
102
|
|
106
|
103
|
// If you change this struct, adjust TOTAL_STRUCT_SIZE
|
|
@@ -118,8 +115,7 @@
|
118
|
115
|
class unified_bed_leveling {
|
119
|
116
|
private:
|
120
|
117
|
|
121
|
|
- static float last_specified_z,
|
122
|
|
- fade_scaling_factor_for_current_height;
|
|
118
|
+ static float last_specified_z;
|
123
|
119
|
|
124
|
120
|
public:
|
125
|
121
|
|
|
@@ -307,32 +303,29 @@
|
307
|
303
|
}
|
308
|
304
|
|
309
|
305
|
/**
|
310
|
|
- * This routine is used to scale the Z correction depending upon the current nozzle height. It is
|
311
|
|
- * optimized for speed. It avoids floating point operations by checking if the requested scaling
|
312
|
|
- * factor is going to be the same as the last time the function calculated a value. If so, it just
|
313
|
|
- * returns it.
|
|
306
|
+ * This function sets the Z leveling fade factor based on the given Z height,
|
|
307
|
+ * only re-calculating when necessary.
|
314
|
308
|
*
|
315
|
|
- * It returns a scaling factor of 1.0 if UBL is inactive.
|
316
|
|
- * It returns a scaling factor of 0.0 if Z is past the specified 'Fade Height'
|
|
309
|
+ * Returns 1.0 if g29_correction_fade_height is 0.0.
|
|
310
|
+ * Returns 0.0 if Z is past the specified 'Fade Height'.
|
317
|
311
|
*/
|
318
|
312
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
319
|
313
|
|
320
|
314
|
static FORCE_INLINE float fade_scaling_factor_for_z(const float &lz) {
|
|
315
|
+ if (state.g29_correction_fade_height == 0.0) return 1.0;
|
|
316
|
+
|
|
317
|
+ static float fade_scaling_factor = 1.0;
|
321
|
318
|
const float rz = RAW_Z_POSITION(lz);
|
322
|
319
|
if (last_specified_z != rz) {
|
323
|
320
|
last_specified_z = rz;
|
324
|
|
- fade_scaling_factor_for_current_height =
|
325
|
|
- state.active && rz < state.g29_correction_fade_height
|
|
321
|
+ fade_scaling_factor =
|
|
322
|
+ rz < state.g29_correction_fade_height
|
326
|
323
|
? 1.0 - (rz * state.g29_fade_height_multiplier)
|
327
|
324
|
: 0.0;
|
328
|
325
|
}
|
329
|
|
- return fade_scaling_factor_for_current_height;
|
|
326
|
+ return fade_scaling_factor;
|
330
|
327
|
}
|
331
|
328
|
|
332
|
|
- #else
|
333
|
|
-
|
334
|
|
- static constexpr float fade_scaling_factor_for_z(const float &lz) { UNUSED(lz); return 1.0; }
|
335
|
|
-
|
336
|
329
|
#endif
|
337
|
330
|
|
338
|
331
|
}; // class unified_bed_leveling
|