瀏覽代碼

Fix ABL G29 early BLTouch deploy

Scott Lahteine 5 年之前
父節點
當前提交
fac3a7d147
共有 1 個文件被更改,包括 27 次插入69 次删除
  1. 27
    69
      Marlin/src/gcode/bedlevel/abl/G29.cpp

+ 27
- 69
Marlin/src/gcode/bedlevel/abl/G29.cpp 查看文件

78
   #endif
78
   #endif
79
 #endif
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
  * G29: Detailed Z probe, probes the bed at 3 or more points.
84
  * G29: Detailed Z probe, probes the bed at 3 or more points.
164
  */
160
  */
165
 G29_TYPE GcodeSuite::G29() {
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
   // G29 Q is also available if debugging
165
   // G29 Q is also available if debugging
174
   #if ENABLED(DEBUG_LEVELING_FEATURE)
166
   #if ENABLED(DEBUG_LEVELING_FEATURE)
179
       log_machine_info();
171
       log_machine_info();
180
     }
172
     }
181
     marlin_debug_flags = old_debug_flags;
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
   #endif
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
   // Don't allow auto-leveling without homing first
181
   // Don't allow auto-leveling without homing first
203
   if (axis_unhomed_error()) G29_RETURN(false);
182
   if (axis_unhomed_error()) G29_RETURN(false);
208
   }
187
   }
209
 
188
 
210
   // Define local vars 'static' for manual probing, 'auto' otherwise
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
   ABL_VAR int verbose_level;
192
   ABL_VAR int verbose_level;
218
   ABL_VAR xy_pos_t probePos;
193
   ABL_VAR xy_pos_t probePos;
346
       G29_RETURN(false);
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
     #if ENABLED(AUTO_BED_LEVELING_LINEAR)
326
     #if ENABLED(AUTO_BED_LEVELING_LINEAR)
356
 
327
 
430
 
401
 
431
     planner.synchronize();
402
     planner.synchronize();
432
 
403
 
404
+    if (!faux) remember_feedrate_scaling_off();
405
+
433
     // Disable auto bed leveling during G29.
406
     // Disable auto bed leveling during G29.
434
     // Be formal so G29 can be done successively without G28.
407
     // Be formal so G29 can be done successively without G28.
435
     if (!no_action) set_bed_leveling_enabled(false);
408
     if (!no_action) set_bed_leveling_enabled(false);
436
 
409
 
410
+    // Deploy certain probes before starting probing
437
     #if HAS_BED_PROBE
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
         set_bed_leveling_enabled(abl_should_enable);
415
         set_bed_leveling_enabled(abl_should_enable);
441
         G29_RETURN(false);
416
         G29_RETURN(false);
442
       }
417
       }
443
     #endif
418
     #endif
444
 
419
 
445
-    if (!faux) remember_feedrate_scaling_off();
446
-
447
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
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
         // Reset grid to 0.0 or "not probed". (Also disables ABL)
425
         // Reset grid to 0.0 or "not probed". (Also disables ABL)
454
         reset_bed_level();
426
         reset_bed_level();
455
 
427
 
560
         PR_INNER_VAR = abl_probe_index - (PR_OUTER_VAR * PR_INNER_END);
532
         PR_INNER_VAR = abl_probe_index - (PR_OUTER_VAR * PR_INNER_END);
561
 
533
 
562
         // Probe in reverse order for every other row/column
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
         if (zig) PR_INNER_VAR = (PR_INNER_END - 1) - PR_INNER_VAR;
536
         if (zig) PR_INNER_VAR = (PR_INNER_END - 1) - PR_INNER_VAR;
566
 
537
 
567
         probePos = probe_position_lf + gridSpacing * meshCount.asFloat();
538
         probePos = probe_position_lf + gridSpacing * meshCount.asFloat();
576
       // Is there a next point to move to?
547
       // Is there a next point to move to?
577
       if (abl_probe_index < abl_points) {
548
       if (abl_probe_index < abl_points) {
578
         _manual_goto_xy(probePos); // Can be used here too!
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
         G29_RETURN(false);
553
         G29_RETURN(false);
585
       }
554
       }
586
       else {
555
       else {
587
-
588
         // Leveling done! Fall through to G29 finishing code below
556
         // Leveling done! Fall through to G29 finishing code below
589
-
590
         SERIAL_ECHOLNPGM("Grid probing done.");
557
         SERIAL_ECHOLNPGM("Grid probing done.");
591
-
592
         // Re-enable software endstops, if needed
558
         // Re-enable software endstops, if needed
593
         TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state);
559
         TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state);
594
       }
560
       }
599
       if (abl_probe_index < abl_points) {
565
       if (abl_probe_index < abl_points) {
600
         probePos = points[abl_probe_index];
566
         probePos = points[abl_probe_index];
601
         _manual_goto_xy(probePos);
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
         G29_RETURN(false);
571
         G29_RETURN(false);
608
       }
572
       }
609
       else {
573
       else {
670
 
634
 
671
           TERN_(AUTO_BED_LEVELING_LINEAR, indexIntoAB[meshCount.x][meshCount.y] = ++abl_probe_index); // 0...
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
           if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", int(pt_index), "/", int(GRID_MAX_POINTS), ".");
640
           if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", int(pt_index), "/", int(GRID_MAX_POINTS), ".");
679
           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)));
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
 
860
 
899
         // Unapply the offset because it is going to be immediately applied
861
         // Unapply the offset because it is going to be immediately applied
900
         // and cause compensation movement in Z
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
         current_position.z -= fade_scaling_factor * bilinear_z_offset(current_position);
864
         current_position.z -= fade_scaling_factor * bilinear_z_offset(current_position);
907
 
865
 
908
         if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(" corrected Z:", current_position.z);
866
         if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(" corrected Z:", current_position.z);

Loading…
取消
儲存