Selaa lähdekoodia

Allow no raise after run_z_probe in probe_pt

Scott Lahteine 7 vuotta sitten
vanhempi
commit
c352954882

+ 5
- 5
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Näytä tiedosto

@@ -750,7 +750,7 @@
750 750
           const float rawx = mesh_index_to_xpos(location.x_index),
751 751
                       rawy = mesh_index_to_ypos(location.y_index);
752 752
 
753
-          const float measured_z = probe_pt(rawx, rawy, stow_probe, g29_verbose_level); // TODO: Needs error handling
753
+          const float measured_z = probe_pt(rawx, rawy, stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
754 754
           z_values[location.x_index][location.y_index] = measured_z;
755 755
         }
756 756
         SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
@@ -1519,7 +1519,7 @@
1519 1519
       incremental_LSF_reset(&lsf_results);
1520 1520
 
1521 1521
       if (do_3_pt_leveling) {
1522
-        measured_z = probe_pt(PROBE_PT_1_X, PROBE_PT_1_Y, false, g29_verbose_level);
1522
+        measured_z = probe_pt(PROBE_PT_1_X, PROBE_PT_1_Y, PROBE_PT_RAISE, g29_verbose_level);
1523 1523
         if (isnan(measured_z))
1524 1524
           abort_flag = true;
1525 1525
         else {
@@ -1533,7 +1533,7 @@
1533 1533
         }
1534 1534
 
1535 1535
         if (!abort_flag) {
1536
-          measured_z = probe_pt(PROBE_PT_2_X, PROBE_PT_2_Y, false, g29_verbose_level);
1536
+          measured_z = probe_pt(PROBE_PT_2_X, PROBE_PT_2_Y, PROBE_PT_RAISE, g29_verbose_level);
1537 1537
           //z2 = measured_z;
1538 1538
           if (isnan(measured_z))
1539 1539
             abort_flag = true;
@@ -1548,7 +1548,7 @@
1548 1548
         }
1549 1549
 
1550 1550
         if (!abort_flag) {
1551
-          measured_z = probe_pt(PROBE_PT_3_X, PROBE_PT_3_Y, true, g29_verbose_level);
1551
+          measured_z = probe_pt(PROBE_PT_3_X, PROBE_PT_3_Y, PROBE_PT_STOW, g29_verbose_level);
1552 1552
           //z3 = measured_z;
1553 1553
           if (isnan(measured_z))
1554 1554
             abort_flag = true;
@@ -1576,7 +1576,7 @@
1576 1576
             const float ry = float(y_min) + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
1577 1577
 
1578 1578
             if (!abort_flag) {
1579
-              measured_z = probe_pt(rx, ry, parser.seen('E'), g29_verbose_level); // TODO: Needs error handling
1579
+              measured_z = probe_pt(rx, ry, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
1580 1580
 
1581 1581
               abort_flag = isnan(measured_z);
1582 1582
 

+ 3
- 3
Marlin/src/gcode/bedlevel/abl/G29.cpp Näytä tiedosto

@@ -604,7 +604,7 @@ void GcodeSuite::G29() {
604 604
 
605 605
   #else // !PROBE_MANUALLY
606 606
   {
607
-    const bool stow_probe_after_each = parser.boolval('E');
607
+    const ProbePtRaise raise_after = parser.boolval('E') ? PROBE_PT_STOW : PROBE_PT_RAISE;
608 608
 
609 609
     measured_z = 0;
610 610
 
@@ -650,7 +650,7 @@ void GcodeSuite::G29() {
650 650
             if (!position_is_reachable_by_probe(xProbe, yProbe)) continue;
651 651
           #endif
652 652
 
653
-          measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
653
+          measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, raise_after, verbose_level);
654 654
 
655 655
           if (isnan(measured_z)) {
656 656
             set_bed_leveling_enabled(abl_should_enable);
@@ -687,7 +687,7 @@ void GcodeSuite::G29() {
687 687
         // Retain the last probe position
688 688
         xProbe = points[i].x;
689 689
         yProbe = points[i].y;
690
-        measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
690
+        measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, raise_after, verbose_level);
691 691
         if (isnan(measured_z)) {
692 692
           set_bed_leveling_enabled(abl_should_enable);
693 693
           break;

+ 1
- 1
Marlin/src/gcode/calibrate/G33.cpp Näytä tiedosto

@@ -137,7 +137,7 @@ static void G33_cleanup(
137 137
 
138 138
 inline float calibration_probe(const float nx, const float ny, const bool stow) {
139 139
   #if HAS_BED_PROBE
140
-    return probe_pt(nx, ny, stow, 0, false);
140
+    return probe_pt(nx, ny, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, false);
141 141
   #else
142 142
     UNUSED(stow);
143 143
     return lcd_probe_pt(nx, ny);

+ 3
- 3
Marlin/src/gcode/calibrate/M48.cpp Näytä tiedosto

@@ -70,7 +70,7 @@ void GcodeSuite::M48() {
70 70
     return;
71 71
   }
72 72
 
73
-  const bool stow_probe_after_each = parser.boolval('E');
73
+  const ProbePtRaise raise_after = parser.boolval('E') ? PROBE_PT_STOW : PROBE_PT_RAISE;
74 74
 
75 75
   float X_current = current_position[X_AXIS],
76 76
         Y_current = current_position[Y_AXIS];
@@ -114,7 +114,7 @@ void GcodeSuite::M48() {
114 114
   double mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples];
115 115
 
116 116
   // Move to the first point, deploy, and probe
117
-  const float t = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level);
117
+  const float t = probe_pt(X_probe_location, Y_probe_location, raise_after, verbose_level);
118 118
   bool probing_good = !isnan(t);
119 119
 
120 120
   if (probing_good) {
@@ -190,7 +190,7 @@ void GcodeSuite::M48() {
190 190
       } // n_legs
191 191
 
192 192
       // Probe a single point
193
-      sample_set[n] = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, 0);
193
+      sample_set[n] = probe_pt(X_probe_location, Y_probe_location, raise_after, 0);
194 194
 
195 195
       // Break the loop if the probe fails
196 196
       probing_good = !isnan(sample_set[n]);

+ 3
- 3
Marlin/src/gcode/probe/G30.cpp Näytä tiedosto

@@ -51,8 +51,8 @@ void GcodeSuite::G30() {
51 51
 
52 52
   setup_for_endstop_or_probe_move();
53 53
 
54
-  const bool do_stow = parser.boolval('E');
55
-  const float measured_z = probe_pt(xpos, ypos, do_stow, 1);
54
+  const ProbePtRaise raise_after = parser.boolval('E') ? PROBE_PT_STOW : PROBE_PT_NONE;
55
+  const float measured_z = probe_pt(xpos, ypos, raise_after, 1);
56 56
 
57 57
   if (!isnan(measured_z)) {
58 58
     SERIAL_PROTOCOLPAIR("Bed X: ", FIXFLOAT(xpos));
@@ -62,7 +62,7 @@ void GcodeSuite::G30() {
62 62
 
63 63
   clean_up_after_endstop_or_probe_move();
64 64
 
65
-  if (do_stow) move_z_after_probing();
65
+  if (raise_after == PROBE_PT_STOW) move_z_after_probing();
66 66
 
67 67
   report_current_position();
68 68
 }

+ 7
- 5
Marlin/src/module/probe.cpp Näytä tiedosto

@@ -631,13 +631,15 @@ static float run_z_probe() {
631 631
  *   - Raise to the BETWEEN height
632 632
  * - Return the probed Z position
633 633
  */
634
-float probe_pt(const float &rx, const float &ry, const bool stow, const uint8_t verbose_level, const bool probe_relative/*=true*/) {
634
+float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) {
635 635
   #if ENABLED(DEBUG_LEVELING_FEATURE)
636 636
     if (DEBUGGING(LEVELING)) {
637 637
       SERIAL_ECHOPAIR(">>> probe_pt(", LOGICAL_X_POSITION(rx));
638 638
       SERIAL_ECHOPAIR(", ", LOGICAL_Y_POSITION(ry));
639
-      SERIAL_ECHOPAIR(", ", stow ? "" : "no ");
640
-      SERIAL_ECHOLNPGM("stow)");
639
+      SERIAL_ECHOPAIR(", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none");
640
+      SERIAL_ECHOPAIR(", ", int(verbose_level));
641
+      SERIAL_ECHOPAIR(", ", probe_relative ? "probe" : "nozzle");
642
+      SERIAL_ECHOLNPGM("_relative)");
641 643
       DEBUG_POS("", current_position);
642 644
     }
643 645
   #endif
@@ -670,9 +672,9 @@ float probe_pt(const float &rx, const float &ry, const bool stow, const uint8_t
670 672
   if (!DEPLOY_PROBE()) {
671 673
     measured_z = run_z_probe() + zprobe_zoffset;
672 674
 
673
-    if (!stow)
675
+    if (raise_after == PROBE_PT_RAISE)
674 676
       do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
675
-    else
677
+    else if (raise_after == PROBE_PT_STOW)
676 678
       if (STOW_PROBE()) measured_z = NAN;
677 679
   }
678 680
 

+ 6
- 1
Marlin/src/module/probe.h Näytä tiedosto

@@ -37,7 +37,12 @@
37 37
   #else
38 38
     inline void move_z_after_probing() {}
39 39
   #endif
40
-  float probe_pt(const float &rx, const float &ry, const bool, const uint8_t, const bool probe_relative=true);
40
+  enum ProbePtRaise : unsigned char {
41
+    PROBE_PT_NONE,  // No raise or stow after run_z_probe
42
+    PROBE_PT_STOW,  // Do a complete stow after run_z_probe
43
+    PROBE_PT_RAISE  // Raise to "between" clearance after run_z_probe
44
+  };
45
+  float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true);
41 46
   #define DEPLOY_PROBE() set_probe_deployed(true)
42 47
   #define STOW_PROBE() set_probe_deployed(false)
43 48
 #else

Loading…
Peruuta
Tallenna