@@ -524,6 +524,33 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) {
524524 return !probe_triggered;
525525}
526526
527+ #if ENABLED(PROBE_TARE)
528+ /* *
529+ * @brief Tare the Z probe
530+ *
531+ * @details Signal to the probe to tare itself
532+ *
533+ * @return TRUE if the tare cold not be completed
534+ */
535+ bool Probe::tare () {
536+ #if BOTH(PROBE_ACTIVATION_SWITCH, PROBE_TARE_ONLY_WHILE_INACTIVE)
537+ if (READ (PROBE_ACTIVATION_SWITCH_PIN) == PROBE_ACTIVATION_SWITCH_STATE) {
538+ SERIAL_ECHOLNPGM (" Cannot tare an active probe" );
539+ return true ;
540+ }
541+ #endif
542+
543+ SERIAL_ECHOLNPGM (" Taring probe" );
544+ OUT_WRITE (PROBE_TARE_PIN, PROBE_TARE_STATE);
545+ delay (PROBE_TARE_TIME);
546+ OUT_WRITE (PROBE_TARE_PIN, !PROBE_TARE_STATE);
547+ delay (PROBE_TARE_DELAY);
548+
549+ endstops.hit_on_purpose ();
550+ return false ;
551+ }
552+ #endif
553+
527554/* *
528555 * @brief Probe at the current XY (possibly more than once) to find the bed Z.
529556 *
@@ -535,8 +562,11 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) {
535562float Probe::run_z_probe (const bool sanity_check/* =true*/ ) {
536563 DEBUG_SECTION (log_probe, " Probe::run_z_probe" , DEBUGGING (LEVELING));
537564
538- auto try_to_probe = [&](PGM_P const plbl, const float &z_probe_low_point, const feedRate_t fr_mm_s, const bool scheck, const float clearance) {
565+ auto try_to_probe = [&](PGM_P const plbl, const float &z_probe_low_point, const feedRate_t fr_mm_s, const bool scheck, const float clearance) -> bool {
539566 // Do a first probe at the fast speed
567+
568+ if (TERN0 (PROBE_TARE, tare ())) return true ;
569+
540570 const bool probe_fail = probe_down_to_z (z_probe_low_point, fr_mm_s), // No probe trigger?
541571 early_fail = (scheck && current_position.z > -offset.z + clearance); // Probe triggered too high?
542572 #if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -561,6 +591,8 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
561591 #if TOTAL_PROBING == 2
562592
563593 // Do a first probe at the fast speed
594+ if (TERN0 (PROBE_TARE, tare ())) return NAN;
595+
564596 if (try_to_probe (PSTR (" FAST" ), z_probe_low_point, z_probe_fast_mm_s,
565597 sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN;
566598
@@ -598,6 +630,9 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
598630 )
599631 #endif
600632 {
633+ // If the probe won't tare, return
634+ if (TERN0 (PROBE_TARE, tare ())) return true ;
635+
601636 // Probe downward slowly to find the bed
602637 if (try_to_probe (PSTR (" SLOW" ), z_probe_low_point, MMM_TO_MMS (Z_PROBE_SPEED_SLOW),
603638 sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return NAN;
0 commit comments