Browse Source

Pass the fade factor to mbl.get_z

Scott Lahteine 8 years ago
parent
commit
84ff78c1e3
2 changed files with 13 additions and 4 deletions
  1. 11
    2
      Marlin/mesh_bed_leveling.h
  2. 2
    2
      Marlin/planner.cpp

+ 11
- 2
Marlin/mesh_bed_leveling.h View File

83
       return z1 + delta_a * delta_z;
83
       return z1 + delta_a * delta_z;
84
     }
84
     }
85
 
85
 
86
-    float get_z(float x0, float y0) {
86
+    float get_z(const float &x0, const float &y0
87
+      #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
88
+        , const float &factor
89
+      #endif
90
+    ) const {
87
       int8_t cx = cell_index_x(x0),
91
       int8_t cx = cell_index_x(x0),
88
              cy = cell_index_y(y0);
92
              cy = cell_index_y(y0);
89
       if (cx < 0 || cy < 0) return z_offset;
93
       if (cx < 0 || cy < 0) return z_offset;
96
       float z0 = calc_z0(y0,
100
       float z0 = calc_z0(y0,
97
                          get_probe_y(cy), z1,
101
                          get_probe_y(cy), z1,
98
                          get_probe_y(cy + 1), z2);
102
                          get_probe_y(cy + 1), z2);
99
-      return z0 + z_offset;
103
+
104
+      #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
105
+        return z0 * factor + z_offset;
106
+      #else
107
+        return z0 + z_offset;
108
+      #endif
100
     }
109
     }
101
   };
110
   };
102
 
111
 

+ 2
- 2
Marlin/planner.cpp View File

559
     #if ENABLED(MESH_BED_LEVELING)
559
     #if ENABLED(MESH_BED_LEVELING)
560
 
560
 
561
       if (mbl.active())
561
       if (mbl.active())
562
-        lz += mbl.get_z(RAW_X_POSITION(lx), RAW_Y_POSITION(ly)) * z_fade_factor;
562
+        lz += mbl.get_z(RAW_X_POSITION(lx), RAW_Y_POSITION(ly), z_fade_factor);
563
 
563
 
564
     #elif ABL_PLANAR
564
     #elif ABL_PLANAR
565
 
565
 
595
 
595
 
596
       if (mbl.active()) {
596
       if (mbl.active()) {
597
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
597
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
598
-          const float c = mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]));
598
+          const float c = mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]), 1.0);
599
           logical[Z_AXIS] = (z_fade_height * (RAW_Z_POSITION(logical[Z_AXIS]) - c)) / (z_fade_height - c);
599
           logical[Z_AXIS] = (z_fade_height * (RAW_Z_POSITION(logical[Z_AXIS]) - c)) / (z_fade_height - c);
600
         #else
600
         #else
601
           logical[Z_AXIS] -= mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]));
601
           logical[Z_AXIS] -= mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]));

Loading…
Cancel
Save