Browse Source

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

Brian 7 years ago
parent
commit
88649b06a6
4 changed files with 12 additions and 33 deletions
  1. 4
    10
      Marlin/configuration_store.cpp
  2. 0
    8
      Marlin/ubl.cpp
  3. 6
    11
      Marlin/ubl.h
  4. 2
    4
      Marlin/ubl_G29.cpp

+ 4
- 10
Marlin/configuration_store.cpp View File

@@ -212,13 +212,7 @@ void MarlinSettings::postprocess() {
212 212
   #endif
213 213
 
214 214
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
215
-    set_z_fade_height(
216
-      //#if ENABLED(AUTO_BED_LEVELING_UBL)
217
-      //  ubl.state.g29_correction_fade_height
218
-      //#else
219
-        planner.z_fade_height
220
-      //#endif
221
-    );
215
+    set_z_fade_height(planner.z_fade_height);
222 216
   #endif
223 217
 
224 218
   #if HAS_BED_PROBE
@@ -1412,9 +1406,9 @@ void MarlinSettings::reset() {
1412 1406
       }
1413 1407
       CONFIG_ECHO_START;
1414 1408
       SERIAL_ECHOPAIR("  M420 S", ubl.state.active ? 1 : 0);
1415
-      //#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1416
-      //  SERIAL_ECHOPAIR(" Z", ubl.state.g29_correction_fade_height);
1417
-      //#endif
1409
+      #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1410
+        SERIAL_ECHOPAIR(" Z", planner.z_fade_height);
1411
+      #endif
1418 1412
       SERIAL_EOL;
1419 1413
 
1420 1414
       if (!forReplay) {

+ 0
- 8
Marlin/ubl.cpp View File

@@ -90,14 +90,6 @@
90 90
 
91 91
     if (sanity_check())
92 92
       SERIAL_PROTOCOLLNPGM("?In load_state() sanity_check() failed.\n");
93
-
94
-    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
95
-      const float recip = ubl.state.g29_correction_fade_height ? 1.0 / ubl.state.g29_correction_fade_height : 1.0;
96
-      if (ubl.state.g29_fade_height_multiplier != recip) {
97
-        ubl.state.g29_fade_height_multiplier = recip;
98
-        store_state();
99
-      }
100
-    #endif
101 93
   }
102 94
 
103 95
   void unified_bed_leveling::load_mesh(const int16_t m) {

+ 6
- 11
Marlin/ubl.h View File

@@ -30,6 +30,7 @@
30 30
   #include "Marlin.h"
31 31
   #include "math.h"
32 32
   #include "vector_3.h"
33
+  #include "planner.h"
33 34
 
34 35
   #define UBL_VERSION "1.00"
35 36
   #define UBL_OK false
@@ -97,15 +98,9 @@
97 98
           mesh_x_dist = MESH_X_DIST,
98 99
           mesh_y_dist = MESH_Y_DIST;
99 100
 
100
-    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
101
-      float g29_correction_fade_height = 10.0,
102
-            g29_fade_height_multiplier = 1.0 / 10.0; // It's cheaper to do a floating point multiply than divide,
103
-                                                     // so keep this value and its reciprocal.
104
-    #endif
105
-
106 101
     // If you change this struct, adjust TOTAL_STRUCT_SIZE
107 102
 
108
-    #define TOTAL_STRUCT_SIZE 40 // Total size of the above fields
103
+    #define TOTAL_STRUCT_SIZE 32 // Total size of the above fields
109 104
 
110 105
     // padding provides space to add state variables without
111 106
     // changing the location of data structures in the EEPROM.
@@ -309,21 +304,21 @@
309 304
        * This function sets the Z leveling fade factor based on the given Z height,
310 305
        * only re-calculating when necessary.
311 306
        *
312
-       *  Returns 1.0 if g29_correction_fade_height is 0.0.
307
+       *  Returns 1.0 if planner.z_fade_height is 0.0.
313 308
        *  Returns 0.0 if Z is past the specified 'Fade Height'.
314 309
        */
315 310
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
316 311
 
317 312
         static FORCE_INLINE float fade_scaling_factor_for_z(const float &lz) {
318
-          if (state.g29_correction_fade_height == 0.0) return 1.0;
313
+          if (planner.z_fade_height == 0.0) return 1.0;
319 314
 
320 315
           static float fade_scaling_factor = 1.0;
321 316
           const float rz = RAW_Z_POSITION(lz);
322 317
           if (last_specified_z != rz) {
323 318
             last_specified_z = rz;
324 319
             fade_scaling_factor =
325
-              rz < state.g29_correction_fade_height
326
-                ? 1.0 - (rz * state.g29_fade_height_multiplier)
320
+              rz < planner.z_fade_height
321
+                ? 1.0 - (rz * planner.inverse_z_fade_height)
327 322
                 : 0.0;
328 323
           }
329 324
           return fade_scaling_factor;

+ 2
- 4
Marlin/ubl_G29.cpp View File

@@ -30,7 +30,6 @@
30 30
   #include "Marlin.h"
31 31
   #include "hex_print_routines.h"
32 32
   #include "configuration_store.h"
33
-  #include "planner.h"
34 33
   #include "ultralcd.h"
35 34
 
36 35
   #include <math.h>
@@ -1068,8 +1067,7 @@
1068 1067
           SERIAL_PROTOCOLLNPGM("?Bed Level Correction Fade Height Not Plausible.\n");
1069 1068
           return UBL_ERR;
1070 1069
         }
1071
-        ubl.state.g29_correction_fade_height = fh;
1072
-        ubl.state.g29_fade_height_multiplier = 1.0 / fh;
1070
+        set_z_fade_height(fh);
1073 1071
       }
1074 1072
     #endif
1075 1073
 
@@ -1166,7 +1164,7 @@
1166 1164
     safe_delay(50);
1167 1165
 
1168 1166
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1169
-      SERIAL_PROTOCOLLNPAIR("g29_correction_fade_height : ", ubl.state.g29_correction_fade_height);
1167
+      SERIAL_PROTOCOLLNPAIR("planner.z_fade_height : ", planner.z_fade_height);
1170 1168
     #endif
1171 1169
 
1172 1170
     SERIAL_PROTOCOLPGM("z_offset: ");

Loading…
Cancel
Save