Browse Source

Fix G29 E and M48 n

- Users prefer `G29 E` to work like `M48 E` so fixed that
- `M48 n` replaced with `M48 P` (or `p`). `n` legacy support
- Shorten some strings to save precious bytes
- Smaller code for 3-point probing
Scott Lahteine 10 years ago
parent
commit
803425e12c
1 changed files with 27 additions and 33 deletions
  1. 27
    33
      Marlin/Marlin_main.cpp

+ 27
- 33
Marlin/Marlin_main.cpp View File

2108
    *
2108
    *
2109
    * Global Parameters:
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
    *     There's no extra effect if you have a fixed probe.
2113
    *     There's no extra effect if you have a fixed probe.
2114
    *     Usage: "G29 E" or "G29 e"
2114
    *     Usage: "G29 E" or "G29 e"
2115
    *
2115
    *
2135
     }
2135
     }
2136
 
2136
 
2137
     bool dryrun = code_seen('D') || code_seen('d');
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
     #ifdef AUTO_BED_LEVELING_GRID
2140
     #ifdef AUTO_BED_LEVELING_GRID
2141
 
2141
 
2293
 
2293
 
2294
           // Enhanced G29 - Do not retract servo between probes
2294
           // Enhanced G29 - Do not retract servo between probes
2295
           ProbeAction act;
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
             act = ProbeEngageAndRetract;
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
           measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level);
2305
           measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level);
2308
 
2306
 
2386
 
2384
 
2387
       // Probe at 3 arbitrary points
2385
       // Probe at 3 arbitrary points
2388
       float z_at_pt_1, z_at_pt_2, z_at_pt_3;
2386
       float z_at_pt_1, z_at_pt_2, z_at_pt_3;
2389
-
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
-      }
2387
+      ProbeAction p1, p2, p3;
2388
+      if (engage_probe_for_each_reading)
2389
+        p1 = p2 = p3 = ProbeEngageAndRetract;
2390
+      else
2391
+        p1 = ProbeEngage, p2 = ProbeStay, p3 = ProbeRetract;
2392
+      z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, p1, 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, p2, 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, p3, verbose_level);
2401
       clean_up_after_endstop_move();
2395
       clean_up_after_endstop_move();
2402
       if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
2396
       if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
2403
 
2397
 
2764
    *
2758
    *
2765
    * Usage:
2759
    * Usage:
2766
    *   M48 <n#> <X#> <Y#> <V#> <E> <L#>
2760
    *   M48 <n#> <X#> <Y#> <V#> <E> <L#>
2767
-   *     n = Number of samples (4-50, default 10)
2761
+   *     P = Number of sampled points (4-50, default 10)
2768
    *     X = Sample X position
2762
    *     X = Sample X position
2769
    *     Y = Sample Y position
2763
    *     Y = Sample Y position
2770
    *     V = Verbose level (0-4, default=1)
2764
    *     V = Verbose level (0-4, default=1)
2798
     if (verbose_level > 0)
2792
     if (verbose_level > 0)
2799
       SERIAL_PROTOCOLPGM("M48 Z-Probe Repeatability test\n");
2793
       SERIAL_PROTOCOLPGM("M48 Z-Probe Repeatability test\n");
2800
 
2794
 
2801
-    if (code_seen('n')) {
2795
+    if (code_seen('P') || code_seen('p') || code_seen('n')) { // `n` for legacy support only - please use `P`!
2802
       n_samples = code_value();
2796
       n_samples = code_value();
2803
       if (n_samples < 4 || n_samples > 50) {
2797
       if (n_samples < 4 || n_samples > 50) {
2804
-        SERIAL_PROTOCOLPGM("?Specified sample size not plausible (4-50).\n");
2798
+        SERIAL_PROTOCOLPGM("?Sample size not plausible (4-50).\n");
2805
         return;
2799
         return;
2806
       }
2800
       }
2807
     }
2801
     }
2818
     if (code_seen('X') || code_seen('x')) {
2812
     if (code_seen('X') || code_seen('x')) {
2819
       X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER;
2813
       X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER;
2820
       if (X_probe_location < X_MIN_POS || X_probe_location > X_MAX_POS) {
2814
       if (X_probe_location < X_MIN_POS || X_probe_location > X_MAX_POS) {
2821
-        SERIAL_PROTOCOLPGM("?Specified X position out of range.\n");
2815
+        SERIAL_PROTOCOLPGM("?X position out of range.\n");
2822
         return;
2816
         return;
2823
       }
2817
       }
2824
     }
2818
     }
2826
     if (code_seen('Y') || code_seen('y')) {
2820
     if (code_seen('Y') || code_seen('y')) {
2827
       Y_probe_location = code_value() -  Y_PROBE_OFFSET_FROM_EXTRUDER;
2821
       Y_probe_location = code_value() -  Y_PROBE_OFFSET_FROM_EXTRUDER;
2828
       if (Y_probe_location < Y_MIN_POS || Y_probe_location > Y_MAX_POS) {
2822
       if (Y_probe_location < Y_MIN_POS || Y_probe_location > Y_MAX_POS) {
2829
-        SERIAL_PROTOCOLPGM("?Specified Y position out of range.\n");
2823
+        SERIAL_PROTOCOLPGM("?Y position out of range.\n");
2830
         return;
2824
         return;
2831
       }
2825
       }
2832
     }
2826
     }
2835
       n_legs = code_value();
2829
       n_legs = code_value();
2836
       if (n_legs == 1) n_legs = 2;
2830
       if (n_legs == 1) n_legs = 2;
2837
       if (n_legs < 0 || n_legs > 15) {
2831
       if (n_legs < 0 || n_legs > 15) {
2838
-        SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausible (0-15).\n");
2832
+        SERIAL_PROTOCOLPGM("?Number of legs in movement not plausible (0-15).\n");
2839
         return;
2833
         return;
2840
       }
2834
       }
2841
     }
2835
     }
2858
     // use that as a starting point for each probe.
2852
     // use that as a starting point for each probe.
2859
     //
2853
     //
2860
     if (verbose_level > 2)
2854
     if (verbose_level > 2)
2861
-      SERIAL_PROTOCOL("Positioning probe for the test.\n");
2855
+      SERIAL_PROTOCOL("Positioning the probe...\n");
2862
 
2856
 
2863
     plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location,
2857
     plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location,
2864
         ext_position,
2858
         ext_position,
2907
         //SERIAL_ECHOPAIR("starting radius: ",radius);
2901
         //SERIAL_ECHOPAIR("starting radius: ",radius);
2908
         //SERIAL_ECHOPAIR("   theta: ",theta);
2902
         //SERIAL_ECHOPAIR("   theta: ",theta);
2909
         //SERIAL_ECHOPAIR("   direction: ",rotational_direction);
2903
         //SERIAL_ECHOPAIR("   direction: ",rotational_direction);
2910
-        //SERIAL_PROTOCOLLNPGM("");
2904
+        //SERIAL_EOL;
2911
 
2905
 
2912
         float dir = rotational_direction ? 1 : -1;
2906
         float dir = rotational_direction ? 1 : -1;
2913
         for (l = 0; l < n_legs - 1; l++) {
2907
         for (l = 0; l < n_legs - 1; l++) {
2926
           if (verbose_level > 3) {
2920
           if (verbose_level > 3) {
2927
             SERIAL_ECHOPAIR("x: ", X_current);
2921
             SERIAL_ECHOPAIR("x: ", X_current);
2928
             SERIAL_ECHOPAIR("y: ", Y_current);
2922
             SERIAL_ECHOPAIR("y: ", Y_current);
2929
-            SERIAL_PROTOCOLLNPGM("");
2923
+            SERIAL_EOL;
2930
           }
2924
           }
2931
 
2925
 
2932
           do_blocking_move_to( X_current, Y_current, Z_current );
2926
           do_blocking_move_to( X_current, Y_current, Z_current );

Loading…
Cancel
Save