Bladeren bron

Simplified probe_pt function (part 1)

Scott Lahteine 9 jaren geleden
bovenliggende
commit
c376c08042
1 gewijzigde bestanden met toevoegingen van 28 en 29 verwijderingen
  1. 28
    29
      Marlin/Marlin_main.cpp

+ 28
- 29
Marlin/Marlin_main.cpp Bestand weergeven

@@ -2096,19 +2096,20 @@ static void clean_up_after_endstop_or_probe_move() {
2096 2096
     do_blocking_move_to(x, y, current_position[Z_AXIS]);
2097 2097
   }
2098 2098
 
2099
-  enum ProbeAction {
2100
-    ProbeStay          = 0,
2101
-    ProbeDeploy        = _BV(0),
2102
-    ProbeStow          = _BV(1),
2103
-    ProbeDeployAndStow = (ProbeDeploy | ProbeStow)
2104
-  };
2105
-
2106
-  // Probe bed height at position (x,y), returns the measured z value
2107
-  static float probe_pt(float x, float y, float z_raise, ProbeAction probe_action = ProbeDeployAndStow, int verbose_level = 1) {
2099
+  //
2100
+  // - Move to the given XY
2101
+  // - Deploy the probe, if not already deployed
2102
+  // - Probe the bed, get the Z position
2103
+  // - Depending on the 'stow' flag
2104
+  //   - Stow the probe, or
2105
+  //   - Raise to the BETWEEN height
2106
+  // - Return the probed Z position
2107
+  //
2108
+  static float probe_pt(float x, float y, bool stow = true, int verbose_level = 1) {
2108 2109
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2109 2110
       if (DEBUGGING(LEVELING)) {
2110 2111
         SERIAL_ECHOLNPGM("probe_pt >>>");
2111
-        SERIAL_ECHOPAIR("> ProbeAction:", probe_action);
2112
+        SERIAL_ECHOPAIR("> stow:", stow);
2112 2113
         SERIAL_EOL;
2113 2114
         DEBUG_POS("", current_position);
2114 2115
       }
@@ -2119,39 +2120,37 @@ static void clean_up_after_endstop_or_probe_move() {
2119 2120
     // Raise by z_raise, then move the Z probe to the given XY
2120 2121
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2121 2122
       if (DEBUGGING(LEVELING)) {
2122
-        SERIAL_ECHOPAIR("Z Raise by z_raise ", z_raise);
2123
-        SERIAL_EOL;
2124
-      }
2125
-    #endif
2126
-    do_probe_raise(z_raise); // this also updates current_position
2127
-
2128
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
2129
-      if (DEBUGGING(LEVELING)) {
2130
-        SERIAL_ECHOPAIR("> do_blocking_move_to_xy ", x - (X_PROBE_OFFSET_FROM_EXTRUDER));
2123
+        SERIAL_ECHOPAIR("> do_blocking_move_to ", x - (X_PROBE_OFFSET_FROM_EXTRUDER));
2131 2124
         SERIAL_ECHOPAIR(", ", y - (Y_PROBE_OFFSET_FROM_EXTRUDER));
2125
+        SERIAL_ECHOPAIR(", ", max(current_position[Z_AXIS], Z_RAISE_BETWEEN_PROBINGS));
2132 2126
         SERIAL_EOL;
2133 2127
       }
2134 2128
     #endif
2135 2129
 
2136
-    // this also updates current_position
2137 2130
     feedrate = XY_PROBE_FEEDRATE;
2138 2131
     do_blocking_move_to_xy(x - (X_PROBE_OFFSET_FROM_EXTRUDER), y - (Y_PROBE_OFFSET_FROM_EXTRUDER));
2139 2132
 
2140
-    if (probe_action & ProbeDeploy) {
2141
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
2142
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> ProbeDeploy");
2143
-      #endif
2144
-      deploy_z_probe();
2145
-    }
2133
+    #if ENABLED(DEBUG_LEVELING_FEATURE)
2134
+      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> deploy_z_probe");
2135
+    #endif
2136
+    deploy_z_probe();
2146 2137
 
2147 2138
     float measured_z = run_z_probe();
2148 2139
 
2149
-    if (probe_action & ProbeStow) {
2140
+    if (stow) {
2150 2141
       #if ENABLED(DEBUG_LEVELING_FEATURE)
2151
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> ProbeStow (stow_z_probe will do Z Raise)");
2142
+        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> stow_z_probe");
2152 2143
       #endif
2153 2144
       stow_z_probe();
2154 2145
     }
2146
+    #if Z_RAISE_BETWEEN_PROBINGS > 0
2147
+      else {
2148
+        #if ENABLED(DEBUG_LEVELING_FEATURE)
2149
+          if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> do_probe_raise");
2150
+        #endif
2151
+        do_probe_raise(Z_RAISE_BETWEEN_PROBINGS);
2152
+      }
2153
+    #endif
2155 2154
 
2156 2155
     if (verbose_level > 2) {
2157 2156
       SERIAL_PROTOCOLPGM("Bed X: ");
@@ -2172,7 +2171,7 @@ static void clean_up_after_endstop_or_probe_move() {
2172 2171
     return measured_z;
2173 2172
   }
2174 2173
 
2175
-#endif // AUTO_BED_LEVELING_FEATURE || Z_MIN_PROBE_REPEATABILITY_TEST
2174
+#endif // HAS_BED_PROBE
2176 2175
 
2177 2176
 #if ENABLED(AUTO_BED_LEVELING_FEATURE)
2178 2177
 

Laden…
Annuleren
Opslaan