Browse Source

Ensure fade factor is recalculated if fade height changes

Scott Lahteine 7 years ago
parent
commit
32c607ffe2
2 changed files with 8 additions and 1 deletions
  1. 1
    0
      Marlin/src/feature/bedlevel/bedlevel.cpp
  2. 7
    1
      Marlin/src/module/planner.h

+ 1
- 0
Marlin/src/feature/bedlevel/bedlevel.cpp View File

139
 
139
 
140
     planner.z_fade_height = zfh;
140
     planner.z_fade_height = zfh;
141
     planner.inverse_z_fade_height = RECIPROCAL(zfh);
141
     planner.inverse_z_fade_height = RECIPROCAL(zfh);
142
+    planner.force_fade_recalc();
142
 
143
 
143
     if (level_active) {
144
     if (level_active) {
144
       #if ENABLED(AUTO_BED_LEVELING_UBL)
145
       #if ENABLED(AUTO_BED_LEVELING_UBL)

+ 7
- 1
Marlin/src/module/planner.h View File

202
      */
202
      */
203
     static uint32_t cutoff_long;
203
     static uint32_t cutoff_long;
204
 
204
 
205
+    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
206
+      static float last_raw_lz;
207
+    #endif
208
+
205
     #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
209
     #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
206
       /**
210
       /**
207
        * Counters to manage disabling inactive extruders
211
        * Counters to manage disabling inactive extruders
273
        *  Returns 0.0 if Z is past the specified 'Fade Height'.
277
        *  Returns 0.0 if Z is past the specified 'Fade Height'.
274
        */
278
        */
275
       inline static float fade_scaling_factor_for_z(const float &lz) {
279
       inline static float fade_scaling_factor_for_z(const float &lz) {
276
-        static float z_fade_factor = 1.0, last_raw_lz = -999.0;
280
+        static float z_fade_factor = 1.0;
277
         if (z_fade_height) {
281
         if (z_fade_height) {
278
           const float raw_lz = RAW_Z_POSITION(lz);
282
           const float raw_lz = RAW_Z_POSITION(lz);
279
           if (raw_lz >= z_fade_height) return 0.0;
283
           if (raw_lz >= z_fade_height) return 0.0;
286
         return 1.0;
290
         return 1.0;
287
       }
291
       }
288
 
292
 
293
+      FORCE_INLINE static void force_fade_recalc() { last_raw_lz = -999.999; }
294
+
289
     #else
295
     #else
290
 
296
 
291
       FORCE_INLINE static float fade_scaling_factor_for_z(const float &lz) {
297
       FORCE_INLINE static float fade_scaling_factor_for_z(const float &lz) {

Loading…
Cancel
Save