Преглед изворни кода

Eliminate goto in gcode_G33

Scott Lahteine пре 8 година
родитељ
комит
75e6ead5fd
1 измењених фајлова са 26 додато и 17 уклоњено
  1. 26
    17
      Marlin/Marlin_main.cpp

+ 26
- 17
Marlin/Marlin_main.cpp Прегледај датотеку

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
     inline void gcode_G33() {
5373
     inline void gcode_G33() {
5359
 
5374
 
5360
       const int8_t probe_points = parser.intval('P', DELTA_CALIBRATION_DEFAULT_POINTS);
5375
       const int8_t probe_points = parser.intval('P', DELTA_CALIBRATION_DEFAULT_POINTS);
5431
       #if HAS_LEVELING
5446
       #if HAS_LEVELING
5432
         reset_bed_level(); // After calibration bed-level data is no longer valid
5447
         reset_bed_level(); // After calibration bed-level data is no longer valid
5433
       #endif
5448
       #endif
5449
+
5434
       #if HOTENDS > 1
5450
       #if HOTENDS > 1
5435
         const uint8_t old_tool_index = active_extruder;
5451
         const uint8_t old_tool_index = active_extruder;
5436
         tool_change(0, 0, true);
5452
         tool_change(0, 0, true);
5453
+        #define G33_CLEANUP() G33_cleanup(old_tool_index)
5454
+      #else
5455
+        #define G33_CLEANUP() G33_cleanup()
5437
       #endif
5456
       #endif
5457
+
5438
       setup_for_endstop_or_probe_move();
5458
       setup_for_endstop_or_probe_move();
5439
       endstops.enable(true);
5459
       endstops.enable(true);
5440
       if (!home_delta())
5460
       if (!home_delta())
5453
 
5473
 
5454
       #if DISABLED(PROBE_MANUALLY)
5474
       #if DISABLED(PROBE_MANUALLY)
5455
         const float measured_z = probe_pt(dx, dy, stow_after_each, 1, false); // 1st probe to set height
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
       #endif
5478
       #endif
5461
 
5479
 
5462
       do {
5480
       do {
5474
             z_at_pt[0] += lcd_probe_pt(0, 0);
5492
             z_at_pt[0] += lcd_probe_pt(0, 0);
5475
           #else
5493
           #else
5476
             z_at_pt[0] += probe_pt(dx, dy, stow_after_each, 1, false);
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
           #endif
5496
           #endif
5479
         }
5497
         }
5480
         if (_7p_calibration) { // probe extra center points
5498
         if (_7p_calibration) { // probe extra center points
5484
               z_at_pt[0] += lcd_probe_pt(cos(a) * r, sin(a) * r);
5502
               z_at_pt[0] += lcd_probe_pt(cos(a) * r, sin(a) * r);
5485
             #else
5503
             #else
5486
               z_at_pt[0] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
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
             #endif
5506
             #endif
5489
           }
5507
           }
5490
           z_at_pt[0] /= float(_7p_double_circle ? 7 : probe_points);
5508
           z_at_pt[0] /= float(_7p_double_circle ? 7 : probe_points);
5505
                 z_at_pt[axis] += lcd_probe_pt(cos(a) * r, sin(a) * r);
5523
                 z_at_pt[axis] += lcd_probe_pt(cos(a) * r, sin(a) * r);
5506
               #else
5524
               #else
5507
                 z_at_pt[axis] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
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
               #endif
5527
               #endif
5510
             }
5528
             }
5511
             zig_zag = !zig_zag;
5529
             zig_zag = !zig_zag;
5705
       }
5723
       }
5706
       while ((zero_std_dev < test_precision && zero_std_dev > calibration_precision && iterations < 31) || iterations <= force_iterations);
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
   #endif // DELTA_AUTO_CALIBRATION
5729
   #endif // DELTA_AUTO_CALIBRATION

Loading…
Откажи
Сачувај