From f583d933ebe96d3d6048fade2ac15c9962ec254d Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 5 Dec 2020 17:25:28 -0500 Subject: [PATCH] Tweaks following PR thread --- Marlin/Configuration.h | 16 ++++++++-------- Marlin/src/module/endstops.cpp | 12 ++++++------ Marlin/src/module/motion.cpp | 5 +++-- Marlin/src/module/probe.cpp | 18 +++++++++--------- Marlin/src/module/probe.h | 2 +- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index af8fd4f0e2..96264ee5a1 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -997,24 +997,24 @@ #define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2) // For probes that require an explicit enable input such as feedback an arm is deployed or an opto switch reporting in-range -//#define PROBE_NEEDS_ENABLE -#if ENABLED(PROBE_NEEDS_ENABLE) - #define PROBE_NEEDS_ENABLE_STATE LOW +//#define PROBE_ENABLED_INPUT +#if ENABLED(PROBE_ENABLED_INPUT) + #define PROBE_ENABLED_INPUT_STATE LOW + //#define PROBE_ENABLE_PIN PC6 // Override default probe enable pin #endif -//#define PROBE_ENABLE_PIN PC6 // Override default probe enable pin // Probe requires Tare - Usefull for Strain guage or Piezo type probes which may see force from cabling or bowden tubes following moves -//#define PROBE_NEEDS_TARE -#if ENABLED(PROBE_NEEDS_TARE) +//#define PROBE_CAN_TARE +#if ENABLED(PROBE_CAN_TARE) #define PROBE_TARE_TIME 200 // Time to hold tare pin #define PROBE_TARE_DELAY 200 // Dwell following tare before continuing #define PROBE_TARE_STATE HIGH // State to write pin for tare //#define PROBE_TARE_PIN PA5 // Override default Tare pin - #if ENABLED(PROBE_NEEDS_ENABLE) + #if ENABLED(PROBE_ENABLED_INPUT) // Assume probe enable will come on in a Z window rather than detecting probe deployment. // Useful when TARE can be assured outside enable range to avoid potential crash situations. // Prevents tare unless enable switch is off - //#define PROBE_ENABLE_WINDOW + //#define PROBE_TARE_WHILE_INACTIVE #endif #endif diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index feabaaae0e..a82c357863 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -284,7 +284,7 @@ void Endstops::init() { SET_INPUT(PROBE_ENABLE_PIN) #endif - #if ENABLED(PROBE_NEEDS_TARE) + #if ENABLED(PROBE_CAN_TARE probe.tare_z_probe(); #endif @@ -590,7 +590,7 @@ void Endstops::update() { #endif #endif - #if HAS_Z_MIN && !Z_SPI_SENSORLESS && DISABLED(PROBE_NEEDS_ENABLE) + #if HAS_Z_MIN && !Z_SPI_SENSORLESS && DISABLED(PROBE_ENABLED_INPUTT) UPDATE_ENDSTOP_BIT(Z, MIN); #if ENABLED(Z_MULTI_ENDSTOPS) #if HAS_Z2_MIN @@ -616,16 +616,16 @@ void Endstops::update() { #endif // When closing the gap check the enabled probe - #if HAS_CUSTOM_PROBE_PIN && DISABLED(PROBE_NEEDS_ENABLE) + #if HAS_CUSTOM_PROBE_PIN && DISABLED(PROBE_ENABLED_INPUTT) UPDATE_ENDSTOP_BIT(Z, MIN_PROBE); #endif - #if ENABLED(PROBE_NEEDS_ENABLE) + #if ENABLED(PROBE_ENABLED_INPUTT) #if HAS_CUSTOM_PROBE_PIN UPDATE_ENDSTOP_BIT(Z, MIN); - SET_BIT_TO(live_state, _ENDSTOP(Z, MIN), ((READ(_ENDSTOP_PIN(Z, MIN)) != _ENDSTOP_INVERTING(Z, MIN_PROBE) && (READ(PROBE_ENABLE_PIN) == PROBE_NEEDS_ENABLE_STATE)))); + SET_BIT_TO(live_state, _ENDSTOP(Z, MIN), ((READ(_ENDSTOP_PIN(Z, MIN)) != _ENDSTOP_INVERTING(Z, MIN_PROBE) && (READ(PROBE_ENABLE_PIN) == PROBE_ENABLED_INPUTT_STATE)))); #else - SET_BIT_TO(live_state, _ENDSTOP(Z, MIN), ((READ(_ENDSTOP_PIN(Z, MIN)) != _ENDSTOP_INVERTING(Z, MIN) && (READ(PROBE_ENABLE_PIN) == PROBE_NEEDS_ENABLE_STATE)))); + SET_BIT_TO(live_state, _ENDSTOP(Z, MIN), ((READ(_ENDSTOP_PIN(Z, MIN)) != _ENDSTOP_INVERTING(Z, MIN) && (READ(PROBE_ENABLE_PIN) == PROBE_ENABLED_INPUTT_STATE)))); #endif #endif diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 3039f07f8c..3bbff515a9 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1603,8 +1603,9 @@ void homeaxis(const AxisEnum axis) { if (axis == Z_AXIS && bltouch.deploy()) return; // The initial DEPLOY #endif - #if ENABLED(PROBE_NEEDS_TARE) - if (probe.tare_z_probe()) return; + #if ENABLED(PROBE_CAN_TARE + if(axis == Z_AXIS) + if (probe.tare_z_probe()) return; #endif #if DISABLED(DELTA) && defined(SENSORLESS_BACKOFF_MM) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index dd4d5fe55e..a505398f75 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -479,10 +479,10 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { return !probe_triggered; } -#if ENABLED(PROBE_NEEDS_TARE) +#if ENABLED(PROBE_CAN_TARE bool Probe::tare_z_probe() { - #if ENABLED(PROBE_ENABLE_WINDOW) - if ((READ(PROBE_ENABLE_PIN) == PROBE_NEEDS_ENABLE_STATE)) { + #if ENABLED(PROBE_TARE_WHILE_INACTIVEACTIVE) + if ((READ(PROBE_ENABLE_PIN) == PROBE_ENABLED_INPUTT_STATE)) { SERIAL_ECHOLN("Cannot tare probe, already Enabled"); return true; } @@ -513,8 +513,8 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { 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) { // Do a first probe at the fast speed - #if ENABLED(PROBE_NEEDS_TARE) - if(tare_z_probe()) return true; + #if ENABLED(PROBE_CAN_TARE + if(tare_z_probe()) return NAN; #endif const bool probe_fail = probe_down_to_z(z_probe_low_point, fr_mm_s), // No probe trigger? @@ -530,7 +530,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { #else UNUSED(plbl); #endif - return (int)(probe_fail || early_fail); + return (bool)(probe_fail || early_fail); }; // Stop the probe before it goes too low to prevent damage. @@ -541,8 +541,8 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { #if TOTAL_PROBING == 2 // Do a first probe at the fast speed - #if ENABLED(PROBE_NEEDS_TARE) - if(tare_z_probe()) return true; + #if ENABLED(PROBE_CAN_TARE + if(tare_z_probe()) return NAN; #endif if (try_to_probe(PSTR("FAST"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST), @@ -583,7 +583,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { #endif { // Probe downward slowly to find the bed - #if ENABLED(PROBE_NEEDS_TARE) + #if ENABLED(PROBE_CAN_TARE if(tare_z_probe()) return true; #endif if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW), diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index adaf61fd61..ee6ce29e2b 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -206,7 +206,7 @@ public: static void set_probing_paused(const bool p); #endif - #if ENABLED(PROBE_NEEDS_TARE) + #if ENABLED(PROBE_CAN_TARE) static bool tare_z_probe(); #endif