Browse Source

Merge pull request #1738 from thinkyhead/fixup_homing

Fix G29 E and M48 n
Scott Lahteine 9 years ago
parent
commit
85b67e5223
1 changed files with 34 additions and 40 deletions
  1. 34
    40
      Marlin/Marlin_main.cpp

+ 34
- 40
Marlin/Marlin_main.cpp View File

@@ -2108,8 +2108,8 @@ inline void gcode_G28() {
2108 2108
    *
2109 2109
    * Global Parameters:
2110 2110
    *
2111
-   * E/e By default G29 engages / disengages the probe for each point.
2112
-   *     Include "E" to engage and disengage the probe just once.
2111
+   * E/e By default G29 will engages the probe, test the bed, then disengage.
2112
+   *     Include "E" to engage/disengage the probe for each sample.
2113 2113
    *     There's no extra effect if you have a fixed probe.
2114 2114
    *     Usage: "G29 E" or "G29 e"
2115 2115
    *
@@ -2135,7 +2135,7 @@ inline void gcode_G28() {
2135 2135
     }
2136 2136
 
2137 2137
     bool dryrun = code_seen('D') || code_seen('d');
2138
-    bool enhanced_g29 = code_seen('E') || code_seen('e');
2138
+    bool engage_probe_for_each_reading = code_seen('E') || code_seen('e');
2139 2139
 
2140 2140
     #ifdef AUTO_BED_LEVELING_GRID
2141 2141
 
@@ -2293,16 +2293,14 @@ inline void gcode_G28() {
2293 2293
 
2294 2294
           // Enhanced G29 - Do not retract servo between probes
2295 2295
           ProbeAction act;
2296
-          if (enhanced_g29) {
2297
-            if (yProbe == front_probe_bed_position && xCount == 0)
2298
-              act = ProbeEngage;
2299
-            else if (yProbe == front_probe_bed_position + (yGridSpacing * (auto_bed_leveling_grid_points - 1)) && xCount == auto_bed_leveling_grid_points - 1)
2300
-              act = ProbeRetract;
2301
-            else
2302
-              act = ProbeStay;
2303
-          }
2304
-          else
2296
+          if (engage_probe_for_each_reading)
2305 2297
             act = ProbeEngageAndRetract;
2298
+          else if (yProbe == front_probe_bed_position && xCount == 0)
2299
+            act = ProbeEngage;
2300
+          else if (yProbe == front_probe_bed_position + (yGridSpacing * (auto_bed_leveling_grid_points - 1)) && xCount == auto_bed_leveling_grid_points - 1)
2301
+            act = ProbeRetract;
2302
+          else
2303
+            act = ProbeStay;
2306 2304
 
2307 2305
           measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level);
2308 2306
 
@@ -2384,20 +2382,17 @@ inline void gcode_G28() {
2384 2382
 
2385 2383
     #else // !AUTO_BED_LEVELING_GRID
2386 2384
 
2387
-      // Probe at 3 arbitrary points
2388
-      float z_at_pt_1, z_at_pt_2, z_at_pt_3;
2385
+      // Actions for each probe
2386
+      ProbeAction p1, p2, p3;
2387
+      if (engage_probe_for_each_reading)
2388
+        p1 = p2 = p3 = ProbeEngageAndRetract;
2389
+      else
2390
+        p1 = ProbeEngage, p2 = ProbeStay, p3 = ProbeRetract;
2389 2391
 
2390
-      if (enhanced_g29) {
2391
-        // Basic Enhanced G29
2392
-        z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, ProbeEngage, verbose_level);
2393
-        z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeStay, verbose_level);
2394
-        z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeRetract, verbose_level);
2395
-      }
2396
-      else {
2397
-        z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, ProbeEngageAndRetract, verbose_level);
2398
-        z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeEngageAndRetract, verbose_level);
2399
-        z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeEngageAndRetract, verbose_level);
2400
-      }
2392
+      // Probe at 3 arbitrary points
2393
+      float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, p1, verbose_level),
2394
+            z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, p2, verbose_level),
2395
+            z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, p3, verbose_level);
2401 2396
       clean_up_after_endstop_move();
2402 2397
       if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
2403 2398
 
@@ -2764,7 +2759,7 @@ inline void gcode_M42() {
2764 2759
    *
2765 2760
    * Usage:
2766 2761
    *   M48 <n#> <X#> <Y#> <V#> <E> <L#>
2767
-   *     n = Number of samples (4-50, default 10)
2762
+   *     P = Number of sampled points (4-50, default 10)
2768 2763
    *     X = Sample X position
2769 2764
    *     Y = Sample Y position
2770 2765
    *     V = Verbose level (0-4, default=1)
@@ -2798,10 +2793,10 @@ inline void gcode_M42() {
2798 2793
     if (verbose_level > 0)
2799 2794
       SERIAL_PROTOCOLPGM("M48 Z-Probe Repeatability test\n");
2800 2795
 
2801
-    if (code_seen('n')) {
2796
+    if (code_seen('P') || code_seen('p') || code_seen('n')) { // `n` for legacy support only - please use `P`!
2802 2797
       n_samples = code_value();
2803 2798
       if (n_samples < 4 || n_samples > 50) {
2804
-        SERIAL_PROTOCOLPGM("?Specified sample size not plausible (4-50).\n");
2799
+        SERIAL_PROTOCOLPGM("?Sample size not plausible (4-50).\n");
2805 2800
         return;
2806 2801
       }
2807 2802
     }
@@ -2818,7 +2813,7 @@ inline void gcode_M42() {
2818 2813
     if (code_seen('X') || code_seen('x')) {
2819 2814
       X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER;
2820 2815
       if (X_probe_location < X_MIN_POS || X_probe_location > X_MAX_POS) {
2821
-        SERIAL_PROTOCOLPGM("?Specified X position out of range.\n");
2816
+        SERIAL_PROTOCOLPGM("?X position out of range.\n");
2822 2817
         return;
2823 2818
       }
2824 2819
     }
@@ -2826,7 +2821,7 @@ inline void gcode_M42() {
2826 2821
     if (code_seen('Y') || code_seen('y')) {
2827 2822
       Y_probe_location = code_value() -  Y_PROBE_OFFSET_FROM_EXTRUDER;
2828 2823
       if (Y_probe_location < Y_MIN_POS || Y_probe_location > Y_MAX_POS) {
2829
-        SERIAL_PROTOCOLPGM("?Specified Y position out of range.\n");
2824
+        SERIAL_PROTOCOLPGM("?Y position out of range.\n");
2830 2825
         return;
2831 2826
       }
2832 2827
     }
@@ -2835,7 +2830,7 @@ inline void gcode_M42() {
2835 2830
       n_legs = code_value();
2836 2831
       if (n_legs == 1) n_legs = 2;
2837 2832
       if (n_legs < 0 || n_legs > 15) {
2838
-        SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausible (0-15).\n");
2833
+        SERIAL_PROTOCOLPGM("?Number of legs in movement not plausible (0-15).\n");
2839 2834
         return;
2840 2835
       }
2841 2836
     }
@@ -2858,7 +2853,7 @@ inline void gcode_M42() {
2858 2853
     // use that as a starting point for each probe.
2859 2854
     //
2860 2855
     if (verbose_level > 2)
2861
-      SERIAL_PROTOCOL("Positioning probe for the test.\n");
2856
+      SERIAL_PROTOCOL("Positioning the probe...\n");
2862 2857
 
2863 2858
     plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location,
2864 2859
         ext_position,
@@ -2907,7 +2902,7 @@ inline void gcode_M42() {
2907 2902
         //SERIAL_ECHOPAIR("starting radius: ",radius);
2908 2903
         //SERIAL_ECHOPAIR("   theta: ",theta);
2909 2904
         //SERIAL_ECHOPAIR("   direction: ",rotational_direction);
2910
-        //SERIAL_PROTOCOLLNPGM("");
2905
+        //SERIAL_EOL;
2911 2906
 
2912 2907
         float dir = rotational_direction ? 1 : -1;
2913 2908
         for (l = 0; l < n_legs - 1; l++) {
@@ -2926,7 +2921,7 @@ inline void gcode_M42() {
2926 2921
           if (verbose_level > 3) {
2927 2922
             SERIAL_ECHOPAIR("x: ", X_current);
2928 2923
             SERIAL_ECHOPAIR("y: ", Y_current);
2929
-            SERIAL_PROTOCOLLNPGM("");
2924
+            SERIAL_EOL;
2930 2925
           }
2931 2926
 
2932 2927
           do_blocking_move_to( X_current, Y_current, Z_current );
@@ -4933,14 +4928,13 @@ void process_commands() {
4933 4928
         case 665: // M665 set delta configurations L<diagonal_rod> R<delta_radius> S<segments_per_sec>
4934 4929
           gcode_M665();
4935 4930
           break;
4936
-        case 666: // M666 set delta endstop adjustment
4937
-          gcode_M666();
4938
-          break;
4939
-      #elif defined(Z_DUAL_ENDSTOPS)
4940
-        case 666: // M666 set delta endstop adjustment
4931
+      #endif
4932
+
4933
+      #if defined(DELTA) || defined(Z_DUAL_ENDSTOPS)
4934
+        case 666: // M666 set delta / dual endstop adjustment
4941 4935
           gcode_M666();
4942 4936
           break;
4943
-      #endif // DELTA
4937
+      #endif
4944 4938
 
4945 4939
       #ifdef FWRETRACT
4946 4940
         case 207: //M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop]

Loading…
Cancel
Save