Pārlūkot izejas kodu

Merge pull request #7966 from thinkyhead/bf2_ubl_remove_z_offset

[2.0.x] Unify Z fade factor
Scott Lahteine 7 gadus atpakaļ
vecāks
revīzija
85b2e7e764

+ 2
- 2
Marlin/src/core/utility.cpp Parādīt failu

@@ -333,7 +333,7 @@ void safe_delay(millis_t ms) {
333 333
       #elif ENABLED(AUTO_BED_LEVELING_UBL)
334 334
         SERIAL_ECHOPGM("UBL");
335 335
       #endif
336
-      if (leveling_is_active()) {
336
+      if (planner.leveling_active) {
337 337
         SERIAL_ECHOLNPGM(" (enabled)");
338 338
         #if ABL_PLANAR
339 339
           const float diff[XYZ] = {
@@ -364,7 +364,7 @@ void safe_delay(millis_t ms) {
364 364
     #elif ENABLED(MESH_BED_LEVELING)
365 365
 
366 366
       SERIAL_ECHOPGM("Mesh Bed Leveling");
367
-      if (leveling_is_active()) {
367
+      if (planner.leveling_active) {
368 368
         float lz = current_position[Z_AXIS];
369 369
         planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], lz);
370 370
         SERIAL_ECHOLNPGM(" (enabled)");

+ 19
- 36
Marlin/src/feature/bedlevel/bedlevel.cpp Parādīt failu

@@ -44,7 +44,7 @@
44 44
 bool leveling_is_valid() {
45 45
   return
46 46
     #if ENABLED(MESH_BED_LEVELING)
47
-      mbl.has_mesh()
47
+      mbl.has_mesh
48 48
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
49 49
       !!bilinear_grid_spacing[X_AXIS]
50 50
     #elif ENABLED(AUTO_BED_LEVELING_UBL)
@@ -55,18 +55,6 @@ bool leveling_is_valid() {
55 55
   ;
56 56
 }
57 57
 
58
-bool leveling_is_active() {
59
-  return
60
-    #if ENABLED(MESH_BED_LEVELING)
61
-      mbl.active()
62
-    #elif ENABLED(AUTO_BED_LEVELING_UBL)
63
-      ubl.state.active
64
-    #else // OLDSCHOOL_ABL
65
-      planner.abl_enabled
66
-    #endif
67
-  ;
68
-}
69
-
70 58
 /**
71 59
  * Turn bed leveling on or off, fixing the current
72 60
  * position as-needed.
@@ -82,7 +70,7 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
82 70
     constexpr bool can_change = true;
83 71
   #endif
84 72
 
85
-  if (can_change && enable != leveling_is_active()) {
73
+  if (can_change && enable != planner.leveling_active) {
86 74
 
87 75
     #if ENABLED(MESH_BED_LEVELING)
88 76
 
@@ -90,23 +78,23 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
90 78
         planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
91 79
 
92 80
       const bool enabling = enable && leveling_is_valid();
93
-      mbl.set_active(enabling);
81
+      planner.leveling_active = enabling;
94 82
       if (enabling) planner.unapply_leveling(current_position);
95 83
 
96 84
     #elif ENABLED(AUTO_BED_LEVELING_UBL)
97 85
       #if PLANNER_LEVELING
98
-        if (ubl.state.active) {                       // leveling from on to off
86
+        if (planner.leveling_active) {                   // leveling from on to off
99 87
           // change unleveled current_position to physical current_position without moving steppers.
100 88
           planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
101
-          ubl.state.active = false;                   // disable only AFTER calling apply_leveling
89
+          planner.leveling_active = false;                   // disable only AFTER calling apply_leveling
102 90
         }
103 91
         else {                                        // leveling from off to on
104
-          ubl.state.active = true;                    // enable BEFORE calling unapply_leveling, otherwise ignored
92
+          planner.leveling_active = true;                    // enable BEFORE calling unapply_leveling, otherwise ignored
105 93
           // change physical current_position to unleveled current_position without moving steppers.
106 94
           planner.unapply_leveling(current_position);
107 95
         }
108 96
       #else
109
-        ubl.state.active = enable;                    // just flip the bit, current_position will be wrong until next move.
97
+        planner.leveling_active = enable;                    // just flip the bit, current_position will be wrong until next move.
110 98
       #endif
111 99
 
112 100
     #else // OLDSCHOOL_ABL
@@ -118,7 +106,7 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
118 106
       #endif
119 107
 
120 108
       // Enable or disable leveling compensation in the planner
121
-      planner.abl_enabled = enable;
109
+      planner.leveling_active = enable;
122 110
 
123 111
       if (!enable)
124 112
         // When disabling just get the current position from the steppers.
@@ -143,23 +131,18 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
143 131
 
144 132
   void set_z_fade_height(const float zfh) {
145 133
 
146
-    const bool level_active = leveling_is_active();
134
+    const bool level_active = planner.leveling_active;
147 135
 
148 136
     #if ENABLED(AUTO_BED_LEVELING_UBL)
137
+      if (level_active) set_bed_leveling_enabled(false);  // turn off before changing fade height for proper apply/unapply leveling to maintain current_position
138
+    #endif
149 139
 
150
-      if (level_active)
151
-        set_bed_leveling_enabled(false);  // turn off before changing fade height for proper apply/unapply leveling to maintain current_position
152
-      planner.z_fade_height = zfh;
153
-      planner.inverse_z_fade_height = RECIPROCAL(zfh);
154
-      if (level_active)
155
-        set_bed_leveling_enabled(true);  // turn back on after changing fade height
156
-
157
-    #else
158
-
159
-      planner.z_fade_height = zfh;
160
-      planner.inverse_z_fade_height = RECIPROCAL(zfh);
140
+    planner.set_z_fade_height(zfh);
161 141
 
162
-      if (level_active) {
142
+    if (level_active) {
143
+      #if ENABLED(AUTO_BED_LEVELING_UBL)
144
+        set_bed_leveling_enabled(true);  // turn back on after changing fade height
145
+      #else
163 146
         set_current_from_steppers_for_axis(
164 147
           #if ABL_PLANAR
165 148
             ALL_AXES
@@ -167,8 +150,8 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
167 150
             Z_AXIS
168 151
           #endif
169 152
         );
170
-      }
171
-    #endif
153
+      #endif
154
+    }
172 155
   }
173 156
 
174 157
 #endif // ENABLE_LEVELING_FADE_HEIGHT
@@ -181,7 +164,7 @@ void reset_bed_level() {
181 164
   #if ENABLED(MESH_BED_LEVELING)
182 165
     if (leveling_is_valid()) {
183 166
       mbl.reset();
184
-      mbl.set_has_mesh(false);
167
+      mbl.has_mesh = false;
185 168
     }
186 169
   #else
187 170
     #if ENABLED(DEBUG_LEVELING_FEATURE)

+ 0
- 1
Marlin/src/feature/bedlevel/bedlevel.h Parādīt failu

@@ -40,7 +40,6 @@
40 40
 #endif
41 41
 
42 42
 bool leveling_is_valid();
43
-bool leveling_is_active();
44 43
 void set_bed_leveling_enabled(const bool enable=true);
45 44
 void reset_bed_level();
46 45
 

+ 2
- 2
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp Parādīt failu

@@ -31,7 +31,7 @@
31 31
 
32 32
   mesh_bed_leveling mbl;
33 33
 
34
-  uint8_t mesh_bed_leveling::status;
34
+  bool mesh_bed_leveling::has_mesh;
35 35
 
36 36
   float mesh_bed_leveling::z_offset,
37 37
         mesh_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
@@ -47,7 +47,7 @@
47 47
   }
48 48
 
49 49
   void mesh_bed_leveling::reset() {
50
-    status = MBL_STATUS_NONE;
50
+    has_mesh = false;
51 51
     z_offset = 0;
52 52
     ZERO(z_values);
53 53
   }

+ 1
- 12
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h Parādīt failu

@@ -34,18 +34,12 @@ enum MeshLevelingState {
34 34
   MeshReset
35 35
 };
36 36
 
37
-enum MBLStatus {
38
-  MBL_STATUS_NONE = 0,
39
-  MBL_STATUS_HAS_MESH_BIT = 0,
40
-  MBL_STATUS_ACTIVE_BIT = 1
41
-};
42
-
43 37
 #define MESH_X_DIST ((MESH_MAX_X - (MESH_MIN_X)) / (GRID_MAX_POINTS_X - 1))
44 38
 #define MESH_Y_DIST ((MESH_MAX_Y - (MESH_MIN_Y)) / (GRID_MAX_POINTS_Y - 1))
45 39
 
46 40
 class mesh_bed_leveling {
47 41
 public:
48
-  static uint8_t status; // Has Mesh and Is Active bits
42
+  static bool has_mesh;
49 43
   static float z_offset,
50 44
                z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
51 45
                index_to_xpos[GRID_MAX_POINTS_X],
@@ -57,11 +51,6 @@ public:
57 51
 
58 52
   static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
59 53
 
60
-  static bool active()                       { return TEST(status, MBL_STATUS_ACTIVE_BIT); }
61
-  static void set_active(const bool onOff)   { onOff ? SBI(status, MBL_STATUS_ACTIVE_BIT) : CBI(status, MBL_STATUS_ACTIVE_BIT); }
62
-  static bool has_mesh()                     { return TEST(status, MBL_STATUS_HAS_MESH_BIT); }
63
-  static void set_has_mesh(const bool onOff) { onOff ? SBI(status, MBL_STATUS_HAS_MESH_BIT) : CBI(status, MBL_STATUS_HAS_MESH_BIT); }
64
-
65 54
   static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) {
66 55
     px = index % (GRID_MAX_POINTS_X);
67 56
     py = index / (GRID_MAX_POINTS_X);

+ 5
- 7
Marlin/src/feature/bedlevel/ubl/ubl.cpp Parādīt failu

@@ -51,7 +51,7 @@
51 51
   void unified_bed_leveling::report_state() {
52 52
     echo_name();
53 53
     SERIAL_PROTOCOLPGM(" System v" UBL_VERSION " ");
54
-    if (!state.active) SERIAL_PROTOCOLPGM("in");
54
+    if (!planner.leveling_active) SERIAL_PROTOCOLPGM("in");
55 55
     SERIAL_PROTOCOLLNPGM("active.");
56 56
     safe_delay(50);
57 57
   }
@@ -65,10 +65,9 @@
65 65
     safe_delay(10);
66 66
   }
67 67
 
68
-  ubl_state unified_bed_leveling::state;
68
+  int8_t unified_bed_leveling::storage_slot;
69 69
 
70
-  float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
71
-        unified_bed_leveling::last_specified_z;
70
+  float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
72 71
 
73 72
   // 15 is the maximum nubmer of grid points supported + 1 safety margin for now,
74 73
   // until determinism prevails
@@ -91,12 +90,11 @@
91 90
 
92 91
   void unified_bed_leveling::reset() {
93 92
     set_bed_leveling_enabled(false);
94
-    state.storage_slot = -1;
93
+    storage_slot = -1;
95 94
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
96
-      planner.z_fade_height = 10.0;
95
+      planner.set_z_fade_height(10.0);
97 96
     #endif
98 97
     ZERO(z_values);
99
-    last_specified_z = -999.9;
100 98
   }
101 99
 
102 100
   void unified_bed_leveling::invalidate() {

+ 1
- 33
Marlin/src/feature/bedlevel/ubl/ubl.h Parādīt failu

@@ -70,16 +70,9 @@ extern uint8_t ubl_cnt;
70 70
 #define MESH_X_DIST (float(UBL_MESH_MAX_X - (UBL_MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
71 71
 #define MESH_Y_DIST (float(UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1))
72 72
 
73
-typedef struct {
74
-  bool active = false;
75
-  int8_t storage_slot = -1;
76
-} ubl_state;
77
-
78 73
 class unified_bed_leveling {
79 74
   private:
80 75
 
81
-    static float last_specified_z;
82
-
83 76
     static int    g29_verbose_level,
84 77
                   g29_phase_value,
85 78
                   g29_repetition_cnt,
@@ -161,7 +154,7 @@ class unified_bed_leveling {
161 154
       static void G26();
162 155
     #endif
163 156
 
164
-    static ubl_state state;
157
+    static int8_t storage_slot;
165 158
 
166 159
     static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
167 160
 
@@ -367,31 +360,6 @@ class unified_bed_leveling {
367 360
       return z0;
368 361
     }
369 362
 
370
-    /**
371
-     * This function sets the Z leveling fade factor based on the given Z height,
372
-     * only re-calculating when necessary.
373
-     *
374
-     *  Returns 1.0 if planner.z_fade_height is 0.0.
375
-     *  Returns 0.0 if Z is past the specified 'Fade Height'.
376
-     */
377
-    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
378
-      static inline float fade_scaling_factor_for_z(const float &lz) {
379
-        if (planner.z_fade_height == 0.0) return 1.0;
380
-        static float fade_scaling_factor = 1.0;
381
-        const float rz = RAW_Z_POSITION(lz);
382
-        if (last_specified_z != rz) {
383
-          last_specified_z = rz;
384
-          fade_scaling_factor =
385
-            rz < planner.z_fade_height
386
-              ? 1.0 - (rz * planner.inverse_z_fade_height)
387
-              : 0.0;
388
-        }
389
-        return fade_scaling_factor;
390
-      }
391
-    #else
392
-      FORCE_INLINE static float fade_scaling_factor_for_z(const float &lz) { return 1.0; }
393
-    #endif
394
-
395 363
     FORCE_INLINE static float mesh_index_to_xpos(const uint8_t i) {
396 364
       return i < GRID_MAX_POINTS_X ? pgm_read_float(&_mesh_index_to_xpos[i]) : UBL_MESH_MIN_X + i * (MESH_X_DIST);
397 365
     }

+ 9
- 9
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Parādīt failu

@@ -424,8 +424,8 @@
424 424
     #endif // HAS_BED_PROBE
425 425
 
426 426
     if (parser.seen('P')) {
427
-      if (WITHIN(g29_phase_value, 0, 1) && state.storage_slot == -1) {
428
-        state.storage_slot = 0;
427
+      if (WITHIN(g29_phase_value, 0, 1) && storage_slot == -1) {
428
+        storage_slot = 0;
429 429
         SERIAL_PROTOCOLLNPGM("Default storage slot 0 selected.");
430 430
       }
431 431
 
@@ -604,7 +604,7 @@
604 604
     //
605 605
 
606 606
     if (parser.seen('L')) {     // Load Current Mesh Data
607
-      g29_storage_slot = parser.has_value() ? parser.value_int() : state.storage_slot;
607
+      g29_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;
608 608
 
609 609
       int16_t a = settings.calc_num_meshes();
610 610
 
@@ -620,7 +620,7 @@
620 620
       }
621 621
 
622 622
       settings.load_mesh(g29_storage_slot);
623
-      state.storage_slot = g29_storage_slot;
623
+      storage_slot = g29_storage_slot;
624 624
 
625 625
       SERIAL_PROTOCOLLNPGM("Done.");
626 626
     }
@@ -630,7 +630,7 @@
630 630
     //
631 631
 
632 632
     if (parser.seen('S')) {     // Store (or Save) Current Mesh Data
633
-      g29_storage_slot = parser.has_value() ? parser.value_int() : state.storage_slot;
633
+      g29_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;
634 634
 
635 635
       if (g29_storage_slot == -1) {                     // Special case, we are going to 'Export' the mesh to the
636 636
         SERIAL_ECHOLNPGM("G29 I 999");              // host in a form it can be reconstructed on a different machine
@@ -662,7 +662,7 @@
662 662
       }
663 663
 
664 664
       settings.store_mesh(g29_storage_slot);
665
-      state.storage_slot = g29_storage_slot;
665
+      storage_slot = g29_storage_slot;
666 666
 
667 667
       SERIAL_PROTOCOLLNPGM("Done.");
668 668
     }
@@ -1170,7 +1170,7 @@
1170 1170
 
1171 1171
       return;
1172 1172
     }
1173
-    ubl_state_at_invocation = state.active;
1173
+    ubl_state_at_invocation = planner.leveling_active;
1174 1174
     set_bed_leveling_enabled(false);
1175 1175
   }
1176 1176
 
@@ -1195,10 +1195,10 @@
1195 1195
   void unified_bed_leveling::g29_what_command() {
1196 1196
     report_state();
1197 1197
 
1198
-    if (state.storage_slot == -1)
1198
+    if (storage_slot == -1)
1199 1199
       SERIAL_PROTOCOLPGM("No Mesh Loaded.");
1200 1200
     else {
1201
-      SERIAL_PROTOCOLPAIR("Mesh ", state.storage_slot);
1201
+      SERIAL_PROTOCOLPAIR("Mesh ", storage_slot);
1202 1202
       SERIAL_PROTOCOLPGM(" Loaded.");
1203 1203
     }
1204 1204
     SERIAL_EOL();

+ 12
- 24
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp Parādīt failu

@@ -173,7 +173,7 @@
173 173
       // are going to apply the Y-Distance into the cell to interpolate the final Z correction.
174 174
 
175 175
       const float yratio = (RAW_Y_POSITION(end[Y_AXIS]) - mesh_index_to_ypos(cell_dest_yi)) * (1.0 / (MESH_Y_DIST));
176
-      float z0 = cell_dest_yi < GRID_MAX_POINTS_Y - 1 ? (z1 + (z2 - z1) * yratio) * fade_scaling_factor_for_z(end[Z_AXIS]) : 0.0;
176
+      float z0 = cell_dest_yi < GRID_MAX_POINTS_Y - 1 ? (z1 + (z2 - z1) * yratio) * planner.fade_scaling_factor_for_z(end[Z_AXIS]) : 0.0;
177 177
 
178 178
       /**
179 179
        * If part of the Mesh is undefined, it will show up as NAN
@@ -257,9 +257,8 @@
257 257
          */
258 258
         const float x = inf_m_flag ? start[X_AXIS] : (next_mesh_line_y - c) / m;
259 259
 
260
-        float z0 = z_correction_for_x_on_horizontal_mesh_line(x, current_xi, current_yi);
261
-
262
-        z0 *= fade_scaling_factor_for_z(end[Z_AXIS]);
260
+        float z0 = z_correction_for_x_on_horizontal_mesh_line(x, current_xi, current_yi)
261
+                   * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
263 262
 
264 263
         /**
265 264
          * If part of the Mesh is undefined, it will show up as NAN
@@ -322,9 +321,8 @@
322 321
         const float next_mesh_line_x = LOGICAL_X_POSITION(mesh_index_to_xpos(current_xi)),
323 322
                     y = m * next_mesh_line_x + c;   // Calculate Y at the next X mesh line
324 323
 
325
-        float z0 = z_correction_for_y_on_vertical_mesh_line(y, current_xi, current_yi);
326
-
327
-        z0 *= fade_scaling_factor_for_z(end[Z_AXIS]);
324
+        float z0 = z_correction_for_y_on_vertical_mesh_line(y, current_xi, current_yi)
325
+                   * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
328 326
 
329 327
         /**
330 328
          * If part of the Mesh is undefined, it will show up as NAN
@@ -395,9 +393,8 @@
395 393
 
396 394
       if (left_flag == (x > next_mesh_line_x)) { // Check if we hit the Y line first
397 395
         // Yes!  Crossing a Y Mesh Line next
398
-        float z0 = z_correction_for_x_on_horizontal_mesh_line(x, current_xi - left_flag, current_yi + dyi);
399
-
400
-        z0 *= fade_scaling_factor_for_z(end[Z_AXIS]);
396
+        float z0 = z_correction_for_x_on_horizontal_mesh_line(x, current_xi - left_flag, current_yi + dyi)
397
+                   * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
401 398
 
402 399
         /**
403 400
          * If part of the Mesh is undefined, it will show up as NAN
@@ -423,9 +420,8 @@
423 420
       }
424 421
       else {
425 422
         // Yes!  Crossing a X Mesh Line next
426
-        float z0 = z_correction_for_y_on_vertical_mesh_line(y, current_xi + dxi, current_yi - down_flag);
427
-
428
-        z0 *= fade_scaling_factor_for_z(end[Z_AXIS]);
423
+        float z0 = z_correction_for_y_on_vertical_mesh_line(y, current_xi + dxi, current_yi - down_flag)
424
+                   * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
429 425
 
430 426
         /**
431 427
          * If part of the Mesh is undefined, it will show up as NAN
@@ -580,17 +576,9 @@
580 576
             seg_rz = RAW_Z_POSITION(current_position[Z_AXIS]),
581 577
             seg_le = current_position[E_AXIS];
582 578
 
583
-      const bool above_fade_height = (
584
-        #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
585
-          planner.z_fade_height != 0 && planner.z_fade_height < RAW_Z_POSITION(ltarget[Z_AXIS])
586
-        #else
587
-          false
588
-        #endif
589
-      );
590
-
591 579
       // Only compute leveling per segment if ubl active and target below z_fade_height.
592 580
 
593
-      if (!state.active || above_fade_height) {   // no mesh leveling
581
+      if (!planner.leveling_active || !planner.leveling_active_at_z(ltarget[Z_AXIS])) {   // no mesh leveling
594 582
 
595 583
         do {
596 584
 
@@ -616,7 +604,7 @@
616 604
       // Otherwise perform per-segment leveling
617 605
 
618 606
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
619
-        const float fade_scaling_factor = fade_scaling_factor_for_z(ltarget[Z_AXIS]);
607
+        const float fade_scaling_factor = planner.fade_scaling_factor_for_z(ltarget[Z_AXIS]);
620 608
       #endif
621 609
 
622 610
       // increment to first segment destination
@@ -648,7 +636,7 @@
648 636
               z_x0y1 = z_values[cell_xi  ][cell_yi+1],  // z at lower right corner
649 637
               z_x1y1 = z_values[cell_xi+1][cell_yi+1];  // z at upper right corner
650 638
 
651
-        if (isnan(z_x0y0)) z_x0y0 = 0;              // ideally activating state.active (G29 A)
639
+        if (isnan(z_x0y0)) z_x0y0 = 0;              // ideally activating planner.leveling_active (G29 A)
652 640
         if (isnan(z_x1y0)) z_x1y0 = 0;              //   should refuse if any invalid mesh points
653 641
         if (isnan(z_x0y1)) z_x0y1 = 0;              //   in order to avoid isnan tests per cell,
654 642
         if (isnan(z_x1y1)) z_x1y1 = 0;              //   thus guessing zero for undefined points

+ 5
- 6
Marlin/src/gcode/bedlevel/M420.cpp Parādīt failu

@@ -51,7 +51,7 @@ void GcodeSuite::M420() {
51 51
     if (parser.seen('L')) {
52 52
 
53 53
       #if ENABLED(EEPROM_SETTINGS)
54
-        const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.state.storage_slot;
54
+        const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.storage_slot;
55 55
         const int16_t a = settings.calc_num_meshes();
56 56
 
57 57
         if (!a) {
@@ -66,7 +66,7 @@ void GcodeSuite::M420() {
66 66
         }
67 67
 
68 68
         settings.load_mesh(storage_slot);
69
-        ubl.state.storage_slot = storage_slot;
69
+        ubl.storage_slot = storage_slot;
70 70
 
71 71
       #else
72 72
 
@@ -80,7 +80,7 @@ void GcodeSuite::M420() {
80 80
     if (parser.seen('L') || parser.seen('V')) {
81 81
       ubl.display_map(0);  // Currently only supports one map type
82 82
       SERIAL_ECHOLNPAIR("ubl.mesh_is_valid = ", ubl.mesh_is_valid());
83
-      SERIAL_ECHOLNPAIR("ubl.state.storage_slot = ", ubl.state.storage_slot);
83
+      SERIAL_ECHOLNPAIR("ubl.storage_slot = ", ubl.storage_slot);
84 84
     }
85 85
 
86 86
   #endif // AUTO_BED_LEVELING_UBL
@@ -105,14 +105,13 @@ void GcodeSuite::M420() {
105 105
   }
106 106
 
107 107
   const bool to_enable = parser.boolval('S');
108
-  if (parser.seen('S'))
109
-    set_bed_leveling_enabled(to_enable);
108
+  if (parser.seen('S')) set_bed_leveling_enabled(to_enable);
110 109
 
111 110
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
112 111
     if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units());
113 112
   #endif
114 113
 
115
-  const bool new_status = leveling_is_active();
114
+  const bool new_status = planner.leveling_active;
116 115
 
117 116
   if (to_enable && !new_status) {
118 117
     SERIAL_ERROR_START();

+ 14
- 14
Marlin/src/gcode/bedlevel/abl/G29.cpp Parādīt failu

@@ -137,7 +137,7 @@ void GcodeSuite::G29() {
137 137
     const uint8_t old_debug_flags = marlin_debug_flags;
138 138
     if (query) marlin_debug_flags |= DEBUG_LEVELING;
139 139
     if (DEBUGGING(LEVELING)) {
140
-      DEBUG_POS(">>> gcode_G29", current_position);
140
+      DEBUG_POS(">>> G29", current_position);
141 141
       log_machine_info();
142 142
     }
143 143
     marlin_debug_flags = old_debug_flags;
@@ -247,7 +247,7 @@ void GcodeSuite::G29() {
247 247
       abl_probe_index = -1;
248 248
     #endif
249 249
 
250
-    abl_should_enable = leveling_is_active();
250
+    abl_should_enable = planner.leveling_active;
251 251
 
252 252
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
253 253
 
@@ -388,7 +388,7 @@ void GcodeSuite::G29() {
388 388
     stepper.synchronize();
389 389
 
390 390
     // Disable auto bed leveling during G29
391
-    planner.abl_enabled = false;
391
+    planner.leveling_active = false;
392 392
 
393 393
     if (!dryrun) {
394 394
       // Re-orient the current position without leveling
@@ -402,7 +402,7 @@ void GcodeSuite::G29() {
402 402
     #if HAS_BED_PROBE
403 403
       // Deploy the probe. Probe will raise if needed.
404 404
       if (DEPLOY_PROBE()) {
405
-        planner.abl_enabled = abl_should_enable;
405
+        planner.leveling_active = abl_should_enable;
406 406
         return;
407 407
       }
408 408
     #endif
@@ -421,7 +421,7 @@ void GcodeSuite::G29() {
421 421
       ) {
422 422
         if (dryrun) {
423 423
           // Before reset bed level, re-enable to correct the position
424
-          planner.abl_enabled = abl_should_enable;
424
+          planner.leveling_active = abl_should_enable;
425 425
         }
426 426
         // Reset grid to 0.0 or "not probed". (Also disables ABL)
427 427
         reset_bed_level();
@@ -466,7 +466,7 @@ void GcodeSuite::G29() {
466 466
       #if HAS_SOFTWARE_ENDSTOPS
467 467
         soft_endstops_enabled = enable_soft_endstops;
468 468
       #endif
469
-      planner.abl_enabled = abl_should_enable;
469
+      planner.leveling_active = abl_should_enable;
470 470
       g29_in_progress = false;
471 471
       #if ENABLED(LCD_BED_LEVELING)
472 472
         lcd_wait_for_move = false;
@@ -669,7 +669,7 @@ void GcodeSuite::G29() {
669 669
           measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
670 670
 
671 671
           if (isnan(measured_z)) {
672
-            planner.abl_enabled = abl_should_enable;
672
+            planner.leveling_active = abl_should_enable;
673 673
             break;
674 674
           }
675 675
 
@@ -705,7 +705,7 @@ void GcodeSuite::G29() {
705 705
         yProbe = LOGICAL_Y_POSITION(points[i].y);
706 706
         measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
707 707
         if (isnan(measured_z)) {
708
-          planner.abl_enabled = abl_should_enable;
708
+          planner.leveling_active = abl_should_enable;
709 709
           break;
710 710
         }
711 711
         points[i].z = measured_z;
@@ -728,7 +728,7 @@ void GcodeSuite::G29() {
728 728
 
729 729
     // Raise to _Z_CLEARANCE_DEPLOY_PROBE. Stow the probe.
730 730
     if (STOW_PROBE()) {
731
-      planner.abl_enabled = abl_should_enable;
731
+      planner.leveling_active = abl_should_enable;
732 732
       measured_z = NAN;
733 733
     }
734 734
   }
@@ -896,9 +896,9 @@ void GcodeSuite::G29() {
896 896
         float converted[XYZ];
897 897
         COPY(converted, current_position);
898 898
 
899
-        planner.abl_enabled = true;
899
+        planner.leveling_active = true;
900 900
         planner.unapply_leveling(converted); // use conversion machinery
901
-        planner.abl_enabled = false;
901
+        planner.leveling_active = false;
902 902
 
903 903
         // Use the last measured distance to the bed, if possible
904 904
         if ( NEAR(current_position[X_AXIS], xProbe - (X_PROBE_OFFSET_FROM_EXTRUDER))
@@ -950,21 +950,21 @@ void GcodeSuite::G29() {
950 950
     #endif
951 951
 
952 952
     // Auto Bed Leveling is complete! Enable if possible.
953
-    planner.abl_enabled = dryrun ? abl_should_enable : true;
953
+    planner.leveling_active = dryrun ? abl_should_enable : true;
954 954
   } // !isnan(measured_z)
955 955
 
956 956
   // Restore state after probing
957 957
   if (!faux) clean_up_after_endstop_or_probe_move();
958 958
 
959 959
   #if ENABLED(DEBUG_LEVELING_FEATURE)
960
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G29");
960
+    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G29");
961 961
   #endif
962 962
 
963 963
   report_current_position();
964 964
 
965 965
   KEEPALIVE_STATE(IN_HANDLER);
966 966
 
967
-  if (planner.abl_enabled)
967
+  if (planner.leveling_active)
968 968
     SYNC_PLAN_POSITION_KINEMATIC();
969 969
 }
970 970
 

+ 2
- 2
Marlin/src/gcode/bedlevel/mbl/G29.cpp Parādīt failu

@@ -42,7 +42,7 @@
42 42
 void echo_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
43 43
 
44 44
 void mesh_probing_done() {
45
-  mbl.set_has_mesh(true);
45
+  mbl.has_mesh = true;
46 46
   gcode.home_all_axes();
47 47
   set_bed_leveling_enabled(true);
48 48
   #if ENABLED(MESH_G28_REST_ORIGIN)
@@ -92,7 +92,7 @@ void GcodeSuite::G29() {
92 92
   switch (state) {
93 93
     case MeshReport:
94 94
       if (leveling_is_valid()) {
95
-        SERIAL_PROTOCOLLNPAIR("State: ", leveling_is_active() ? MSG_ON : MSG_OFF);
95
+        SERIAL_PROTOCOLLNPAIR("State: ", planner.leveling_active ? MSG_ON : MSG_OFF);
96 96
         mbl_mesh_report();
97 97
       }
98 98
       else

+ 1
- 1
Marlin/src/gcode/calibrate/G28.cpp Parādīt failu

@@ -157,7 +157,7 @@ void GcodeSuite::G28(const bool always_home_all) {
157 157
   // Disable the leveling matrix before homing
158 158
   #if HAS_LEVELING
159 159
     #if ENABLED(AUTO_BED_LEVELING_UBL)
160
-      const bool ubl_state_at_entry = leveling_is_active();
160
+      const bool ubl_state_at_entry = planner.leveling_active;
161 161
     #endif
162 162
     set_bed_leveling_enabled(false);
163 163
   #endif

+ 5
- 1
Marlin/src/gcode/calibrate/M48.cpp Parādīt failu

@@ -32,6 +32,10 @@
32 32
   #include "../../feature/bedlevel/bedlevel.h"
33 33
 #endif
34 34
 
35
+#if HAS_LEVELING
36
+  #include "../../module/planner.h"
37
+#endif
38
+
35 39
 /**
36 40
  * M48: Z probe repeatability measurement function.
37 41
  *
@@ -115,7 +119,7 @@ void GcodeSuite::M48() {
115 119
   // Disable bed level correction in M48 because we want the raw data when we probe
116 120
 
117 121
   #if HAS_LEVELING
118
-    const bool was_enabled = leveling_is_active();
122
+    const bool was_enabled = planner.leveling_active;
119 123
     set_bed_leveling_enabled(false);
120 124
   #endif
121 125
 

+ 2
- 2
Marlin/src/gcode/control/T.cpp Parādīt failu

@@ -37,7 +37,7 @@ void GcodeSuite::T(const uint8_t tmp_extruder) {
37 37
 
38 38
   #if ENABLED(DEBUG_LEVELING_FEATURE)
39 39
     if (DEBUGGING(LEVELING)) {
40
-      SERIAL_ECHOPAIR(">>> gcode_T(", tmp_extruder);
40
+      SERIAL_ECHOPAIR(">>> T(", tmp_extruder);
41 41
       SERIAL_CHAR(')');
42 42
       SERIAL_EOL();
43 43
       DEBUG_POS("BEFORE", current_position);
@@ -61,7 +61,7 @@ void GcodeSuite::T(const uint8_t tmp_extruder) {
61 61
   #if ENABLED(DEBUG_LEVELING_FEATURE)
62 62
     if (DEBUGGING(LEVELING)) {
63 63
       DEBUG_POS("AFTER", current_position);
64
-      SERIAL_ECHOLNPGM("<<< gcode_T");
64
+      SERIAL_ECHOLNPGM("<<< T()");
65 65
     }
66 66
   #endif
67 67
 }

+ 6
- 6
Marlin/src/inc/Conditionals_post.h Parādīt failu

@@ -820,12 +820,12 @@
820 820
   #define UBL_DELTA  (ENABLED(AUTO_BED_LEVELING_UBL) && (ENABLED(DELTA) || ENABLED(UBL_GRANULAR_SEGMENTATION_FOR_CARTESIAN)))
821 821
   #define ABL_PLANAR (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_3POINT))
822 822
   #define ABL_GRID   (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR))
823
-  #define HAS_ABL    (ABL_PLANAR || ABL_GRID || ENABLED(AUTO_BED_LEVELING_UBL))
824
-  #define HAS_LEVELING  (HAS_ABL || ENABLED(MESH_BED_LEVELING))
825
-  #define HAS_AUTOLEVEL (HAS_ABL && DISABLED(PROBE_MANUALLY))
826
-  #define OLDSCHOOL_ABL (HAS_ABL && DISABLED(AUTO_BED_LEVELING_UBL))
827
-  #define HAS_MESH   (ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(MESH_BED_LEVELING))
828
-  #define PLANNER_LEVELING      (ABL_PLANAR || ABL_GRID || ENABLED(MESH_BED_LEVELING) || UBL_DELTA)
823
+  #define OLDSCHOOL_ABL         (ABL_PLANAR || ABL_GRID)
824
+  #define HAS_ABL               (OLDSCHOOL_ABL || ENABLED(AUTO_BED_LEVELING_UBL))
825
+  #define HAS_LEVELING          (HAS_ABL || ENABLED(MESH_BED_LEVELING))
826
+  #define HAS_AUTOLEVEL         (HAS_ABL && DISABLED(PROBE_MANUALLY))
827
+  #define HAS_MESH              (ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(MESH_BED_LEVELING))
828
+  #define PLANNER_LEVELING      (OLDSCHOOL_ABL || ENABLED(MESH_BED_LEVELING) || UBL_DELTA)
829 829
   #define HAS_PROBING_PROCEDURE (HAS_ABL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))
830 830
   #if HAS_PROBING_PROCEDURE
831 831
     #define PROBE_BED_WIDTH abs(RIGHT_PROBE_BED_POSITION - (LEFT_PROBE_BED_POSITION))

+ 1
- 1
Marlin/src/inc/SanityCheck.h Parādīt failu

@@ -651,7 +651,7 @@ static_assert(1 >= 0
651 651
   /**
652 652
    * Require some kind of probe for bed leveling and probe testing
653 653
    */
654
-  #if HAS_ABL && DISABLED(AUTO_BED_LEVELING_UBL)
654
+  #if OLDSCHOOL_ABL
655 655
     #error "Auto Bed Leveling requires one of these: PROBE_MANUALLY, FIX_MOUNTED_PROBE, BLTOUCH, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or a Z Servo."
656 656
   #endif
657 657
 

+ 25
- 10
Marlin/src/lcd/ultralcd.cpp Parādīt failu

@@ -1086,7 +1086,7 @@ void kill_screen(const char* lcd_msg) {
1086 1086
           const float new_zoffset = zprobe_zoffset + planner.steps_to_mm[Z_AXIS] * babystep_increment;
1087 1087
           if (WITHIN(new_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
1088 1088
 
1089
-            if (leveling_is_active())
1089
+            if (planner.leveling_active)
1090 1090
               thermalManager.babystep_axis(Z_AXIS, babystep_increment);
1091 1091
 
1092 1092
             zprobe_zoffset = new_zoffset;
@@ -1788,7 +1788,7 @@ void kill_screen(const char* lcd_msg) {
1788 1788
 
1789 1789
             _lcd_after_probing();
1790 1790
 
1791
-            mbl.set_has_mesh(true);
1791
+            mbl.has_mesh = true;
1792 1792
             mesh_probing_done();
1793 1793
 
1794 1794
           #endif
@@ -1906,11 +1906,12 @@ void kill_screen(const char* lcd_msg) {
1906 1906
       enqueue_and_echo_commands_P(PSTR("G28"));
1907 1907
     }
1908 1908
 
1909
-    static bool _level_state;
1910
-    void _lcd_toggle_bed_leveling() { set_bed_leveling_enabled(_level_state); }
1909
+    static bool new_level_state;
1910
+    void _lcd_toggle_bed_leveling() { set_bed_leveling_enabled(new_level_state); }
1911 1911
 
1912 1912
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1913
-      void _lcd_set_z_fade_height() { set_z_fade_height(planner.z_fade_height); }
1913
+      static float new_z_fade_height;
1914
+      void _lcd_set_z_fade_height() { set_z_fade_height(new_z_fade_height); }
1914 1915
     #endif
1915 1916
 
1916 1917
     /**
@@ -1934,13 +1935,11 @@ void kill_screen(const char* lcd_msg) {
1934 1935
       if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
1935 1936
         MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
1936 1937
       else if (leveling_is_valid()) {
1937
-        _level_state = leveling_is_active();
1938
-        MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &_level_state, _lcd_toggle_bed_leveling);
1938
+        MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
1939 1939
       }
1940 1940
 
1941 1941
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1942
-        set_z_fade_height(planner.z_fade_height);
1943
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &planner.z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
1942
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
1944 1943
       #endif
1945 1944
 
1946 1945
       //
@@ -1971,6 +1970,16 @@ void kill_screen(const char* lcd_msg) {
1971 1970
       END_MENU();
1972 1971
     }
1973 1972
 
1973
+    void _lcd_goto_bed_leveling() {
1974
+      currentScreen = lcd_bed_leveling;
1975
+      #if ENABLED(LCD_BED_LEVELING)
1976
+        new_level_state = planner.leveling_active;
1977
+      #endif
1978
+      #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1979
+        new_z_fade_height = planner.z_fade_height;
1980
+      #endif
1981
+    }
1982
+
1974 1983
   #elif ENABLED(AUTO_BED_LEVELING_UBL)
1975 1984
 
1976 1985
     void _lcd_ubl_level_bed();
@@ -2541,7 +2550,13 @@ void kill_screen(const char* lcd_msg) {
2541 2550
       #if ENABLED(PROBE_MANUALLY)
2542 2551
         if (!g29_in_progress)
2543 2552
       #endif
2544
-      MENU_ITEM(submenu, MSG_BED_LEVELING, lcd_bed_leveling);
2553
+          MENU_ITEM(submenu, MSG_BED_LEVELING,
2554
+            #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
2555
+              _lcd_goto_bed_leveling
2556
+            #else
2557
+              lcd_bed_leveling
2558
+            #endif
2559
+          );
2545 2560
     #else
2546 2561
       #if PLANNER_LEVELING
2547 2562
         MENU_ITEM(gcode, MSG_BED_LEVELING, PSTR("G28\nG29"));

+ 1
- 1
Marlin/src/lcd/ultralcd_impl_HD44780.h Parādīt failu

@@ -795,7 +795,7 @@ static void lcd_implementation_status_screen() {
795 795
     lcd.print(ftostr52sp(FIXFLOAT(current_position[Z_AXIS])));
796 796
 
797 797
     #if HAS_LEVELING
798
-      lcd.write(leveling_is_active() || blink ? '_' : ' ');
798
+      lcd.write(planner.leveling_active || blink ? '_' : ' ');
799 799
     #endif
800 800
 
801 801
   #endif // LCD_HEIGHT > 2

+ 26
- 22
Marlin/src/module/configuration_store.cpp Parādīt failu

@@ -68,7 +68,7 @@
68 68
  *  219            z_fade_height                    (float)
69 69
  *
70 70
  * MESH_BED_LEVELING:                               43 bytes
71
- *  223  M420 S    from mbl.status                  (bool)
71
+ *  223  M420 S    planner.leveling_active         (bool)
72 72
  *  224            mbl.z_offset                     (float)
73 73
  *  228            GRID_MAX_POINTS_X                (uint8_t)
74 74
  *  229            GRID_MAX_POINTS_Y                (uint8_t)
@@ -88,8 +88,8 @@
88 88
  *  316            z_values[][]                     (float x9, up to float x256) +988
89 89
  *
90 90
  * AUTO_BED_LEVELING_UBL:                           2 bytes
91
- *  324  G29 A     ubl.state.active                 (bool)
92
- *  325  G29 S     ubl.state.storage_slot           (int8_t)
91
+ *  324  G29 A     planner.leveling_active          (bool)
92
+ *  325  G29 S     ubl.storage_slot                 (int8_t)
93 93
  *
94 94
  * DELTA:                                           48 bytes
95 95
  *  344  M666 XYZ  delta_endstop_adj                (float x3)
@@ -202,6 +202,10 @@ MarlinSettings settings;
202 202
   #include "../feature/fwretract.h"
203 203
 #endif
204 204
 
205
+#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
206
+  float new_z_fade_height;
207
+#endif
208
+
205 209
 /**
206 210
  * Post-process after Retrieve or Reset
207 211
  */
@@ -231,7 +235,7 @@ void MarlinSettings::postprocess() {
231 235
   #endif
232 236
 
233 237
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
234
-    set_z_fade_height(planner.z_fade_height);
238
+    set_z_fade_height(new_z_fade_height);
235 239
   #endif
236 240
 
237 241
   #if HAS_BED_PROBE
@@ -329,7 +333,7 @@ void MarlinSettings::postprocess() {
329 333
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
330 334
       const float zfh = planner.z_fade_height;
331 335
     #else
332
-      const float zfh = 10.0;
336
+      const float zfh = 0.0;
333 337
     #endif
334 338
     EEPROM_WRITE(zfh);
335 339
 
@@ -343,7 +347,7 @@ void MarlinSettings::postprocess() {
343 347
         sizeof(mbl.z_values) == GRID_MAX_POINTS * sizeof(mbl.z_values[0][0]),
344 348
         "MBL Z array is the wrong size."
345 349
       );
346
-      const bool leveling_is_on = TEST(mbl.status, MBL_STATUS_HAS_MESH_BIT);
350
+      const bool leveling_is_on = mbl.has_mesh;
347 351
       const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
348 352
       EEPROM_WRITE(leveling_is_on);
349 353
       EEPROM_WRITE(mbl.z_offset);
@@ -406,8 +410,8 @@ void MarlinSettings::postprocess() {
406 410
     #endif // AUTO_BED_LEVELING_BILINEAR
407 411
 
408 412
     #if ENABLED(AUTO_BED_LEVELING_UBL)
409
-      EEPROM_WRITE(ubl.state.active);
410
-      EEPROM_WRITE(ubl.state.storage_slot);
413
+      EEPROM_WRITE(planner.leveling_active);
414
+      EEPROM_WRITE(ubl.storage_slot);
411 415
     #else
412 416
       const bool ubl_active = false;
413 417
       const int8_t storage_slot = -1;
@@ -630,8 +634,8 @@ void MarlinSettings::postprocess() {
630 634
     }
631 635
 
632 636
     #if ENABLED(UBL_SAVE_ACTIVE_ON_M500)
633
-      if (ubl.state.storage_slot >= 0)
634
-        store_mesh(ubl.state.storage_slot);
637
+      if (ubl.storage_slot >= 0)
638
+        store_mesh(ubl.storage_slot);
635 639
     #endif
636 640
     EEPROM_FINISH();
637 641
     return !eeprom_error;
@@ -720,7 +724,7 @@ void MarlinSettings::postprocess() {
720 724
       //
721 725
 
722 726
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
723
-        EEPROM_READ(planner.z_fade_height);
727
+        EEPROM_READ(new_z_fade_height);
724 728
       #else
725 729
         EEPROM_READ(dummy);
726 730
       #endif
@@ -737,7 +741,7 @@ void MarlinSettings::postprocess() {
737 741
       EEPROM_READ(mesh_num_y);
738 742
 
739 743
       #if ENABLED(MESH_BED_LEVELING)
740
-        mbl.status = leveling_is_on ? _BV(MBL_STATUS_HAS_MESH_BIT) : 0;
744
+        mbl.has_mesh = leveling_is_on;
741 745
         mbl.z_offset = dummy;
742 746
         if (mesh_num_x == GRID_MAX_POINTS_X && mesh_num_y == GRID_MAX_POINTS_Y) {
743 747
           // EEPROM data fits the current mesh
@@ -793,8 +797,8 @@ void MarlinSettings::postprocess() {
793 797
         }
794 798
 
795 799
       #if ENABLED(AUTO_BED_LEVELING_UBL)
796
-        EEPROM_READ(ubl.state.active);
797
-        EEPROM_READ(ubl.state.storage_slot);
800
+        EEPROM_READ(planner.leveling_active);
801
+        EEPROM_READ(ubl.storage_slot);
798 802
       #else
799 803
         uint8_t dummyui8;
800 804
         EEPROM_READ(dummyb);
@@ -1011,10 +1015,10 @@ void MarlinSettings::postprocess() {
1011 1015
           ubl.reset();
1012 1016
         }
1013 1017
 
1014
-        if (ubl.state.storage_slot >= 0) {
1015
-          load_mesh(ubl.state.storage_slot);
1018
+        if (ubl.storage_slot >= 0) {
1019
+          load_mesh(ubl.storage_slot);
1016 1020
           #if ENABLED(EEPROM_CHITCHAT)
1017
-            SERIAL_ECHOPAIR("Mesh ", ubl.state.storage_slot);
1021
+            SERIAL_ECHOPAIR("Mesh ", ubl.storage_slot);
1018 1022
             SERIAL_ECHOLNPGM(" loaded from storage.");
1019 1023
           #endif
1020 1024
         }
@@ -1156,7 +1160,7 @@ void MarlinSettings::reset() {
1156 1160
   planner.max_jerk[E_AXIS] = DEFAULT_EJERK;
1157 1161
 
1158 1162
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1159
-    planner.z_fade_height = 0.0;
1163
+    new_z_fade_height = 0.0;
1160 1164
   #endif
1161 1165
 
1162 1166
   #if HAS_HOME_OFFSET
@@ -1556,9 +1560,9 @@ void MarlinSettings::reset() {
1556 1560
         SERIAL_ECHOLNPGM(":");
1557 1561
       }
1558 1562
       CONFIG_ECHO_START;
1559
-      SERIAL_ECHOPAIR("  M420 S", leveling_is_active() ? 1 : 0);
1563
+      SERIAL_ECHOPAIR("  M420 S", planner.leveling_active ? 1 : 0);
1560 1564
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1561
-        SERIAL_ECHOPAIR(" Z", planner.z_fade_height);
1565
+        SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.z_fade_height));
1562 1566
       #endif
1563 1567
       SERIAL_EOL();
1564 1568
 
@@ -1566,7 +1570,7 @@ void MarlinSettings::reset() {
1566 1570
         SERIAL_EOL();
1567 1571
         ubl.report_state();
1568 1572
 
1569
-        SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.state.storage_slot);
1573
+        SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.storage_slot);
1570 1574
         SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes());
1571 1575
         SERIAL_ECHOLNPGM(" meshes.\n");
1572 1576
       }
@@ -1578,7 +1582,7 @@ void MarlinSettings::reset() {
1578 1582
         SERIAL_ECHOLNPGM("Auto Bed Leveling:");
1579 1583
       }
1580 1584
       CONFIG_ECHO_START;
1581
-      SERIAL_ECHOPAIR("  M420 S", leveling_is_active() ? 1 : 0);
1585
+      SERIAL_ECHOPAIR("  M420 S", planner.leveling_active ? 1 : 0);
1582 1586
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1583 1587
         SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.z_fade_height));
1584 1588
       #endif

+ 22
- 31
Marlin/src/module/motion.cpp Parādīt failu

@@ -490,14 +490,14 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
490 490
   #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
491 491
     #if ENABLED(DELTA)
492 492
       #define ADJUST_DELTA(V) \
493
-        if (planner.abl_enabled) { \
493
+        if (planner.leveling_active) { \
494 494
           const float zadj = bilinear_z_offset(V); \
495 495
           delta[A_AXIS] += zadj; \
496 496
           delta[B_AXIS] += zadj; \
497 497
           delta[C_AXIS] += zadj; \
498 498
         }
499 499
     #else
500
-      #define ADJUST_DELTA(V) if (planner.abl_enabled) { delta[Z_AXIS] += bilinear_z_offset(V); }
500
+      #define ADJUST_DELTA(V) if (planner.leveling_active) { delta[Z_AXIS] += bilinear_z_offset(V); }
501 501
     #endif
502 502
   #else
503 503
     #define ADJUST_DELTA(V) NOOP
@@ -630,41 +630,30 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
630 630
 
631 631
   /**
632 632
    * Prepare a linear move in a Cartesian setup.
633
-   * If Mesh Bed Leveling is enabled, perform a mesh move.
633
+   * Bed Leveling will be applied to the move if enabled.
634 634
    *
635
-   * Returns true if the caller didn't update current_position.
635
+   * Returns true if current_position[] was set to destination[]
636 636
    */
637 637
   inline bool prepare_move_to_destination_cartesian() {
638
-    #if ENABLED(AUTO_BED_LEVELING_UBL)
638
+    if (current_position[X_AXIS] != destination[X_AXIS] || current_position[Y_AXIS] != destination[Y_AXIS]) {
639 639
       const float fr_scaled = MMS_SCALED(feedrate_mm_s);
640
-      if (ubl.state.active) { // direct use of ubl.state.active for speed
641
-        ubl.line_to_destination_cartesian(fr_scaled, active_extruder);
642
-        return true;
643
-      }
644
-      else
645
-        line_to_destination(fr_scaled);
646
-    #else
647
-      // Do not use feedrate_percentage for E or Z only moves
648
-      if (current_position[X_AXIS] == destination[X_AXIS] && current_position[Y_AXIS] == destination[Y_AXIS])
649
-        line_to_destination();
650
-      else {
651
-        const float fr_scaled = MMS_SCALED(feedrate_mm_s);
652
-        #if ENABLED(MESH_BED_LEVELING)
653
-          if (mbl.active()) { // direct used of mbl.active() for speed
640
+      #if HAS_MESH
641
+        if (planner.leveling_active) {
642
+          #if ENABLED(AUTO_BED_LEVELING_UBL)
643
+            ubl.line_to_destination_cartesian(fr_scaled, active_extruder);
644
+          #elif ENABLED(MESH_BED_LEVELING)
654 645
             mesh_line_to_destination(fr_scaled);
655
-            return true;
656
-          }
657
-          else
658
-        #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
659
-          if (planner.abl_enabled) { // direct use of abl_enabled for speed
646
+          #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
660 647
             bilinear_line_to_destination(fr_scaled);
661
-            return true;
662
-          }
663
-          else
664
-        #endif
665
-            line_to_destination(fr_scaled);
666
-      }
667
-    #endif
648
+          #endif
649
+          return true;
650
+        }
651
+      #endif // HAS_MESH
652
+      line_to_destination(fr_scaled);
653
+    }
654
+    else
655
+      line_to_destination();
656
+
668 657
     return false;
669 658
   }
670 659
 
@@ -699,6 +688,8 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
699 688
 
700 689
   /**
701 690
    * Prepare a linear move in a dual X axis setup
691
+   *
692
+   * Return true if current_position[] was set to destination[]
702 693
    */
703 694
   inline bool prepare_move_to_destination_dualx() {
704 695
     if (active_extruder_parked) {

+ 56
- 85
Marlin/src/module/planner.cpp Parādīt failu

@@ -122,8 +122,8 @@ float Planner::min_feedrate_mm_s,
122 122
       Planner::max_jerk[XYZE],       // The largest speed change requiring no acceleration
123 123
       Planner::min_travel_feedrate_mm_s;
124 124
 
125
-#if OLDSCHOOL_ABL
126
-  bool Planner::abl_enabled = false; // Flag that auto bed leveling is enabled
125
+#if HAS_LEVELING
126
+  bool Planner::leveling_active = false; // Flag that auto bed leveling is enabled
127 127
   #if ABL_PLANAR
128 128
     matrix_3x3 Planner::bed_level_matrix; // Transform to compensate for bed level
129 129
   #endif
@@ -131,7 +131,8 @@ float Planner::min_feedrate_mm_s,
131 131
 
132 132
 #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
133 133
   float Planner::z_fade_height, // Initialized by settings.load()
134
-        Planner::inverse_z_fade_height;
134
+        Planner::inverse_z_fade_height,
135
+        Planner::last_raw_lz;
135 136
 #endif
136 137
 
137 138
 #if ENABLED(AUTOTEMP)
@@ -555,46 +556,31 @@ void Planner::calculate_volumetric_multipliers() {
555 556
    */
556 557
   void Planner::apply_leveling(float &lx, float &ly, float &lz) {
557 558
 
558
-    #if ENABLED(AUTO_BED_LEVELING_UBL)
559
-      if (!ubl.state.active) return;
560
-      #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
561
-        // if z_fade_height enabled (nonzero) and raw_z above it, no leveling required
562
-        if (planner.z_fade_height && planner.z_fade_height <= RAW_Z_POSITION(lz)) return;
563
-        lz += ubl.get_z_correction(lx, ly) * ubl.fade_scaling_factor_for_z(lz);
564
-      #else // no fade
565
-        lz += ubl.get_z_correction(lx, ly);
566
-      #endif // FADE
567
-    #endif // UBL
568
-
569
-    #if OLDSCHOOL_ABL
570
-      if (!abl_enabled) return;
571
-    #endif
559
+    if (!planner.leveling_active) return;
572 560
 
573
-    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) && DISABLED(AUTO_BED_LEVELING_UBL)
574
-      static float z_fade_factor = 1.0, last_raw_lz = -999.0;
575
-      if (z_fade_height) {
576
-        const float raw_lz = RAW_Z_POSITION(lz);
577
-        if (raw_lz >= z_fade_height) return;
578
-        if (last_raw_lz != raw_lz) {
579
-          last_raw_lz = raw_lz;
580
-          z_fade_factor = 1.0 - raw_lz * inverse_z_fade_height;
581
-        }
582
-      }
583
-      else
584
-        z_fade_factor = 1.0;
561
+    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
562
+      const float fade_scaling_factor = fade_scaling_factor_for_z(lz);
563
+      if (!fade_scaling_factor) return;
564
+    #else
565
+      constexpr float fade_scaling_factor = 1.0;
585 566
     #endif
586 567
 
587
-    #if ENABLED(MESH_BED_LEVELING)
568
+    #if ENABLED(AUTO_BED_LEVELING_UBL)
588 569
 
589
-      if (mbl.active())
590
-        lz += mbl.get_z(RAW_X_POSITION(lx), RAW_Y_POSITION(ly)
591
-          #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
592
-            , z_fade_factor
593
-          #endif
594
-          );
570
+      lz += ubl.get_z_correction(lx, ly) * fade_scaling_factor;
571
+
572
+    #elif ENABLED(MESH_BED_LEVELING)
573
+
574
+      lz += mbl.get_z(RAW_X_POSITION(lx), RAW_Y_POSITION(ly)
575
+        #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
576
+          , fade_scaling_factor
577
+        #endif
578
+      );
595 579
 
596 580
     #elif ABL_PLANAR
597 581
 
582
+      UNUSED(fade_scaling_factor);
583
+
598 584
       float dx = RAW_X_POSITION(lx) - (X_TILT_FULCRUM),
599 585
             dy = RAW_Y_POSITION(ly) - (Y_TILT_FULCRUM),
600 586
             dz = RAW_Z_POSITION(lz);
@@ -608,70 +594,55 @@ void Planner::calculate_volumetric_multipliers() {
608 594
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
609 595
 
610 596
       float tmp[XYZ] = { lx, ly, 0 };
611
-      lz += bilinear_z_offset(tmp)
612
-        #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
613
-          * z_fade_factor
614
-        #endif
615
-      ;
597
+      lz += bilinear_z_offset(tmp) * fade_scaling_factor;
616 598
 
617 599
     #endif
618 600
   }
619 601
 
620 602
   void Planner::unapply_leveling(float logical[XYZ]) {
621 603
 
622
-    #if ENABLED(AUTO_BED_LEVELING_UBL)
623
-
624
-      if (ubl.state.active) {
604
+    if (!planner.leveling_active) return;
625 605
 
626
-        const float z_physical = RAW_Z_POSITION(logical[Z_AXIS]),
627
-                    z_correct = ubl.get_z_correction(logical[X_AXIS], logical[Y_AXIS]),
628
-                    z_virtual = z_physical - z_correct;
629
-              float z_logical = LOGICAL_Z_POSITION(z_virtual);
630
-
631
-        #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
606
+    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
607
+      if (z_fade_height && RAW_Z_POSITION(logical[Z_AXIS]) >= z_fade_height) return;
608
+    #endif
632 609
 
633
-          // for P=physical_z, L=logical_z, M=mesh_z, H=fade_height,
634
-          // Given P=L+M(1-L/H) (faded mesh correction formula for L<H)
635
-          //  then L=P-M(1-L/H)
636
-          //    so L=P-M+ML/H
637
-          //    so L-ML/H=P-M
638
-          //    so L(1-M/H)=P-M
639
-          //    so L=(P-M)/(1-M/H) for L<H
610
+    #if ENABLED(AUTO_BED_LEVELING_UBL)
640 611
 
641
-          if (planner.z_fade_height) {
642
-            if (z_logical >= planner.z_fade_height)
643
-              z_logical = LOGICAL_Z_POSITION(z_physical);
644
-            else
645
-              z_logical /= 1.0 - z_correct * planner.inverse_z_fade_height;
646
-          }
612
+      const float z_physical = RAW_Z_POSITION(logical[Z_AXIS]),
613
+                  z_correct = ubl.get_z_correction(logical[X_AXIS], logical[Y_AXIS]),
614
+                  z_virtual = z_physical - z_correct;
615
+            float z_logical = LOGICAL_Z_POSITION(z_virtual);
647 616
 
648
-        #endif // ENABLE_LEVELING_FADE_HEIGHT
617
+      #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
649 618
 
650
-        logical[Z_AXIS] = z_logical;
651
-      }
619
+        // for P=physical_z, L=logical_z, M=mesh_z, H=fade_height,
620
+        // Given P=L+M(1-L/H) (faded mesh correction formula for L<H)
621
+        //  then L=P-M(1-L/H)
622
+        //    so L=P-M+ML/H
623
+        //    so L-ML/H=P-M
624
+        //    so L(1-M/H)=P-M
625
+        //    so L=(P-M)/(1-M/H) for L<H
626
+
627
+        if (planner.z_fade_height) {
628
+          if (z_logical >= planner.z_fade_height)
629
+            z_logical = LOGICAL_Z_POSITION(z_physical);
630
+          else
631
+            z_logical /= 1.0 - z_correct * planner.inverse_z_fade_height;
632
+        }
652 633
 
653
-      return; // don't fall thru to other ENABLE_LEVELING_FADE_HEIGHT logic
634
+      #endif // ENABLE_LEVELING_FADE_HEIGHT
654 635
 
655
-    #endif
636
+      logical[Z_AXIS] = z_logical;
656 637
 
657
-    #if OLDSCHOOL_ABL
658
-      if (!abl_enabled) return;
659
-    #endif
638
+    #elif ENABLED(MESH_BED_LEVELING)
660 639
 
661
-    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
662
-      if (z_fade_height && RAW_Z_POSITION(logical[Z_AXIS]) >= z_fade_height) return;
663
-    #endif
664
-
665
-    #if ENABLED(MESH_BED_LEVELING)
666
-
667
-      if (mbl.active()) {
668
-        #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
669
-          const float c = mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]), 1.0);
670
-          logical[Z_AXIS] = (z_fade_height * (RAW_Z_POSITION(logical[Z_AXIS]) - c)) / (z_fade_height - c);
671
-        #else
672
-          logical[Z_AXIS] -= mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]));
673
-        #endif
674
-      }
640
+      #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
641
+        const float c = mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]), 1.0);
642
+        logical[Z_AXIS] = (z_fade_height * (RAW_Z_POSITION(logical[Z_AXIS]) - c)) / (z_fade_height - c);
643
+      #else
644
+        logical[Z_AXIS] -= mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]));
645
+      #endif
675 646
 
676 647
     #elif ABL_PLANAR
677 648
 

+ 55
- 6
Marlin/src/module/planner.h Parādīt failu

@@ -164,15 +164,14 @@ class Planner {
164 164
                  max_jerk[XYZE],       // The largest speed change requiring no acceleration
165 165
                  min_travel_feedrate_mm_s;
166 166
 
167
-    #if OLDSCHOOL_ABL
168
-      static bool abl_enabled;              // Flag that bed leveling is enabled
167
+    #if HAS_LEVELING
168
+      static bool leveling_active;              // Flag that bed leveling is enabled
169 169
       #if ABL_PLANAR
170 170
         static matrix_3x3 bed_level_matrix; // Transform to compensate for bed level
171 171
       #endif
172
-    #endif
173
-
174
-    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
175
-      static float z_fade_height, inverse_z_fade_height;
172
+      #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
173
+        static float z_fade_height, inverse_z_fade_height;
174
+      #endif
176 175
     #endif
177 176
 
178 177
     #if ENABLED(LIN_ADVANCE)
@@ -202,6 +201,10 @@ class Planner {
202 201
      */
203 202
     static uint32_t cutoff_long;
204 203
 
204
+    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
205
+      static float last_raw_lz;
206
+    #endif
207
+
205 208
     #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
206 209
       /**
207 210
        * Counters to manage disabling inactive extruders
@@ -263,6 +266,52 @@ class Planner {
263 266
         if (!filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
264 267
     }
265 268
 
269
+    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
270
+
271
+      /**
272
+       * Get the Z leveling fade factor based on the given Z height,
273
+       * re-calculating only when needed.
274
+       *
275
+       *  Returns 1.0 if planner.z_fade_height is 0.0.
276
+       *  Returns 0.0 if Z is past the specified 'Fade Height'.
277
+       */
278
+      inline static float fade_scaling_factor_for_z(const float &lz) {
279
+        static float z_fade_factor = 1.0;
280
+        if (z_fade_height) {
281
+          const float raw_lz = RAW_Z_POSITION(lz);
282
+          if (raw_lz >= z_fade_height) return 0.0;
283
+          if (last_raw_lz != raw_lz) {
284
+            last_raw_lz = raw_lz;
285
+            z_fade_factor = 1.0 - raw_lz * inverse_z_fade_height;
286
+          }
287
+          return z_fade_factor;
288
+        }
289
+        return 1.0;
290
+      }
291
+
292
+      FORCE_INLINE static void force_fade_recalc() { last_raw_lz = -999.999; }
293
+
294
+      FORCE_INLINE static void set_z_fade_height(const float &zfh) {
295
+        z_fade_height = zfh > 0 ? zfh : 0;
296
+        inverse_z_fade_height = RECIPROCAL(z_fade_height);
297
+        force_fade_recalc();
298
+      }
299
+
300
+      FORCE_INLINE static bool leveling_active_at_z(const float &lz) {
301
+        return !z_fade_height || RAW_Z_POSITION(lz) < z_fade_height;
302
+      }
303
+
304
+    #else
305
+
306
+      FORCE_INLINE static float fade_scaling_factor_for_z(const float &lz) {
307
+        UNUSED(lz);
308
+        return 1.0;
309
+      }
310
+
311
+      FORCE_INLINE static bool leveling_active_at_z(const float &lz) { return true; }
312
+
313
+    #endif
314
+
266 315
     #if PLANNER_LEVELING
267 316
 
268 317
       #define ARG_X float lx

+ 1
- 1
Marlin/src/module/probe.cpp Parādīt failu

@@ -679,7 +679,7 @@ void refresh_zprobe_zoffset(const bool no_babystep/*=false*/) {
679 679
     #endif
680 680
 
681 681
     #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
682
-      if (!no_babystep && leveling_is_active())
682
+      if (!no_babystep && planner.leveling_active)
683 683
         thermalManager.babystep_axis(Z_AXIS, -LROUND(diff * planner.axis_steps_per_mm[Z_AXIS]));
684 684
     #else
685 685
       UNUSED(no_babystep);

+ 2
- 1
Marlin/src/module/temperature.cpp Parādīt failu

@@ -2059,7 +2059,8 @@ void Temperature::isr() {
2059 2059
   } // temp_count >= OVERSAMPLENR
2060 2060
 
2061 2061
   // Go to the next state, up to SensorsReady
2062
-  adc_sensor_state = (ADCSensorState)((int(adc_sensor_state) + 1) % int(StartupDelay));
2062
+  adc_sensor_state = (ADCSensorState)(int(adc_sensor_state) + 1);
2063
+  if (adc_sensor_state > SensorsReady) adc_sensor_state = (ADCSensorState)0;
2063 2064
 
2064 2065
   #if ENABLED(BABYSTEPPING)
2065 2066
     LOOP_XYZ(axis) {

+ 8
- 8
Marlin/src/module/tool_change.cpp Parādīt failu

@@ -295,13 +295,13 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
295 295
                                     + (tmp_extruder == 0 ? -(PARKING_EXTRUDER_GRAB_DISTANCE) : PARKING_EXTRUDER_GRAB_DISTANCE);
296 296
               /**
297 297
                *  Steps:
298
-               *    1. raise Z-Axis to have enough clearance
299
-               *    2. move to park poition of old extruder
300
-               *    3. disengage magnetc field, wait for delay
301
-               *    4. move near new extruder
302
-               *    5. engage magnetic field for new extruder
303
-               *    6. move to parking incl. offset of new extruder
304
-               *    7. lower Z-Axis
298
+               *    1. Raise Z-Axis to give enough clearance
299
+               *    2. Move to park position of old extruder
300
+               *    3. Disengage magnetic field, wait for delay
301
+               *    4. Move near new extruder
302
+               *    5. Engage magnetic field for new extruder
303
+               *    6. Move to parking incl. offset of new extruder
304
+               *    7. Lower Z-Axis
305 305
                */
306 306
 
307 307
               // STEP 1
@@ -464,7 +464,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
464 464
 
465 465
             #if ENABLED(MESH_BED_LEVELING)
466 466
 
467
-              if (leveling_is_active()) {
467
+              if (planner.leveling_active) {
468 468
                 #if ENABLED(DEBUG_LEVELING_FEATURE)
469 469
                   if (DEBUGGING(LEVELING)) SERIAL_ECHOPAIR("Z before MBL: ", current_position[Z_AXIS]);
470 470
                 #endif

Notiek ielāde…
Atcelt
Saglabāt