@@ -2215,7 +2215,7 @@ static void clean_up_after_endstop_or_probe_move() {
2215
2215
}
2216
2216
2217
2217
/* *
2218
- * @details Used by probe_pt to do a single Z probe.
2218
+ * @details Used by probe_pt to do a single Z probe at the current position .
2219
2219
* Leaves current_position[Z_AXIS] at the height where the probe triggered.
2220
2220
*
2221
2221
* @return The raw Z position where the probe was triggered
@@ -2229,7 +2229,8 @@ static void clean_up_after_endstop_or_probe_move() {
2229
2229
// Prevent stepper_inactive_time from running out and EXTRUDER_RUNOUT_PREVENT from extruding
2230
2230
refresh_cmd_timeout ();
2231
2231
2232
- #if ENABLED(PROBE_DOUBLE_TOUCH)
2232
+ // Double-probing does a fast probe followed by a slow probe
2233
+ #if MULTIPLE_PROBING == 2
2233
2234
2234
2235
// Do a first probe at the fast speed
2235
2236
if (do_probe_move (-10 , Z_PROBE_SPEED_FAST)) return NAN;
@@ -2257,22 +2258,49 @@ static void clean_up_after_endstop_or_probe_move() {
2257
2258
}
2258
2259
#endif
2259
2260
2260
- // move down slowly to find bed
2261
- if (do_probe_move (-10 , Z_PROBE_SPEED_SLOW)) return NAN;
2262
-
2263
- #if ENABLED(DEBUG_LEVELING_FEATURE)
2264
- if (DEBUGGING (LEVELING)) DEBUG_POS (" <<< run_z_probe" , current_position);
2261
+ #if MULTIPLE_PROBING > 2
2262
+ float probes_total = 0 ;
2263
+ for (uint8_t p = MULTIPLE_PROBING + 1 ; --p;) {
2265
2264
#endif
2266
2265
2267
- // Debug: compare probe heights
2268
- #if ENABLED(PROBE_DOUBLE_TOUCH) && ENABLED(DEBUG_LEVELING_FEATURE)
2269
- if (DEBUGGING (LEVELING)) {
2270
- SERIAL_ECHOPAIR (" 2nd Probe Z:" , current_position[Z_AXIS]);
2271
- SERIAL_ECHOLNPAIR (" Discrepancy:" , first_probe_z - current_position[Z_AXIS]);
2266
+ // move down slowly to find bed
2267
+ if (do_probe_move (-10 , Z_PROBE_SPEED_SLOW)) return NAN;
2268
+
2269
+ #if MULTIPLE_PROBING > 2
2270
+ probes_total += current_position[Z_AXIS];
2271
+ if (p > 1 ) do_blocking_move_to_z (current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS (Z_PROBE_SPEED_FAST));
2272
2272
}
2273
2273
#endif
2274
2274
2275
- return current_position[Z_AXIS];
2275
+ #if MULTIPLE_PROBING > 2
2276
+
2277
+ // Return the average value of all probes
2278
+ return probes_total * (1.0 / (MULTIPLE_PROBING));
2279
+
2280
+ #elif MULTIPLE_PROBING == 2
2281
+
2282
+ const float z2 = current_position[Z_AXIS];
2283
+
2284
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
2285
+ if (DEBUGGING (LEVELING)) {
2286
+ SERIAL_ECHOPAIR (" 2nd Probe Z:" , z2);
2287
+ SERIAL_ECHOLNPAIR (" Discrepancy:" , first_probe_z - z2);
2288
+ }
2289
+ #endif
2290
+
2291
+ // Return a weighted average of the fast and slow probes
2292
+ return (z2 * 3.0 + first_probe_z * 2.0 ) * 0.2 ;
2293
+
2294
+ #else
2295
+
2296
+ // Return the single probe result
2297
+ return current_position[Z_AXIS];
2298
+
2299
+ #endif
2300
+
2301
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
2302
+ if (DEBUGGING (LEVELING)) DEBUG_POS (" <<< run_z_probe" , current_position);
2303
+ #endif
2276
2304
}
2277
2305
2278
2306
/* *
@@ -6005,7 +6033,7 @@ void home_all_axes() { gcode_G28(true); }
6005
6033
6006
6034
bool G38_pass_fail = false ;
6007
6035
6008
- #if ENABLED(PROBE_DOUBLE_TOUCH)
6036
+ #if MULTIPLE_PROBING > 1
6009
6037
// Get direction of move and retract
6010
6038
float retract_mm[XYZ];
6011
6039
LOOP_XYZ (i) {
@@ -6032,7 +6060,7 @@ void home_all_axes() { gcode_G28(true); }
6032
6060
6033
6061
G38_pass_fail = true ;
6034
6062
6035
- #if ENABLED(PROBE_DOUBLE_TOUCH)
6063
+ #if MULTIPLE_PROBING > 1
6036
6064
// Move away by the retract distance
6037
6065
set_destination_from_current ();
6038
6066
LOOP_XYZ (i) destination[i] += retract_mm[i];
0 commit comments