Quellcode durchsuchen

Fix ABL G29 early BLTouch deploy

Scott Lahteine vor 5 Jahren
Ursprung
Commit
fac3a7d147
1 geänderte Dateien mit 27 neuen und 69 gelöschten Zeilen
  1. 27
    69
      Marlin/src/gcode/bedlevel/abl/G29.cpp

+ 27
- 69
Marlin/src/gcode/bedlevel/abl/G29.cpp Datei anzeigen

@@ -78,11 +78,7 @@
78 78
   #endif
79 79
 #endif
80 80
 
81
-#if ENABLED(G29_RETRY_AND_RECOVER)
82
-  #define G29_RETURN(b) return b;
83
-#else
84
-  #define G29_RETURN(b) return;
85
-#endif
81
+#define G29_RETURN(b) return TERN_(G29_RETRY_AND_RECOVER, b)
86 82
 
87 83
 /**
88 84
  * G29: Detailed Z probe, probes the bed at 3 or more points.
@@ -164,11 +160,7 @@
164 160
  */
165 161
 G29_TYPE GcodeSuite::G29() {
166 162
 
167
-  #if EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY)
168
-    const bool seenQ = parser.seen('Q');
169
-  #else
170
-    constexpr bool seenQ = false;
171
-  #endif
163
+  const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen('Q');
172 164
 
173 165
   // G29 Q is also available if debugging
174 166
   #if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -179,25 +171,12 @@ G29_TYPE GcodeSuite::G29() {
179 171
       log_machine_info();
180 172
     }
181 173
     marlin_debug_flags = old_debug_flags;
182
-    #if DISABLED(PROBE_MANUALLY)
183
-      if (seenQ) G29_RETURN(false);
184
-    #endif
174
+    if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false);
185 175
   #endif
186 176
 
187
-  #if ENABLED(PROBE_MANUALLY)
188
-    const bool seenA = parser.seen('A');
189
-  #else
190
-    constexpr bool seenA = false;
191
-  #endif
192
-
193
-  const bool  no_action = seenA || seenQ,
194
-              faux =
195
-                #if ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY)
196
-                  parser.boolval('C')
197
-                #else
198
-                  no_action
199
-                #endif
200
-              ;
177
+  const bool seenA = TERN0(PROBE_MANUALLY, parser.seen('A')),
178
+         no_action = seenA || seenQ,
179
+              faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action;
201 180
 
202 181
   // Don't allow auto-leveling without homing first
203 182
   if (axis_unhomed_error()) G29_RETURN(false);
@@ -208,11 +187,7 @@ G29_TYPE GcodeSuite::G29() {
208 187
   }
209 188
 
210 189
   // Define local vars 'static' for manual probing, 'auto' otherwise
211
-  #if ENABLED(PROBE_MANUALLY)
212
-    #define ABL_VAR static
213
-  #else
214
-    #define ABL_VAR
215
-  #endif
190
+  #define ABL_VAR TERN_(PROBE_MANUALLY, static)
216 191
 
217 192
   ABL_VAR int verbose_level;
218 193
   ABL_VAR xy_pos_t probePos;
@@ -346,11 +321,7 @@ G29_TYPE GcodeSuite::G29() {
346 321
       G29_RETURN(false);
347 322
     }
348 323
 
349
-    dryrun = parser.boolval('D')
350
-      #if ENABLED(PROBE_MANUALLY)
351
-        || no_action
352
-      #endif
353
-    ;
324
+    dryrun = parser.boolval('D') || TERN0(PROBE_MANUALLY, no_action);
354 325
 
355 326
     #if ENABLED(AUTO_BED_LEVELING_LINEAR)
356 327
 
@@ -430,26 +401,27 @@ G29_TYPE GcodeSuite::G29() {
430 401
 
431 402
     planner.synchronize();
432 403
 
404
+    if (!faux) remember_feedrate_scaling_off();
405
+
433 406
     // Disable auto bed leveling during G29.
434 407
     // Be formal so G29 can be done successively without G28.
435 408
     if (!no_action) set_bed_leveling_enabled(false);
436 409
 
410
+    // Deploy certain probes before starting probing
437 411
     #if HAS_BED_PROBE
438
-      // Deploy the probe. Probe will raise if needed.
439
-      if (probe.deploy()) {
412
+      if (ENABLED(BLTOUCH))
413
+        do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
414
+      else if (probe.deploy()) {
440 415
         set_bed_leveling_enabled(abl_should_enable);
441 416
         G29_RETURN(false);
442 417
       }
443 418
     #endif
444 419
 
445
-    if (!faux) remember_feedrate_scaling_off();
446
-
447 420
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
448 421
 
449
-      #if ENABLED(PROBE_MANUALLY)
450
-        if (!no_action)
451
-      #endif
452
-      if (gridSpacing != bilinear_grid_spacing || probe_position_lf != bilinear_start) {
422
+      if (TERN_(PROBE_MANUALLY, !no_action)
423
+        && (gridSpacing != bilinear_grid_spacing || probe_position_lf != bilinear_start)
424
+      ) {
453 425
         // Reset grid to 0.0 or "not probed". (Also disables ABL)
454 426
         reset_bed_level();
455 427
 
@@ -560,8 +532,7 @@ G29_TYPE GcodeSuite::G29() {
560 532
         PR_INNER_VAR = abl_probe_index - (PR_OUTER_VAR * PR_INNER_END);
561 533
 
562 534
         // Probe in reverse order for every other row/column
563
-        bool zig = (PR_OUTER_VAR & 1); // != ((PR_OUTER_END) & 1);
564
-
535
+        const bool zig = (PR_OUTER_VAR & 1); // != ((PR_OUTER_END) & 1);
565 536
         if (zig) PR_INNER_VAR = (PR_INNER_END - 1) - PR_INNER_VAR;
566 537
 
567 538
         probePos = probe_position_lf + gridSpacing * meshCount.asFloat();
@@ -576,19 +547,14 @@ G29_TYPE GcodeSuite::G29() {
576 547
       // Is there a next point to move to?
577 548
       if (abl_probe_index < abl_points) {
578 549
         _manual_goto_xy(probePos); // Can be used here too!
579
-        #if HAS_SOFTWARE_ENDSTOPS
580
-          // Disable software endstops to allow manual adjustment
581
-          // If G29 is not completed, they will not be re-enabled
582
-          soft_endstops_enabled = false;
583
-        #endif
550
+        // Disable software endstops to allow manual adjustment
551
+        // If G29 is not completed, they will not be re-enabled
552
+        TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = false);
584 553
         G29_RETURN(false);
585 554
       }
586 555
       else {
587
-
588 556
         // Leveling done! Fall through to G29 finishing code below
589
-
590 557
         SERIAL_ECHOLNPGM("Grid probing done.");
591
-
592 558
         // Re-enable software endstops, if needed
593 559
         TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state);
594 560
       }
@@ -599,11 +565,9 @@ G29_TYPE GcodeSuite::G29() {
599 565
       if (abl_probe_index < abl_points) {
600 566
         probePos = points[abl_probe_index];
601 567
         _manual_goto_xy(probePos);
602
-        #if HAS_SOFTWARE_ENDSTOPS
603
-          // Disable software endstops to allow manual adjustment
604
-          // If G29 is not completed, they will not be re-enabled
605
-          soft_endstops_enabled = false;
606
-        #endif
568
+        // Disable software endstops to allow manual adjustment
569
+        // If G29 is not completed, they will not be re-enabled
570
+        TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = false);
607 571
         G29_RETURN(false);
608 572
       }
609 573
       else {
@@ -670,10 +634,8 @@ G29_TYPE GcodeSuite::G29() {
670 634
 
671 635
           TERN_(AUTO_BED_LEVELING_LINEAR, indexIntoAB[meshCount.x][meshCount.y] = ++abl_probe_index); // 0...
672 636
 
673
-          #if IS_KINEMATIC
674
-            // Avoid probing outside the round or hexagonal area
675
-            if (!probe.can_reach(probePos)) continue;
676
-          #endif
637
+          // Avoid probing outside the round or hexagonal area
638
+          if (TERN0(IS_KINEMATIC, !probe.can_reach(probePos))) continue;
677 639
 
678 640
           if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", int(pt_index), "/", int(GRID_MAX_POINTS), ".");
679 641
           TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(GRID_MAX_POINTS)));
@@ -898,11 +860,7 @@ G29_TYPE GcodeSuite::G29() {
898 860
 
899 861
         // Unapply the offset because it is going to be immediately applied
900 862
         // and cause compensation movement in Z
901
-        #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
902
-          const float fade_scaling_factor = planner.fade_scaling_factor_for_z(current_position.z);
903
-        #else
904
-          constexpr float fade_scaling_factor = 1.0f;
905
-        #endif
863
+        const float fade_scaling_factor = TERN(ENABLE_LEVELING_FADE_HEIGHT, planner.fade_scaling_factor_for_z(current_position.z), 1);
906 864
         current_position.z -= fade_scaling_factor * bilinear_z_offset(current_position);
907 865
 
908 866
         if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(" corrected Z:", current_position.z);

Laden…
Abbrechen
Speichern