From 892e83e8723ecd395b334c554fd13faa32534e04 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 27 Dec 2020 16:23:18 -0600 Subject: [PATCH] Init tare pin once --- Marlin/src/MarlinCore.cpp | 6 +++++- Marlin/src/module/probe.cpp | 14 ++++++++++++-- Marlin/src/module/probe.h | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 0171690d4..9a3de3f1a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -193,7 +193,7 @@ #include "feature/runout.h" #endif -#if HAS_Z_SERVO_PROBE +#if EITHER(PROBE_TARE, HAS_Z_SERVO_PROBE) #include "module/probe.h" #endif @@ -1119,6 +1119,10 @@ void setup() { SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.) #endif + #if ENABLED(PROBE_TARE) + SETUP_RUN(probe.tare_init()); + #endif + #if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION) SETUP_RUN(card.mount()); // Mount media with settings before first_load #endif diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index df014bdc2..53c35d69f 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -510,6 +510,16 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { } #if ENABLED(PROBE_TARE) + + /** + * @brief Init the tare pin + * + * @details Init tare pin to ON state for a strain gauge, otherwise OFF + */ + void Probe::tare_init() { + OUT_WRITE(PROBE_TARE_PIN, !PROBE_TARE_STATE); + } + /** * @brief Tare the Z probe * @@ -526,9 +536,9 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { #endif SERIAL_ECHOLNPGM("Taring probe"); - OUT_WRITE(PROBE_TARE_PIN, PROBE_TARE_STATE); + WRITE(PROBE_TARE_PIN, PROBE_TARE_STATE); delay(PROBE_TARE_TIME); - OUT_WRITE(PROBE_TARE_PIN, !PROBE_TARE_STATE); + WRITE(PROBE_TARE_PIN, !PROBE_TARE_STATE); delay(PROBE_TARE_DELAY); endstops.hit_on_purpose(); diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index 49520eb33..527f1190f 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -211,6 +211,7 @@ public: #endif #if ENABLED(PROBE_TARE) + static void tare_init(); static bool tare(); #endif