Bladeren bron

Eliminate goto in gcode_G33

Scott Lahteine 7 jaren geleden
bovenliggende
commit
75e6ead5fd
1 gewijzigde bestanden met toevoegingen van 26 en 17 verwijderingen
  1. 26
    17
      Marlin/Marlin_main.cpp

+ 26
- 17
Marlin/Marlin_main.cpp Bestand weergeven

@@ -5355,6 +5355,21 @@ void home_all_axes() { gcode_G28(true); }
5355 5355
       }
5356 5356
     }
5357 5357
 
5358
+    void G33_cleanup(
5359
+      #if HOTENDS > 1
5360
+        const uint8_t old_tool_index
5361
+      #endif
5362
+    ) {
5363
+      #if ENABLED(DELTA_HOME_TO_SAFE_ZONE)
5364
+        do_blocking_move_to_z(delta_clip_start_height);
5365
+      #endif
5366
+      STOW_PROBE();
5367
+      clean_up_after_endstop_or_probe_move();
5368
+      #if HOTENDS > 1
5369
+        tool_change(old_tool_index, 0, true);
5370
+      #endif
5371
+    }
5372
+
5358 5373
     inline void gcode_G33() {
5359 5374
 
5360 5375
       const int8_t probe_points = parser.intval('P', DELTA_CALIBRATION_DEFAULT_POINTS);
@@ -5431,10 +5446,15 @@ void home_all_axes() { gcode_G28(true); }
5431 5446
       #if HAS_LEVELING
5432 5447
         reset_bed_level(); // After calibration bed-level data is no longer valid
5433 5448
       #endif
5449
+
5434 5450
       #if HOTENDS > 1
5435 5451
         const uint8_t old_tool_index = active_extruder;
5436 5452
         tool_change(0, 0, true);
5453
+        #define G33_CLEANUP() G33_cleanup(old_tool_index)
5454
+      #else
5455
+        #define G33_CLEANUP() G33_cleanup()
5437 5456
       #endif
5457
+
5438 5458
       setup_for_endstop_or_probe_move();
5439 5459
       endstops.enable(true);
5440 5460
       if (!home_delta())
@@ -5453,10 +5473,8 @@ void home_all_axes() { gcode_G28(true); }
5453 5473
 
5454 5474
       #if DISABLED(PROBE_MANUALLY)
5455 5475
         const float measured_z = probe_pt(dx, dy, stow_after_each, 1, false); // 1st probe to set height
5456
-        if (nan_error(measured_z))
5457
-          goto FAIL;
5458
-        else
5459
-          home_offset[Z_AXIS] -= measured_z;
5476
+        if (isnan(measured_z)) return G33_CLEANUP();
5477
+        home_offset[Z_AXIS] -= measured_z;
5460 5478
       #endif
5461 5479
 
5462 5480
       do {
@@ -5474,7 +5492,7 @@ void home_all_axes() { gcode_G28(true); }
5474 5492
             z_at_pt[0] += lcd_probe_pt(0, 0);
5475 5493
           #else
5476 5494
             z_at_pt[0] += probe_pt(dx, dy, stow_after_each, 1, false);
5477
-            if (nan_error(z_at_pt[0])) goto FAIL;
5495
+            if (isnan(z_at_pt[0])) return G33_CLEANUP();
5478 5496
           #endif
5479 5497
         }
5480 5498
         if (_7p_calibration) { // probe extra center points
@@ -5484,7 +5502,7 @@ void home_all_axes() { gcode_G28(true); }
5484 5502
               z_at_pt[0] += lcd_probe_pt(cos(a) * r, sin(a) * r);
5485 5503
             #else
5486 5504
               z_at_pt[0] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
5487
-              if (nan_error(z_at_pt[0])) goto FAIL;
5505
+              if (isnan(z_at_pt[0])) return G33_CLEANUP();
5488 5506
             #endif
5489 5507
           }
5490 5508
           z_at_pt[0] /= float(_7p_double_circle ? 7 : probe_points);
@@ -5505,7 +5523,7 @@ void home_all_axes() { gcode_G28(true); }
5505 5523
                 z_at_pt[axis] += lcd_probe_pt(cos(a) * r, sin(a) * r);
5506 5524
               #else
5507 5525
                 z_at_pt[axis] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
5508
-                if (nan_error(z_at_pt[axis])) goto FAIL;
5526
+                if (isnan(z_at_pt[axis])) return G33_CLEANUP();
5509 5527
               #endif
5510 5528
             }
5511 5529
             zig_zag = !zig_zag;
@@ -5705,16 +5723,7 @@ void home_all_axes() { gcode_G28(true); }
5705 5723
       }
5706 5724
       while ((zero_std_dev < test_precision && zero_std_dev > calibration_precision && iterations < 31) || iterations <= force_iterations);
5707 5725
 
5708
-      FAIL:
5709
-
5710
-      #if ENABLED(DELTA_HOME_TO_SAFE_ZONE)
5711
-        do_blocking_move_to_z(delta_clip_start_height);
5712
-      #endif
5713
-      STOW_PROBE();
5714
-      clean_up_after_endstop_or_probe_move();
5715
-      #if HOTENDS > 1
5716
-        tool_change(old_tool_index, 0, true);
5717
-      #endif
5726
+      G33_CLEANUP();
5718 5727
     }
5719 5728
 
5720 5729
   #endif // DELTA_AUTO_CALIBRATION

Laden…
Annuleren
Opslaan