From bed26734a28175f7ef9669d5190bf7ebc6227223 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 1 Aug 2023 23:03:06 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20More=20endstops=20refactoring=20?= =?UTF-8?q?(#25758)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 15 + Marlin/src/HAL/AVR/endstop_interrupts.h | 2 +- Marlin/src/HAL/DUE/endstop_interrupts.h | 2 +- Marlin/src/HAL/ESP32/endstop_interrupts.h | 2 +- Marlin/src/HAL/LPC1768/endstop_interrupts.h | 2 +- Marlin/src/HAL/SAMD21/endstop_interrupts.h | 58 +-- Marlin/src/HAL/SAMD51/endstop_interrupts.h | 58 +-- Marlin/src/HAL/STM32/endstop_interrupts.h | 2 +- Marlin/src/HAL/STM32F1/endstop_interrupts.h | 2 +- .../src/HAL/TEENSY31_32/endstop_interrupts.h | 2 +- .../src/HAL/TEENSY35_36/endstop_interrupts.h | 2 +- .../src/HAL/TEENSY40_41/endstop_interrupts.h | 2 +- Marlin/src/gcode/calibrate/G28.cpp | 109 ++-- Marlin/src/gcode/calibrate/G33.cpp | 4 +- Marlin/src/inc/Conditionals_LCD.h | 24 +- Marlin/src/inc/Conditionals_post.h | 263 +++++++--- Marlin/src/inc/SanityCheck.h | 126 ++--- Marlin/src/lcd/e3v2/proui/endstop_diag.cpp | 12 +- .../generic/endstop_state_screen.cpp | 2 +- Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp | 102 +++- Marlin/src/lcd/menu/menu_configuration.cpp | 53 +- Marlin/src/module/endstops.cpp | 484 +++++++++--------- Marlin/src/module/endstops.h | 96 ++-- Marlin/src/module/motion.cpp | 126 +++-- Marlin/src/module/probe.cpp | 32 +- buildroot/tests/BIGTREE_BTT002 | 4 +- buildroot/tests/FYSETC_F6 | 11 +- buildroot/tests/LPC1769 | 7 +- buildroot/tests/SAMD21_minitronics20 | 3 +- buildroot/tests/SAMD51_grandcentral_m4 | 3 +- buildroot/tests/mega1280 | 1 + buildroot/tests/teensy35 | 3 +- 32 files changed, 883 insertions(+), 731 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 3127d59e8b..dbba2e60ed 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1751,6 +1751,21 @@ //#define V_HOME_DIR -1 //#define W_HOME_DIR -1 +/** + * Safety Stops + * If an axis has endstops on both ends the one specified above is used for + * homing, while the other can be used for things like SD_ABORT_ON_ENDSTOP_HIT. + */ +//#define X_SAFETY_STOP +//#define Y_SAFETY_STOP +//#define Z_SAFETY_STOP +//#define I_SAFETY_STOP +//#define J_SAFETY_STOP +//#define K_SAFETY_STOP +//#define U_SAFETY_STOP +//#define V_SAFETY_STOP +//#define W_SAFETY_STOP + // @section geometry // The size of the printable area diff --git a/Marlin/src/HAL/AVR/endstop_interrupts.h b/Marlin/src/HAL/AVR/endstop_interrupts.h index ac827f1842..2532624d39 100644 --- a/Marlin/src/HAL/AVR/endstop_interrupts.h +++ b/Marlin/src/HAL/AVR/endstop_interrupts.h @@ -160,7 +160,7 @@ void setup_endstop_interrupts() { pciSetup(Z_MAX_PIN); #endif #endif - #if HAS_Z_MIN_PIN + #if USE_Z_MIN #if (digitalPinToInterrupt(Z_MIN_PIN) != NOT_AN_INTERRUPT) _ATTACH(Z_MIN_PIN); #else diff --git a/Marlin/src/HAL/DUE/endstop_interrupts.h b/Marlin/src/HAL/DUE/endstop_interrupts.h index 28510fb508..954eb625a5 100644 --- a/Marlin/src/HAL/DUE/endstop_interrupts.h +++ b/Marlin/src/HAL/DUE/endstop_interrupts.h @@ -52,7 +52,7 @@ void setup_endstop_interrupts() { TERN_(USE_Y_MAX, _ATTACH(Y_MAX_PIN)); TERN_(USE_Y_MIN, _ATTACH(Y_MIN_PIN)); TERN_(USE_Z_MAX, _ATTACH(Z_MAX_PIN)); - TERN_(HAS_Z_MIN_PIN, _ATTACH(Z_MIN_PIN)); + TERN_(USE_Z_MIN, _ATTACH(Z_MIN_PIN)); TERN_(USE_X2_MAX, _ATTACH(X2_MAX_PIN)); TERN_(USE_X2_MIN, _ATTACH(X2_MIN_PIN)); TERN_(USE_Y2_MAX, _ATTACH(Y2_MAX_PIN)); diff --git a/Marlin/src/HAL/ESP32/endstop_interrupts.h b/Marlin/src/HAL/ESP32/endstop_interrupts.h index 43f4975d46..1377345992 100644 --- a/Marlin/src/HAL/ESP32/endstop_interrupts.h +++ b/Marlin/src/HAL/ESP32/endstop_interrupts.h @@ -47,7 +47,7 @@ void setup_endstop_interrupts() { TERN_(USE_Y_MAX, _ATTACH(Y_MAX_PIN)); TERN_(USE_Y_MIN, _ATTACH(Y_MIN_PIN)); TERN_(USE_Z_MAX, _ATTACH(Z_MAX_PIN)); - TERN_(HAS_Z_MIN_PIN, _ATTACH(Z_MIN_PIN)); + TERN_(USE_Z_MIN, _ATTACH(Z_MIN_PIN)); TERN_(USE_X2_MAX, _ATTACH(X2_MAX_PIN)); TERN_(USE_X2_MIN, _ATTACH(X2_MIN_PIN)); TERN_(USE_Y2_MAX, _ATTACH(Y2_MAX_PIN)); diff --git a/Marlin/src/HAL/LPC1768/endstop_interrupts.h b/Marlin/src/HAL/LPC1768/endstop_interrupts.h index cd9de25477..7a67b958b4 100644 --- a/Marlin/src/HAL/LPC1768/endstop_interrupts.h +++ b/Marlin/src/HAL/LPC1768/endstop_interrupts.h @@ -74,7 +74,7 @@ void setup_endstop_interrupts() { #endif _ATTACH(Z_MAX_PIN); #endif - #if HAS_Z_MIN_PIN + #if USE_Z_MIN #if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PIN) #error "Z_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue." #endif diff --git a/Marlin/src/HAL/SAMD21/endstop_interrupts.h b/Marlin/src/HAL/SAMD21/endstop_interrupts.h index 31414a39e3..37fdb7504b 100644 --- a/Marlin/src/HAL/SAMD21/endstop_interrupts.h +++ b/Marlin/src/HAL/SAMD21/endstop_interrupts.h @@ -54,34 +54,34 @@ #include "../../module/endstops.h" #define MATCH_EILINE(P1,P2) (P1 != P2 && PIN_TO_EILINE(P1) == PIN_TO_EILINE(P2)) -#define MATCH_X_MAX_EILINE(P) TERN0(USE_X_MAX, DEFER4(MATCH_EILINE)(P, X_MAX_PIN)) -#define MATCH_X_MIN_EILINE(P) TERN0(USE_X_MIN, DEFER4(MATCH_EILINE)(P, X_MIN_PIN)) -#define MATCH_Y_MAX_EILINE(P) TERN0(USE_Y_MAX, DEFER4(MATCH_EILINE)(P, Y_MAX_PIN)) -#define MATCH_Y_MIN_EILINE(P) TERN0(USE_Y_MIN, DEFER4(MATCH_EILINE)(P, Y_MIN_PIN)) -#define MATCH_Z_MAX_EILINE(P) TERN0(USE_Z_MAX, DEFER4(MATCH_EILINE)(P, Z_MAX_PIN)) -#define MATCH_Z_MIN_EILINE(P) TERN0(HAS_Z_MIN_PIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PIN)) -#define MATCH_I_MAX_EILINE(P) TERN0(USE_I_MAX, DEFER4(MATCH_EILINE)(P, I_MAX_PIN)) -#define MATCH_I_MIN_EILINE(P) TERN0(USE_I_MIN, DEFER4(MATCH_EILINE)(P, I_MIN_PIN)) -#define MATCH_J_MAX_EILINE(P) TERN0(USE_J_MAX, DEFER4(MATCH_EILINE)(P, J_MAX_PIN)) -#define MATCH_J_MIN_EILINE(P) TERN0(USE_J_MIN, DEFER4(MATCH_EILINE)(P, J_MIN_PIN)) -#define MATCH_K_MAX_EILINE(P) TERN0(USE_K_MAX, DEFER4(MATCH_EILINE)(P, K_MAX_PIN)) -#define MATCH_K_MIN_EILINE(P) TERN0(USE_K_MIN, DEFER4(MATCH_EILINE)(P, K_MIN_PIN)) -#define MATCH_U_MAX_EILINE(P) TERN0(USE_U_MAX, DEFER4(MATCH_EILINE)(P, U_MAX_PIN)) -#define MATCH_U_MIN_EILINE(P) TERN0(USE_U_MIN, DEFER4(MATCH_EILINE)(P, U_MIN_PIN)) -#define MATCH_V_MAX_EILINE(P) TERN0(USE_V_MAX, DEFER4(MATCH_EILINE)(P, V_MAX_PIN)) -#define MATCH_V_MIN_EILINE(P) TERN0(USE_V_MIN, DEFER4(MATCH_EILINE)(P, V_MIN_PIN)) -#define MATCH_W_MAX_EILINE(P) TERN0(USE_W_MAX, DEFER4(MATCH_EILINE)(P, W_MAX_PIN)) -#define MATCH_W_MIN_EILINE(P) TERN0(USE_W_MIN, DEFER4(MATCH_EILINE)(P, W_MIN_PIN)) -#define MATCH_X2_MAX_EILINE(P) TERN0(USE_X2_MAX, DEFER4(MATCH_EILINE)(P, X2_MAX_PIN)) -#define MATCH_X2_MIN_EILINE(P) TERN0(USE_X2_MIN, DEFER4(MATCH_EILINE)(P, X2_MIN_PIN)) -#define MATCH_Y2_MAX_EILINE(P) TERN0(USE_Y2_MAX, DEFER4(MATCH_EILINE)(P, Y2_MAX_PIN)) -#define MATCH_Y2_MIN_EILINE(P) TERN0(USE_Y2_MIN, DEFER4(MATCH_EILINE)(P, Y2_MIN_PIN)) -#define MATCH_Z2_MAX_EILINE(P) TERN0(USE_Z2_MAX, DEFER4(MATCH_EILINE)(P, Z2_MAX_PIN)) -#define MATCH_Z2_MIN_EILINE(P) TERN0(USE_Z2_MIN, DEFER4(MATCH_EILINE)(P, Z2_MIN_PIN)) -#define MATCH_Z3_MAX_EILINE(P) TERN0(USE_Z3_MAX, DEFER4(MATCH_EILINE)(P, Z3_MAX_PIN)) -#define MATCH_Z3_MIN_EILINE(P) TERN0(USE_Z3_MIN, DEFER4(MATCH_EILINE)(P, Z3_MIN_PIN)) -#define MATCH_Z4_MAX_EILINE(P) TERN0(USE_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN)) -#define MATCH_Z4_MIN_EILINE(P) TERN0(USE_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN)) +#define MATCH_X_MAX_EILINE(P) TERN0(USE_X_MAX, DEFER4(MATCH_EILINE)(P, X_MAX_PIN)) +#define MATCH_X_MIN_EILINE(P) TERN0(USE_X_MIN, DEFER4(MATCH_EILINE)(P, X_MIN_PIN)) +#define MATCH_Y_MAX_EILINE(P) TERN0(USE_Y_MAX, DEFER4(MATCH_EILINE)(P, Y_MAX_PIN)) +#define MATCH_Y_MIN_EILINE(P) TERN0(USE_Y_MIN, DEFER4(MATCH_EILINE)(P, Y_MIN_PIN)) +#define MATCH_Z_MAX_EILINE(P) TERN0(USE_Z_MAX, DEFER4(MATCH_EILINE)(P, Z_MAX_PIN)) +#define MATCH_Z_MIN_EILINE(P) TERN0(USE_Z_MIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PIN)) +#define MATCH_I_MAX_EILINE(P) TERN0(USE_I_MAX, DEFER4(MATCH_EILINE)(P, I_MAX_PIN)) +#define MATCH_I_MIN_EILINE(P) TERN0(USE_I_MIN, DEFER4(MATCH_EILINE)(P, I_MIN_PIN)) +#define MATCH_J_MAX_EILINE(P) TERN0(USE_J_MAX, DEFER4(MATCH_EILINE)(P, J_MAX_PIN)) +#define MATCH_J_MIN_EILINE(P) TERN0(USE_J_MIN, DEFER4(MATCH_EILINE)(P, J_MIN_PIN)) +#define MATCH_K_MAX_EILINE(P) TERN0(USE_K_MAX, DEFER4(MATCH_EILINE)(P, K_MAX_PIN)) +#define MATCH_K_MIN_EILINE(P) TERN0(USE_K_MIN, DEFER4(MATCH_EILINE)(P, K_MIN_PIN)) +#define MATCH_U_MAX_EILINE(P) TERN0(USE_U_MAX, DEFER4(MATCH_EILINE)(P, U_MAX_PIN)) +#define MATCH_U_MIN_EILINE(P) TERN0(USE_U_MIN, DEFER4(MATCH_EILINE)(P, U_MIN_PIN)) +#define MATCH_V_MAX_EILINE(P) TERN0(USE_V_MAX, DEFER4(MATCH_EILINE)(P, V_MAX_PIN)) +#define MATCH_V_MIN_EILINE(P) TERN0(USE_V_MIN, DEFER4(MATCH_EILINE)(P, V_MIN_PIN)) +#define MATCH_W_MAX_EILINE(P) TERN0(USE_W_MAX, DEFER4(MATCH_EILINE)(P, W_MAX_PIN)) +#define MATCH_W_MIN_EILINE(P) TERN0(USE_W_MIN, DEFER4(MATCH_EILINE)(P, W_MIN_PIN)) +#define MATCH_X2_MAX_EILINE(P) TERN0(USE_X2_MAX, DEFER4(MATCH_EILINE)(P, X2_MAX_PIN)) +#define MATCH_X2_MIN_EILINE(P) TERN0(USE_X2_MIN, DEFER4(MATCH_EILINE)(P, X2_MIN_PIN)) +#define MATCH_Y2_MAX_EILINE(P) TERN0(USE_Y2_MAX, DEFER4(MATCH_EILINE)(P, Y2_MAX_PIN)) +#define MATCH_Y2_MIN_EILINE(P) TERN0(USE_Y2_MIN, DEFER4(MATCH_EILINE)(P, Y2_MIN_PIN)) +#define MATCH_Z2_MAX_EILINE(P) TERN0(USE_Z2_MAX, DEFER4(MATCH_EILINE)(P, Z2_MAX_PIN)) +#define MATCH_Z2_MIN_EILINE(P) TERN0(USE_Z2_MIN, DEFER4(MATCH_EILINE)(P, Z2_MIN_PIN)) +#define MATCH_Z3_MAX_EILINE(P) TERN0(USE_Z3_MAX, DEFER4(MATCH_EILINE)(P, Z3_MAX_PIN)) +#define MATCH_Z3_MIN_EILINE(P) TERN0(USE_Z3_MIN, DEFER4(MATCH_EILINE)(P, Z3_MIN_PIN)) +#define MATCH_Z4_MAX_EILINE(P) TERN0(USE_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN)) +#define MATCH_Z4_MIN_EILINE(P) TERN0(USE_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN)) #define MATCH_Z_MIN_PROBE_EILINE(P) TERN0(USE_Z_MIN_PROBE, DEFER4(MATCH_EILINE)(P, Z_MIN_PROBE_PIN)) #define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \ @@ -136,7 +136,7 @@ void setup_endstop_interrupts() { #endif _ATTACH(Z_MAX_PIN); #endif - #if HAS_Z_MIN_PIN + #if USE_Z_MIN #if !AVAILABLE_EILINE(Z_MIN_PIN) #error "Z_MIN_PIN has no EXTINT line available. Disable ENDSTOP_INTERRUPTS_FEATURE to continue." #endif diff --git a/Marlin/src/HAL/SAMD51/endstop_interrupts.h b/Marlin/src/HAL/SAMD51/endstop_interrupts.h index 40f78baf87..84b6c46da9 100644 --- a/Marlin/src/HAL/SAMD51/endstop_interrupts.h +++ b/Marlin/src/HAL/SAMD51/endstop_interrupts.h @@ -53,34 +53,34 @@ #include "../../module/endstops.h" #define MATCH_EILINE(P1,P2) (P1 != P2 && PIN_TO_EILINE(P1) == PIN_TO_EILINE(P2)) -#define MATCH_X_MAX_EILINE(P) TERN0(USE_X_MAX, DEFER4(MATCH_EILINE)(P, X_MAX_PIN)) -#define MATCH_X_MIN_EILINE(P) TERN0(USE_X_MIN, DEFER4(MATCH_EILINE)(P, X_MIN_PIN)) -#define MATCH_Y_MAX_EILINE(P) TERN0(USE_Y_MAX, DEFER4(MATCH_EILINE)(P, Y_MAX_PIN)) -#define MATCH_Y_MIN_EILINE(P) TERN0(USE_Y_MIN, DEFER4(MATCH_EILINE)(P, Y_MIN_PIN)) -#define MATCH_Z_MAX_EILINE(P) TERN0(USE_Z_MAX, DEFER4(MATCH_EILINE)(P, Z_MAX_PIN)) -#define MATCH_Z_MIN_EILINE(P) TERN0(HAS_Z_MIN_PIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PIN)) -#define MATCH_I_MAX_EILINE(P) TERN0(USE_I_MAX, DEFER4(MATCH_EILINE)(P, I_MAX_PIN)) -#define MATCH_I_MIN_EILINE(P) TERN0(USE_I_MIN, DEFER4(MATCH_EILINE)(P, I_MIN_PIN)) -#define MATCH_J_MAX_EILINE(P) TERN0(USE_J_MAX, DEFER4(MATCH_EILINE)(P, J_MAX_PIN)) -#define MATCH_J_MIN_EILINE(P) TERN0(USE_J_MIN, DEFER4(MATCH_EILINE)(P, J_MIN_PIN)) -#define MATCH_K_MAX_EILINE(P) TERN0(USE_K_MAX, DEFER4(MATCH_EILINE)(P, K_MAX_PIN)) -#define MATCH_K_MIN_EILINE(P) TERN0(USE_K_MIN, DEFER4(MATCH_EILINE)(P, K_MIN_PIN)) -#define MATCH_U_MAX_EILINE(P) TERN0(USE_U_MAX, DEFER4(MATCH_EILINE)(P, U_MAX_PIN)) -#define MATCH_U_MIN_EILINE(P) TERN0(USE_U_MIN, DEFER4(MATCH_EILINE)(P, U_MIN_PIN)) -#define MATCH_V_MAX_EILINE(P) TERN0(USE_V_MAX, DEFER4(MATCH_EILINE)(P, V_MAX_PIN)) -#define MATCH_V_MIN_EILINE(P) TERN0(USE_V_MIN, DEFER4(MATCH_EILINE)(P, V_MIN_PIN)) -#define MATCH_W_MAX_EILINE(P) TERN0(USE_W_MAX, DEFER4(MATCH_EILINE)(P, W_MAX_PIN)) -#define MATCH_W_MIN_EILINE(P) TERN0(USE_W_MIN, DEFER4(MATCH_EILINE)(P, W_MIN_PIN)) -#define MATCH_X2_MAX_EILINE(P) TERN0(USE_X2_MAX, DEFER4(MATCH_EILINE)(P, X2_MAX_PIN)) -#define MATCH_X2_MIN_EILINE(P) TERN0(USE_X2_MIN, DEFER4(MATCH_EILINE)(P, X2_MIN_PIN)) -#define MATCH_Y2_MAX_EILINE(P) TERN0(USE_Y2_MAX, DEFER4(MATCH_EILINE)(P, Y2_MAX_PIN)) -#define MATCH_Y2_MIN_EILINE(P) TERN0(USE_Y2_MIN, DEFER4(MATCH_EILINE)(P, Y2_MIN_PIN)) -#define MATCH_Z2_MAX_EILINE(P) TERN0(USE_Z2_MAX, DEFER4(MATCH_EILINE)(P, Z2_MAX_PIN)) -#define MATCH_Z2_MIN_EILINE(P) TERN0(USE_Z2_MIN, DEFER4(MATCH_EILINE)(P, Z2_MIN_PIN)) -#define MATCH_Z3_MAX_EILINE(P) TERN0(USE_Z3_MAX, DEFER4(MATCH_EILINE)(P, Z3_MAX_PIN)) -#define MATCH_Z3_MIN_EILINE(P) TERN0(USE_Z3_MIN, DEFER4(MATCH_EILINE)(P, Z3_MIN_PIN)) -#define MATCH_Z4_MAX_EILINE(P) TERN0(USE_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN)) -#define MATCH_Z4_MIN_EILINE(P) TERN0(USE_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN)) +#define MATCH_X_MAX_EILINE(P) TERN0(USE_X_MAX, DEFER4(MATCH_EILINE)(P, X_MAX_PIN)) +#define MATCH_X_MIN_EILINE(P) TERN0(USE_X_MIN, DEFER4(MATCH_EILINE)(P, X_MIN_PIN)) +#define MATCH_Y_MAX_EILINE(P) TERN0(USE_Y_MAX, DEFER4(MATCH_EILINE)(P, Y_MAX_PIN)) +#define MATCH_Y_MIN_EILINE(P) TERN0(USE_Y_MIN, DEFER4(MATCH_EILINE)(P, Y_MIN_PIN)) +#define MATCH_Z_MAX_EILINE(P) TERN0(USE_Z_MAX, DEFER4(MATCH_EILINE)(P, Z_MAX_PIN)) +#define MATCH_Z_MIN_EILINE(P) TERN0(USE_Z_MIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PIN)) +#define MATCH_I_MAX_EILINE(P) TERN0(USE_I_MAX, DEFER4(MATCH_EILINE)(P, I_MAX_PIN)) +#define MATCH_I_MIN_EILINE(P) TERN0(USE_I_MIN, DEFER4(MATCH_EILINE)(P, I_MIN_PIN)) +#define MATCH_J_MAX_EILINE(P) TERN0(USE_J_MAX, DEFER4(MATCH_EILINE)(P, J_MAX_PIN)) +#define MATCH_J_MIN_EILINE(P) TERN0(USE_J_MIN, DEFER4(MATCH_EILINE)(P, J_MIN_PIN)) +#define MATCH_K_MAX_EILINE(P) TERN0(USE_K_MAX, DEFER4(MATCH_EILINE)(P, K_MAX_PIN)) +#define MATCH_K_MIN_EILINE(P) TERN0(USE_K_MIN, DEFER4(MATCH_EILINE)(P, K_MIN_PIN)) +#define MATCH_U_MAX_EILINE(P) TERN0(USE_U_MAX, DEFER4(MATCH_EILINE)(P, U_MAX_PIN)) +#define MATCH_U_MIN_EILINE(P) TERN0(USE_U_MIN, DEFER4(MATCH_EILINE)(P, U_MIN_PIN)) +#define MATCH_V_MAX_EILINE(P) TERN0(USE_V_MAX, DEFER4(MATCH_EILINE)(P, V_MAX_PIN)) +#define MATCH_V_MIN_EILINE(P) TERN0(USE_V_MIN, DEFER4(MATCH_EILINE)(P, V_MIN_PIN)) +#define MATCH_W_MAX_EILINE(P) TERN0(USE_W_MAX, DEFER4(MATCH_EILINE)(P, W_MAX_PIN)) +#define MATCH_W_MIN_EILINE(P) TERN0(USE_W_MIN, DEFER4(MATCH_EILINE)(P, W_MIN_PIN)) +#define MATCH_X2_MAX_EILINE(P) TERN0(USE_X2_MAX, DEFER4(MATCH_EILINE)(P, X2_MAX_PIN)) +#define MATCH_X2_MIN_EILINE(P) TERN0(USE_X2_MIN, DEFER4(MATCH_EILINE)(P, X2_MIN_PIN)) +#define MATCH_Y2_MAX_EILINE(P) TERN0(USE_Y2_MAX, DEFER4(MATCH_EILINE)(P, Y2_MAX_PIN)) +#define MATCH_Y2_MIN_EILINE(P) TERN0(USE_Y2_MIN, DEFER4(MATCH_EILINE)(P, Y2_MIN_PIN)) +#define MATCH_Z2_MAX_EILINE(P) TERN0(USE_Z2_MAX, DEFER4(MATCH_EILINE)(P, Z2_MAX_PIN)) +#define MATCH_Z2_MIN_EILINE(P) TERN0(USE_Z2_MIN, DEFER4(MATCH_EILINE)(P, Z2_MIN_PIN)) +#define MATCH_Z3_MAX_EILINE(P) TERN0(USE_Z3_MAX, DEFER4(MATCH_EILINE)(P, Z3_MAX_PIN)) +#define MATCH_Z3_MIN_EILINE(P) TERN0(USE_Z3_MIN, DEFER4(MATCH_EILINE)(P, Z3_MIN_PIN)) +#define MATCH_Z4_MAX_EILINE(P) TERN0(USE_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN)) +#define MATCH_Z4_MIN_EILINE(P) TERN0(USE_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN)) #define MATCH_Z_MIN_PROBE_EILINE(P) TERN0(USE_Z_MIN_PROBE, DEFER4(MATCH_EILINE)(P, Z_MIN_PROBE_PIN)) #define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \ @@ -135,7 +135,7 @@ void setup_endstop_interrupts() { #endif _ATTACH(Z_MAX_PIN); #endif - #if HAS_Z_MIN_PIN + #if USE_Z_MIN #if !AVAILABLE_EILINE(Z_MIN_PIN) #error "Z_MIN_PIN has no EXTINT line available. Disable ENDSTOP_INTERRUPTS_FEATURE to continue." #endif diff --git a/Marlin/src/HAL/STM32/endstop_interrupts.h b/Marlin/src/HAL/STM32/endstop_interrupts.h index 5ae228d3f8..0c92053d42 100644 --- a/Marlin/src/HAL/STM32/endstop_interrupts.h +++ b/Marlin/src/HAL/STM32/endstop_interrupts.h @@ -34,7 +34,7 @@ void setup_endstop_interrupts() { TERN_(USE_Y_MAX, _ATTACH(Y_MAX_PIN)); TERN_(USE_Y_MIN, _ATTACH(Y_MIN_PIN)); TERN_(USE_Z_MAX, _ATTACH(Z_MAX_PIN)); - TERN_(HAS_Z_MIN_PIN, _ATTACH(Z_MIN_PIN)); + TERN_(USE_Z_MIN, _ATTACH(Z_MIN_PIN)); TERN_(USE_X2_MAX, _ATTACH(X2_MAX_PIN)); TERN_(USE_X2_MIN, _ATTACH(X2_MIN_PIN)); TERN_(USE_Y2_MAX, _ATTACH(Y2_MAX_PIN)); diff --git a/Marlin/src/HAL/STM32F1/endstop_interrupts.h b/Marlin/src/HAL/STM32F1/endstop_interrupts.h index 6febcec5d0..6ed920183b 100644 --- a/Marlin/src/HAL/STM32F1/endstop_interrupts.h +++ b/Marlin/src/HAL/STM32F1/endstop_interrupts.h @@ -59,7 +59,7 @@ void setup_endstop_interrupts() { TERN_(USE_Y_MAX, _ATTACH(Y_MAX_PIN)); TERN_(USE_Y_MIN, _ATTACH(Y_MIN_PIN)); TERN_(USE_Z_MAX, _ATTACH(Z_MAX_PIN)); - TERN_(HAS_Z_MIN_PIN, _ATTACH(Z_MIN_PIN)); + TERN_(USE_Z_MIN, _ATTACH(Z_MIN_PIN)); TERN_(USE_X2_MAX, _ATTACH(X2_MAX_PIN)); TERN_(USE_X2_MIN, _ATTACH(X2_MIN_PIN)); TERN_(USE_Y2_MAX, _ATTACH(Y2_MAX_PIN)); diff --git a/Marlin/src/HAL/TEENSY31_32/endstop_interrupts.h b/Marlin/src/HAL/TEENSY31_32/endstop_interrupts.h index 28510fb508..954eb625a5 100644 --- a/Marlin/src/HAL/TEENSY31_32/endstop_interrupts.h +++ b/Marlin/src/HAL/TEENSY31_32/endstop_interrupts.h @@ -52,7 +52,7 @@ void setup_endstop_interrupts() { TERN_(USE_Y_MAX, _ATTACH(Y_MAX_PIN)); TERN_(USE_Y_MIN, _ATTACH(Y_MIN_PIN)); TERN_(USE_Z_MAX, _ATTACH(Z_MAX_PIN)); - TERN_(HAS_Z_MIN_PIN, _ATTACH(Z_MIN_PIN)); + TERN_(USE_Z_MIN, _ATTACH(Z_MIN_PIN)); TERN_(USE_X2_MAX, _ATTACH(X2_MAX_PIN)); TERN_(USE_X2_MIN, _ATTACH(X2_MIN_PIN)); TERN_(USE_Y2_MAX, _ATTACH(Y2_MAX_PIN)); diff --git a/Marlin/src/HAL/TEENSY35_36/endstop_interrupts.h b/Marlin/src/HAL/TEENSY35_36/endstop_interrupts.h index 505434cd89..bc8e177fb7 100644 --- a/Marlin/src/HAL/TEENSY35_36/endstop_interrupts.h +++ b/Marlin/src/HAL/TEENSY35_36/endstop_interrupts.h @@ -51,7 +51,7 @@ void setup_endstop_interrupts() { TERN_(USE_Y_MAX, _ATTACH(Y_MAX_PIN)); TERN_(USE_Y_MIN, _ATTACH(Y_MIN_PIN)); TERN_(USE_Z_MAX, _ATTACH(Z_MAX_PIN)); - TERN_(HAS_Z_MIN_PIN, _ATTACH(Z_MIN_PIN)); + TERN_(USE_Z_MIN, _ATTACH(Z_MIN_PIN)); TERN_(USE_X2_MAX, _ATTACH(X2_MAX_PIN)); TERN_(USE_X2_MIN, _ATTACH(X2_MIN_PIN)); TERN_(USE_Y2_MAX, _ATTACH(Y2_MAX_PIN)); diff --git a/Marlin/src/HAL/TEENSY40_41/endstop_interrupts.h b/Marlin/src/HAL/TEENSY40_41/endstop_interrupts.h index 325d97daeb..722912c890 100644 --- a/Marlin/src/HAL/TEENSY40_41/endstop_interrupts.h +++ b/Marlin/src/HAL/TEENSY40_41/endstop_interrupts.h @@ -51,7 +51,7 @@ void setup_endstop_interrupts() { TERN_(USE_Y_MAX, _ATTACH(Y_MAX_PIN)); TERN_(USE_Y_MIN, _ATTACH(Y_MIN_PIN)); TERN_(USE_Z_MAX, _ATTACH(Z_MAX_PIN)); - TERN_(HAS_Z_MIN_PIN, _ATTACH(Z_MIN_PIN)); + TERN_(USE_Z_MIN, _ATTACH(Z_MIN_PIN)); TERN_(USE_X2_MAX, _ATTACH(X2_MAX_PIN)); TERN_(USE_X2_MIN, _ATTACH(X2_MIN_PIN)); TERN_(USE_Y2_MAX, _ATTACH(Y2_MAX_PIN)); diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index b364c0382c..fd034f0ba6 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -254,69 +254,67 @@ void GcodeSuite::G28() { // Reset to the XY plane TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY); - #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) - #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z)) || HAS_CURRENT_HOME(I) || HAS_CURRENT_HOME(J) || HAS_CURRENT_HOME(K) || HAS_CURRENT_HOME(U) || HAS_CURRENT_HOME(V) || HAS_CURRENT_HOME(W) + #define _OR_HAS_CURR_HOME(N) HAS_CURRENT_HOME(N) || + #if MAIN_AXIS_MAP(_OR_HAS_CURR_HOME) MAP(_OR_HAS_CURR_HOME, X2, Y2, Z2, Z3, Z4) 0 #define HAS_HOMING_CURRENT 1 #endif #if HAS_HOMING_CURRENT - auto debug_current = [](FSTR_P const s, const int16_t a, const int16_t b) { - DEBUG_ECHOLN(s, F(" current: "), a, F(" -> "), b); - }; + + #if ENABLED(DEBUG_LEVELING_FEATURE) + auto debug_current = [](FSTR_P const s, const int16_t a, const int16_t b) { + if (DEBUGGING(LEVELING)) { DEBUG_ECHOF(s); DEBUG_ECHOLNPGM(" current: ", a, " -> ", b); } + }; + #else + #define debug_current(...) + #endif + + #define _SAVE_SET_CURRENT(A) \ + const int16_t saved_current_##A = stepper##A.getMilliamps(); \ + stepper##A.rms_current(A##_CURRENT_HOME); \ + debug_current(F(STR_##A), saved_current_##A, A##_CURRENT_HOME) + #if HAS_CURRENT_HOME(X) - const int16_t tmc_save_current_X = stepperX.getMilliamps(); - stepperX.rms_current(X_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_X), tmc_save_current_X, X_CURRENT_HOME); + _SAVE_SET_CURRENT(X); #endif #if HAS_CURRENT_HOME(X2) - const int16_t tmc_save_current_X2 = stepperX2.getMilliamps(); - stepperX2.rms_current(X2_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_X2), tmc_save_current_X2, X2_CURRENT_HOME); + _SAVE_SET_CURRENT(X2); #endif #if HAS_CURRENT_HOME(Y) - const int16_t tmc_save_current_Y = stepperY.getMilliamps(); - stepperY.rms_current(Y_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_Y), tmc_save_current_Y, Y_CURRENT_HOME); + _SAVE_SET_CURRENT(Y); #endif #if HAS_CURRENT_HOME(Y2) - const int16_t tmc_save_current_Y2 = stepperY2.getMilliamps(); - stepperY2.rms_current(Y2_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_Y2), tmc_save_current_Y2, Y2_CURRENT_HOME); + _SAVE_SET_CURRENT(Y2); #endif - #if HAS_CURRENT_HOME(Z) && ENABLED(DELTA) - const int16_t tmc_save_current_Z = stepperZ.getMilliamps(); - stepperZ.rms_current(Z_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_Z), tmc_save_current_Z, Z_CURRENT_HOME); + #if HAS_CURRENT_HOME(Z) + _SAVE_SET_CURRENT(Z); + #endif + #if HAS_CURRENT_HOME(Z2) + _SAVE_SET_CURRENT(Z2); + #endif + #if HAS_CURRENT_HOME(Z3) + _SAVE_SET_CURRENT(Z3); + #endif + #if HAS_CURRENT_HOME(Z4) + _SAVE_SET_CURRENT(Z4); #endif #if HAS_CURRENT_HOME(I) - const int16_t tmc_save_current_I = stepperI.getMilliamps(); - stepperI.rms_current(I_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_I), tmc_save_current_I, I_CURRENT_HOME); + _SAVE_SET_CURRENT(I); #endif #if HAS_CURRENT_HOME(J) - const int16_t tmc_save_current_J = stepperJ.getMilliamps(); - stepperJ.rms_current(J_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_J), tmc_save_current_J, J_CURRENT_HOME); + _SAVE_SET_CURRENT(J); #endif #if HAS_CURRENT_HOME(K) - const int16_t tmc_save_current_K = stepperK.getMilliamps(); - stepperK.rms_current(K_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_K), tmc_save_current_K, K_CURRENT_HOME); + _SAVE_SET_CURRENT(K); #endif #if HAS_CURRENT_HOME(U) - const int16_t tmc_save_current_U = stepperU.getMilliamps(); - stepperU.rms_current(U_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_U), tmc_save_current_U, U_CURRENT_HOME); + _SAVE_SET_CURRENT(U); #endif #if HAS_CURRENT_HOME(V) - const int16_t tmc_save_current_V = stepperV.getMilliamps(); - stepperV.rms_current(V_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_V), tmc_save_current_V, V_CURRENT_HOME); + _SAVE_SET_CURRENT(V); #endif #if HAS_CURRENT_HOME(W) - const int16_t tmc_save_current_W = stepperW.getMilliamps(); - stepperW.rms_current(W_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_W), tmc_save_current_W, W_CURRENT_HOME); + _SAVE_SET_CURRENT(W); #endif #if SENSORLESS_STALLGUARD_DELAY safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle @@ -577,37 +575,46 @@ void GcodeSuite::G28() { #if HAS_HOMING_CURRENT if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Restore driver current..."); #if HAS_CURRENT_HOME(X) - stepperX.rms_current(tmc_save_current_X); + stepperX.rms_current(saved_current_X); #endif #if HAS_CURRENT_HOME(X2) - stepperX2.rms_current(tmc_save_current_X2); + stepperX2.rms_current(saved_current_X2); #endif #if HAS_CURRENT_HOME(Y) - stepperY.rms_current(tmc_save_current_Y); + stepperY.rms_current(saved_current_Y); #endif #if HAS_CURRENT_HOME(Y2) - stepperY2.rms_current(tmc_save_current_Y2); + stepperY2.rms_current(saved_current_Y2); #endif - #if HAS_CURRENT_HOME(Z) && ENABLED(DELTA) - stepperZ.rms_current(tmc_save_current_Z); + #if HAS_CURRENT_HOME(Z) + stepperZ.rms_current(saved_current_Z); + #endif + #if HAS_CURRENT_HOME(Z2) + stepperZ2.rms_current(saved_current_Z2); + #endif + #if HAS_CURRENT_HOME(Z3) + stepperZ3.rms_current(saved_current_Z3); + #endif + #if HAS_CURRENT_HOME(Z4) + stepperZ4.rms_current(saved_current_Z4); #endif #if HAS_CURRENT_HOME(I) - stepperI.rms_current(tmc_save_current_I); + stepperI.rms_current(saved_current_I); #endif #if HAS_CURRENT_HOME(J) - stepperJ.rms_current(tmc_save_current_J); + stepperJ.rms_current(saved_current_J); #endif #if HAS_CURRENT_HOME(K) - stepperK.rms_current(tmc_save_current_K); + stepperK.rms_current(saved_current_K); #endif #if HAS_CURRENT_HOME(U) - stepperU.rms_current(tmc_save_current_U); + stepperU.rms_current(saved_current_U); #endif #if HAS_CURRENT_HOME(V) - stepperV.rms_current(tmc_save_current_V); + stepperV.rms_current(saved_current_V); #endif #if HAS_CURRENT_HOME(W) - stepperW.rms_current(tmc_save_current_W); + stepperW.rms_current(saved_current_W); #endif #if SENSORLESS_STALLGUARD_DELAY safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 7530737dde..10f5afca2d 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -67,9 +67,9 @@ float lcd_probe_pt(const xy_pos_t &xy); void ac_home() { endstops.enable(true); - TERN_(SENSORLESS_HOMING, endstops.set_homing_current(true)); + TERN_(SENSORLESS_HOMING, endstops.set_z_sensorless_current(true)); home_delta(); - TERN_(SENSORLESS_HOMING, endstops.set_homing_current(false)); + TERN_(SENSORLESS_HOMING, endstops.set_z_sensorless_current(false)); endstops.not_homing(); } diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 084a3d74e9..b069e2d2b1 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1422,24 +1422,26 @@ * Conditionals based on the type of Bed Probe */ #if HAS_BED_PROBE + #if ALL(DELTA, SENSORLESS_PROBING) + #define HAS_DELTA_SENSORLESS_PROBING 1 + #else + #define HAS_REAL_BED_PROBE 1 + #endif + #if HAS_REAL_BED_PROBE && NONE(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_SPI_SENSORLESS) + #define NEED_Z_MIN_PROBE_PIN 1 + #endif + #if Z_HOME_TO_MIN && (!NEED_Z_MIN_PROBE_PIN || ENABLED(USE_PROBE_FOR_Z_HOMING)) + #define HOMING_Z_WITH_PROBE 1 + #endif #if DISABLED(NOZZLE_AS_PROBE) #define HAS_PROBE_XY_OFFSET 1 #endif - #if ALL(DELTA, SENSORLESS_PROBING) - #define HAS_DELTA_SENSORLESS_PROBING 1 - #endif - #if NONE(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, HAS_DELTA_SENSORLESS_PROBING) - #define USE_Z_MIN_PROBE 1 - #endif - #if Z_HOME_TO_MIN && (DISABLED(USE_Z_MIN_PROBE) || ENABLED(USE_PROBE_FOR_Z_HOMING)) - #define HOMING_Z_WITH_PROBE 1 + #if ANY(Z_PROBE_ALLEN_KEY, MAG_MOUNTED_PROBE) + #define PROBE_TRIGGERED_WHEN_STOWED_TEST 1 // Extra test for Allen Key Probe #endif #ifndef Z_PROBE_LOW_POINT #define Z_PROBE_LOW_POINT -5 #endif - #if ANY(Z_PROBE_ALLEN_KEY, MAG_MOUNTED_PROBE) - #define PROBE_TRIGGERED_WHEN_STOWED_TEST 1 // Extra test for Allen Key Probe - #endif #if MULTIPLE_PROBING > 1 #if EXTRA_PROBING > 0 #define TOTAL_PROBING (MULTIPLE_PROBING + EXTRA_PROBING) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 442fcfbafd..13f20114e5 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1424,13 +1424,13 @@ #if AXIS_IS_TMC(X) #if defined(X_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X) #define X_SENSORLESS 1 + #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(X) + #define X_SPI_SENSORLESS 1 + #endif #endif #if AXIS_HAS_STEALTHCHOP(X) #define X_HAS_STEALTHCHOP 1 #endif - #if ENABLED(SPI_ENDSTOPS) - #define X_SPI_SENSORLESS X_SENSORLESS - #endif #ifndef X_INTERPOLATE #define X_INTERPOLATE INTERPOLATE #endif @@ -1462,13 +1462,13 @@ #if AXIS_IS_TMC(Y) #if defined(Y_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y) #define Y_SENSORLESS 1 + #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(Y) + #define Y_SPI_SENSORLESS 1 + #endif #endif #if AXIS_HAS_STEALTHCHOP(Y) #define Y_HAS_STEALTHCHOP 1 #endif - #if ENABLED(SPI_ENDSTOPS) - #define Y_SPI_SENSORLESS Y_SENSORLESS - #endif #ifndef Y_INTERPOLATE #define Y_INTERPOLATE INTERPOLATE #endif @@ -1500,13 +1500,13 @@ #if AXIS_IS_TMC(Z) #if defined(Z_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z) #define Z_SENSORLESS 1 + #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(Z) + #define Z_SPI_SENSORLESS 1 + #endif #endif #if AXIS_HAS_STEALTHCHOP(Z) #define Z_HAS_STEALTHCHOP 1 #endif - #if ENABLED(SPI_ENDSTOPS) - #define Z_SPI_SENSORLESS Z_SENSORLESS - #endif #ifndef Z_INTERPOLATE #define Z_INTERPOLATE INTERPOLATE #endif @@ -1572,13 +1572,13 @@ #if AXIS_IS_TMC(I) #if defined(I_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(I) #define I_SENSORLESS 1 + #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(I) + #define I_SPI_SENSORLESS 1 + #endif #endif #if AXIS_HAS_STEALTHCHOP(I) #define I_HAS_STEALTHCHOP 1 #endif - #if ENABLED(SPI_ENDSTOPS) - #define I_SPI_SENSORLESS I_SENSORLESS - #endif #ifndef I_INTERPOLATE #define I_INTERPOLATE INTERPOLATE #endif @@ -1593,13 +1593,13 @@ #if AXIS_IS_TMC(J) #if defined(J_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(J) #define J_SENSORLESS 1 + #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(J) + #define J_SPI_SENSORLESS 1 + #endif #endif #if AXIS_HAS_STEALTHCHOP(J) #define J_HAS_STEALTHCHOP 1 #endif - #if ENABLED(SPI_ENDSTOPS) - #define J_SPI_SENSORLESS J_SENSORLESS - #endif #ifndef J_INTERPOLATE #define J_INTERPOLATE INTERPOLATE #endif @@ -1614,13 +1614,13 @@ #if AXIS_IS_TMC(K) #if defined(K_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(K) #define K_SENSORLESS 1 + #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(K) + #define K_SPI_SENSORLESS 1 + #endif #endif #if AXIS_HAS_STEALTHCHOP(K) #define K_HAS_STEALTHCHOP 1 #endif - #if ENABLED(SPI_ENDSTOPS) - #define K_SPI_SENSORLESS K_SENSORLESS - #endif #ifndef K_INTERPOLATE #define K_INTERPOLATE INTERPOLATE #endif @@ -1635,13 +1635,13 @@ #if AXIS_IS_TMC(U) #if defined(U_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(U) #define U_SENSORLESS 1 + #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(U) + #define U_SPI_SENSORLESS 1 + #endif #endif #if AXIS_HAS_STEALTHCHOP(U) #define U_HAS_STEALTHCHOP 1 #endif - #if ENABLED(SPI_ENDSTOPS) - #define U_SPI_SENSORLESS U_SENSORLESS - #endif #ifndef U_INTERPOLATE #define U_INTERPOLATE INTERPOLATE #endif @@ -1656,13 +1656,13 @@ #if AXIS_IS_TMC(V) #if defined(V_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(V) #define V_SENSORLESS 1 + #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(V) + #define V_SPI_SENSORLESS 1 + #endif #endif #if AXIS_HAS_STEALTHCHOP(V) #define V_HAS_STEALTHCHOP 1 #endif - #if ENABLED(SPI_ENDSTOPS) - #define V_SPI_SENSORLESS V_SENSORLESS - #endif #ifndef V_INTERPOLATE #define V_INTERPOLATE INTERPOLATE #endif @@ -1677,13 +1677,13 @@ #if AXIS_IS_TMC(W) #if defined(W_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(W) #define W_SENSORLESS 1 + #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(W) + #define W_SPI_SENSORLESS 1 + #endif #endif #if AXIS_HAS_STEALTHCHOP(W) #define W_HAS_STEALTHCHOP 1 #endif - #if ENABLED(SPI_ENDSTOPS) - #define W_SPI_SENSORLESS W_SENSORLESS - #endif #ifndef W_INTERPOLATE #define W_INTERPOLATE INTERPOLATE #endif @@ -1948,11 +1948,18 @@ #endif #endif -// -// Endstops and bed probe -// - -#define _USE_STOP(A,N,M,C) ((A##_HOME_TO_##M || (C+0)) && PIN_EXISTS(A##N##_##M)) +/** + * Endstop and probe flags + * - Set USE_(AXIS)_(MIN|MAX) flags for each used endstop that has a pin, including those for DIAG0 state. + * - Note: Dual X Carriage uses "X" and "X2" steppers, but X_MIN and X_MAX endstop states (i.e., not X2_MAX). + * - Set a HAS_(AXIS)_(MIN|MAX)_STATE flag for each endstop that has a state, including SPI Sensorless which don't use a pin. + * - Set a HAS_(AXIS)_STATE flag for each axis that has at least one state. + * - Consider (AXIS)_SAFETY_STOP for the case where the axis has a second endstop. + * Currently this must be distinct, but we can add a mechanism to use the same pin for sensorless + * or switches wired to the same pin, or for the single SPI stall state on the axis. + */ +#define _USE_STOP(A,N,M,C) ((ANY(A##_HOME_TO_##M, A##N##_SAFETY_STOP) || (C+0)) && PIN_EXISTS(A##N##_##M) && !A##_SPI_SENSORLESS) +#define _HAS_STATE(A,N,M) (USE_##A##N##_##M || (ANY(A##_HOME_TO_##M, A##N##_SAFETY_STOP) && A##_SPI_SENSORLESS)) #if _USE_STOP(X,,MIN,) #define USE_X_MIN 1 @@ -1960,139 +1967,239 @@ #if _USE_STOP(X,,MAX,ENABLED(DUAL_X_CARRIAGE)) #define USE_X_MAX 1 #endif -#if USE_X_MIN || USE_X_MAX - #define HAS_X_ENDSTOP 1 +#if _HAS_STATE(X,,MIN) + #define HAS_X_MIN_STATE 1 +#endif +#if _HAS_STATE(X,,MAX) + #define HAS_X_MAX_STATE 1 +#endif +#if HAS_X_MIN_STATE || HAS_X_MAX_STATE + #define HAS_X_STATE 1 #endif #if _USE_STOP(Y,,MIN,) #define USE_Y_MIN 1 -#elif _USE_STOP(Y,,MAX,) +#endif +#if _USE_STOP(Y,,MAX,) #define USE_Y_MAX 1 #endif -#if USE_Y_MIN || USE_Y_MAX - #define HAS_Y_ENDSTOP 1 +#if _HAS_STATE(Y,,MIN) + #define HAS_Y_MIN_STATE 1 +#endif +#if _HAS_STATE(Y,,MAX) + #define HAS_Y_MAX_STATE 1 +#endif +#if HAS_Y_MIN_STATE || HAS_Y_MAX_STATE + #define HAS_Y_STATE 1 #endif -#if _USE_STOP(Z,,MIN,ANY(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, HAS_DELTA_SENSORLESS_PROBING)) +#if _USE_STOP(Z,,MIN,ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)) #define USE_Z_MIN 1 - #if !HAS_DELTA_SENSORLESS_PROBING - #define HAS_Z_MIN_PIN 1 - #endif #endif #if _USE_STOP(Z,,MAX,) #define USE_Z_MAX 1 #endif -#if USE_Z_MIN || USE_Z_MAX - #define HAS_Z_ENDSTOP 1 +#if _HAS_STATE(Z,,MIN) + #define HAS_Z_MIN_STATE 1 +#endif +#if _HAS_STATE(Z,,MAX) + #define HAS_Z_MAX_STATE 1 +#endif +#if HAS_Z_MIN_STATE || HAS_Z_MAX_STATE + #define HAS_Z_STATE 1 #endif #if _USE_STOP(I,,MIN,) #define USE_I_MIN 1 -#elif _USE_STOP(I,,MAX,) +#endif +#if _USE_STOP(I,,MAX,) #define USE_I_MAX 1 #endif -#if USE_I_MIN || USE_I_MAX - #define HAS_I_ENDSTOP 1 +#if _HAS_STATE(I,,MIN) + #define HAS_I_MIN_STATE 1 +#endif +#if _HAS_STATE(I,,MAX) + #define HAS_I_MAX_STATE 1 +#endif +#if HAS_I_MIN_STATE || HAS_I_MAX_STATE + #define HAS_I_STATE 1 #endif #if _USE_STOP(J,,MIN,) #define USE_J_MIN 1 -#elif _USE_STOP(J,,MAX,) +#endif +#if _USE_STOP(J,,MAX,) #define USE_J_MAX 1 #endif -#if USE_J_MIN || USE_J_MAX - #define HAS_J_ENDSTOP 1 +#if _HAS_STATE(J,,MIN) + #define HAS_J_MIN_STATE 1 +#endif +#if _HAS_STATE(J,,MAX) + #define HAS_J_MAX_STATE 1 +#endif +#if HAS_J_MIN_STATE || HAS_J_MAX_STATE + #define HAS_J_STATE 1 #endif #if _USE_STOP(K,,MIN,) #define USE_K_MIN 1 -#elif _USE_STOP(K,,MAX,) +#endif +#if _USE_STOP(K,,MAX,) #define USE_K_MAX 1 #endif -#if USE_K_MIN || USE_K_MAX - #define HAS_K_ENDSTOP 1 +#if _HAS_STATE(K,,MIN) + #define HAS_K_MIN_STATE 1 +#endif +#if _HAS_STATE(K,,MAX) + #define HAS_K_MAX_STATE 1 +#endif +#if HAS_K_MIN_STATE || HAS_K_MAX_STATE + #define HAS_K_STATE 1 #endif #if _USE_STOP(U,,MIN,) #define USE_U_MIN 1 -#elif _USE_STOP(U,,MAX,) +#endif +#if _USE_STOP(U,,MAX,) #define USE_U_MAX 1 #endif -#if USE_U_MIN || USE_U_MAX - #define HAS_U_ENDSTOP 1 +#if _HAS_STATE(U,,MIN) + #define HAS_U_MIN_STATE 1 +#endif +#if _HAS_STATE(U,,MAX) + #define HAS_U_MAX_STATE 1 +#endif +#if HAS_U_MIN_STATE || HAS_U_MAX_STATE + #define HAS_U_STATE 1 #endif #if _USE_STOP(V,,MIN,) #define USE_V_MIN 1 -#elif _USE_STOP(V,,MAX,) +#endif +#if _USE_STOP(V,,MAX,) #define USE_V_MAX 1 #endif -#if USE_V_MIN || USE_V_MAX - #define HAS_V_ENDSTOP 1 +#if _HAS_STATE(V,,MIN) + #define HAS_V_MIN_STATE 1 +#endif +#if _HAS_STATE(V,,MAX) + #define HAS_V_MAX_STATE 1 +#endif +#if HAS_V_MIN_STATE || HAS_V_MAX_STATE + #define HAS_V_STATE 1 #endif #if _USE_STOP(W,,MIN,) #define USE_W_MIN 1 -#elif _USE_STOP(W,,MAX,) +#endif +#if _USE_STOP(W,,MAX,) #define USE_W_MAX 1 #endif -#if USE_W_MIN || USE_W_MAX - #define HAS_W_ENDSTOP 1 +#if _HAS_STATE(W,,MIN) + #define HAS_W_MIN_STATE 1 +#endif +#if _HAS_STATE(W,,MAX) + #define HAS_W_MAX_STATE 1 +#endif +#if HAS_W_MIN_STATE || HAS_W_MAX_STATE + #define HAS_W_STATE 1 #endif -#if ANY(DUAL_X_CARRIAGE, X_DUAL_ENDSTOPS) +#if ENABLED(X_DUAL_ENDSTOPS) #if _USE_STOP(X,2,MIN,) #define USE_X2_MIN 1 - #elif _USE_STOP(X,2,MAX,) + #endif + #if _USE_STOP(X,2,MAX,) #define USE_X2_MAX 1 #endif - #if USE_X2_MIN || USE_X2_MAX - #define HAS_X2_ENDSTOP 1 + #if _HAS_STATE(X,2,MIN) || HAS_X_MIN_STATE + #define HAS_X2_MIN_STATE 1 + #endif + #if _HAS_STATE(X,2,MAX) || HAS_X_MAX_STATE + #define HAS_X2_MAX_STATE 1 + #endif + #if HAS_X2_MIN_STATE || HAS_X2_MAX_STATE + #define HAS_X2_STATE 1 #endif #endif #if ENABLED(Y_DUAL_ENDSTOPS) #if _USE_STOP(Y,2,MIN,) #define USE_Y2_MIN 1 - #elif _USE_STOP(Y,2,MAX,) + #endif + #if _USE_STOP(Y,2,MAX,) #define USE_Y2_MAX 1 #endif - #if USE_Y2_MIN || USE_Y2_MAX - #define HAS_Y2_ENDSTOP 1 + #if _HAS_STATE(Y,2,MIN) || HAS_Y_MIN_STATE + #define HAS_Y2_MIN_STATE 1 + #endif + #if _HAS_STATE(Y,2,MAX) || HAS_Y_MAX_STATE + #define HAS_Y2_MAX_STATE 1 + #endif + #if HAS_Y2_MIN_STATE || HAS_Y2_MAX_STATE + #define HAS_Y2_STATE 1 #endif #endif #if ENABLED(Z_MULTI_ENDSTOPS) #if _USE_STOP(Z,2,MIN,) #define USE_Z2_MIN 1 - #elif _USE_STOP(Z,2,MAX,) + #endif + #if _USE_STOP(Z,2,MAX,) #define USE_Z2_MAX 1 #endif - #if USE_Z2_MIN || USE_Z2_MAX - #define HAS_Z2_ENDSTOP 1 + #if _HAS_STATE(Z,2,MIN) || HAS_Z_MIN_STATE + #define HAS_Z2_MIN_STATE 1 + #endif + #if _HAS_STATE(Z,2,MAX) || HAS_Z_MAX_STATE + #define HAS_Z2_MAX_STATE 1 + #endif + #if HAS_Z2_MIN_STATE || HAS_Z2_MAX_STATE + #define HAS_Z2_STATE 1 #endif #if NUM_Z_STEPPERS >= 3 #if _USE_STOP(Z,3,MIN,) #define USE_Z3_MIN 1 - #elif _USE_STOP(Z,3,MAX,) + #endif + #if _USE_STOP(Z,3,MAX,) #define USE_Z3_MAX 1 #endif - #if USE_Z3_MIN || USE_Z3_MAX - #define HAS_Z3_ENDSTOP 1 + #if _HAS_STATE(Z,3,MIN) || HAS_Z_MIN_STATE + #define HAS_Z3_MIN_STATE 1 + #endif + #if _HAS_STATE(Z,3,MAX) || HAS_Z_MAX_STATE + #define HAS_Z3_MAX_STATE 1 + #endif + #if HAS_Z3_MIN_STATE || HAS_Z3_MAX_STATE + #define HAS_Z3_STATE 1 #endif #endif #if NUM_Z_STEPPERS >= 4 #if _USE_STOP(Z,4,MIN,) #define USE_Z4_MIN 1 - #elif _USE_STOP(Z,4,MAX,) + #endif + #if _USE_STOP(Z,4,MAX,) #define USE_Z4_MAX 1 #endif - #if USE_Z4_MIN || USE_Z4_MAX - #define HAS_Z4_ENDSTOP 1 + #if _HAS_STATE(Z,4,MIN) || HAS_Z_MIN_STATE + #define HAS_Z4_MIN_STATE 1 + #endif + #if _HAS_STATE(Z,4,MAX) || HAS_Z_MAX_STATE + #define HAS_Z4_MAX_STATE 1 + #endif + #if HAS_Z4_MIN_STATE || HAS_Z4_MAX_STATE + #define HAS_Z4_STATE 1 #endif #endif #endif +#if NEED_Z_MIN_PROBE_PIN && PIN_EXISTS(Z_MIN_PROBE) + #define USE_Z_MIN_PROBE 1 +#endif +#if HAS_REAL_BED_PROBE + #define HAS_Z_PROBE_STATE 1 +#endif + #undef _USE_STOP /** @@ -2111,7 +2218,7 @@ #if USE_Y_MAX #define ENDSTOPPULLUP_YMAX #endif - #if HAS_Z_MIN_PIN + #if USE_Z_MIN #define ENDSTOPPULLUP_ZMIN #endif #if USE_Z_MAX diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 8eb8662c32..5933c8c396 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1388,19 +1388,13 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L /** * Require pin options and pins to be defined */ - #if ENABLED(SENSORLESS_PROBING) - #if ENABLED(DELTA) && !(X_SENSORLESS && Y_SENSORLESS && Z_SENSORLESS) - #error "SENSORLESS_PROBING requires TMC2130/2160/2209/5130/5160 drivers on X, Y, and Z and {X|Y|Z}_STALL_SENSITIVITY." - #elif !Z_SENSORLESS - #error "SENSORLESS_PROBING requires a TMC2130/2160/2209/5130/5160 driver on Z and Z_STALL_SENSITIVITY." - #endif - #elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) - #if !HAS_Z_MIN_PIN + #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #if !USE_Z_MIN #error "Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN requires the Z_MIN_PIN to be defined." #elif Z_MIN_PROBE_ENDSTOP_HIT_STATE != Z_MIN_ENDSTOP_HIT_STATE #error "Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN requires Z_MIN_ENDSTOP_HIT_STATE to match Z_MIN_PROBE_ENDSTOP_HIT_STATE." #endif - #elif !USE_Z_MIN_PROBE + #elif !PIN_EXISTS(Z_MIN_PROBE) #error "Z_MIN_PROBE_PIN must be defined if Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN is not enabled." #endif @@ -2323,53 +2317,53 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L /** * Endstop Tests */ -#if HAS_ENDSTOPS - // Delta and Cartesian use 3 homing endstops - #if NONE(IS_SCARA, SPI_ENDSTOPS) - #if X_HOME_TO_MIN && !PIN_EXISTS(X_MIN) - #error "X_MIN_PIN (or X_STOP_PIN) is required for X axis homing." - #elif X_HOME_TO_MAX && !PIN_EXISTS(X_MAX) - #error "X_MAX_PIN (or X_STOP_PIN) is required for X axis homing." - #elif Y_HOME_TO_MIN && !PIN_EXISTS(Y_MIN) - #error "Y_MIN_PIN (or Y_STOP_PIN) is required for Y axis homing." - #elif Y_HOME_TO_MAX && !PIN_EXISTS(Y_MAX) - #error "Y_MAX_PIN (or Y_STOP_PIN) is required for Y axis homing." - #elif I_HOME_TO_MIN && !PIN_EXISTS(I_MIN) - #error "I_MIN_PIN (or I_STOP_PIN) is required for I axis homing." - #elif I_HOME_TO_MAX && !PIN_EXISTS(I_MAX) - #error "I_MAX_PIN (or I_STOP_PIN) is required for I axis homing." - #elif J_HOME_TO_MIN && !PIN_EXISTS(J_MIN) - #error "J_MIN_PIN (or J_STOP_PIN) is required for J axis homing." - #elif J_HOME_TO_MAX && !PIN_EXISTS(J_MAX) - #error "J_MAX_PIN (or J_STOP_PIN) is required for J axis homing." - #elif K_HOME_TO_MIN && !PIN_EXISTS(K_MIN) - #error "K_MIN_PIN (or K_STOP_PIN) is required for K axis homing." - #elif K_HOME_TO_MAX && !PIN_EXISTS(K_MAX) - #error "K_MAX_PIN (or K_STOP_PIN) is required for K axis homing." - #elif U_HOME_TO_MIN && !PIN_EXISTS(U_MIN) - #error "U_MIN_PIN (or U_STOP_PIN) is required for U axis homing." - #elif U_HOME_TO_MAX && !PIN_EXISTS(U_MAX) - #error "U_MAX_PIN (or U_STOP_PIN) is required for U axis homing." - #elif V_HOME_TO_MIN && !PIN_EXISTS(V_MIN) - #error "V_MIN_PIN (or V_STOP_PIN) is required for V axis homing." - #elif V_HOME_TO_MAX && !PIN_EXISTS(V_MAX) - #error "V_MAX_PIN (or V_STOP_PIN) is required for V axis homing." - #elif W_HOME_TO_MIN && !PIN_EXISTS(W_MIN) - #error "W_MIN_PIN (or W_STOP_PIN) is required for W axis homing." - #elif W_HOME_TO_MAX && !PIN_EXISTS(W_MAX) - #error "W_MAX_PIN (or W_STOP_PIN) is required for W axis homing." - #endif - #endif - - // Z homing requirements - #if Z_HOME_TO_MAX && ENABLED(USE_PROBE_FOR_Z_HOMING) - #error "Z_HOME_DIR must be -1 when homing Z with the probe." - #elif ALL(HOMING_Z_WITH_PROBE, Z_MULTI_ENDSTOPS) - #error "Z_MULTI_ENDSTOPS is incompatible with USE_PROBE_FOR_Z_HOMING." +#if !IS_SCARA + // Delta and Cartesian require some kind of endstop + #if X_HOME_TO_MIN && !HAS_X_MIN_STATE + #error "X_MIN_PIN, X_STOP_PIN, or X_SPI_SENSORLESS is required for X axis homing." + #elif X_HOME_TO_MAX && !HAS_X_MAX_STATE + #error "X_MAX_PIN, X_STOP_PIN, or X_SPI_SENSORLESS is required for X axis homing." + #elif Y_HOME_TO_MIN && !HAS_Y_MIN_STATE + #error "Y_MIN_PIN, Y_STOP_PIN, or Y_SPI_SENSORLESS is required for Y axis homing." + #elif Y_HOME_TO_MAX && !HAS_Y_MAX_STATE + #error "Y_MAX_PIN, Y_STOP_PIN, or Y_SPI_SENSORLESS is required for Y axis homing." + #elif Z_HOME_TO_MIN && !HAS_Z_MIN_STATE + #error "Z_MIN_PIN, Z_STOP_PIN, or Z_SPI_SENSORLESS is required for Y axis homing." + #elif Z_HOME_TO_MAX && !HAS_Z_MAX_STATE + #error "Z_MAX_PIN, Z_STOP_PIN, or Z_SPI_SENSORLESS is required for Y axis homing." + #elif I_HOME_TO_MIN && !HAS_I_MIN_STATE + #error "I_MIN_PIN, I_STOP_PIN, or I_SPI_SENSORLESS is required for I axis homing." + #elif I_HOME_TO_MAX && !HAS_I_MAX_STATE + #error "I_MAX_PIN, I_STOP_PIN, or I_SPI_SENSORLESS is required for I axis homing." + #elif J_HOME_TO_MIN && !HAS_J_MIN_STATE + #error "J_MIN_PIN, J_STOP_PIN, or J_SPI_SENSORLESS is required for J axis homing." + #elif J_HOME_TO_MAX && !HAS_J_MAX_STATE + #error "J_MAX_PIN, J_STOP_PIN, or J_SPI_SENSORLESS is required for J axis homing." + #elif K_HOME_TO_MIN && !HAS_K_MIN_STATE + #error "K_MIN_PIN, K_STOP_PIN, or K_SPI_SENSORLESS is required for K axis homing." + #elif K_HOME_TO_MAX && !HAS_K_MAX_STATE + #error "K_MAX_PIN, K_STOP_PIN, or K_SPI_SENSORLESS is required for K axis homing." + #elif U_HOME_TO_MIN && !HAS_U_MIN_STATE + #error "U_MIN_PIN, U_STOP_PIN, or U_SPI_SENSORLESS is required for U axis homing." + #elif U_HOME_TO_MAX && !HAS_U_MAX_STATE + #error "U_MAX_PIN, U_STOP_PIN, or U_SPI_SENSORLESS is required for U axis homing." + #elif V_HOME_TO_MIN && !HAS_V_MIN_STATE + #error "V_MIN_PIN, V_STOP_PIN, or V_SPI_SENSORLESS is required for V axis homing." + #elif V_HOME_TO_MAX && !HAS_V_MAX_STATE + #error "V_MAX_PIN, V_STOP_PIN, or V_SPI_SENSORLESS is required for V axis homing." + #elif W_HOME_TO_MIN && !HAS_W_MIN_STATE + #error "W_MIN_PIN, W_STOP_PIN, or W_SPI_SENSORLESS is required for W axis homing." + #elif W_HOME_TO_MAX && !HAS_W_MAX_STATE + #error "W_MAX_PIN, W_STOP_PIN, or W_SPI_SENSORLESS is required for W axis homing." #endif #endif -#if ALL(HOME_Z_FIRST, USE_PROBE_FOR_Z_HOMING) +// Z homing with probe requirements +#if ALL(HOMING_Z_WITH_PROBE, Z_MULTI_ENDSTOPS) + #error "Z_MULTI_ENDSTOPS is incompatible with USE_PROBE_FOR_Z_HOMING (i.e., Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)." +#elif ALL(USE_PROBE_FOR_Z_HOMING, Z_HOME_TO_MAX) + #error "Z_HOME_DIR must be -1 when homing Z with the probe." +#elif ALL(USE_PROBE_FOR_Z_HOMING, HOME_Z_FIRST) #error "HOME_Z_FIRST can't be used when homing Z with a probe." #endif @@ -2381,26 +2375,32 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #if ENABLED(X_DUAL_ENDSTOPS) #if ENABLED(DELTA) #error "X_DUAL_ENDSTOPS is not compatible with DELTA." - #elif !HAS_X2_ENDSTOP - #error "X2 Endstop Pin must be defined for X_DUAL_ENDSTOPS." + #elif !HAS_X2_STATE + #error "Some kind of X2 Endstop must be defined for X_DUAL_ENDSTOPS." + #elif X_SPI_SENSORLESS && !AXIS_HAS_SPI(X2) + #error "All X Stepper Drivers must be SPI-capable to use SPI Endstops on X." #endif #endif #if ENABLED(Y_DUAL_ENDSTOPS) #if ENABLED(DELTA) #error "Y_DUAL_ENDSTOPS is not compatible with DELTA." - #elif !HAS_Y2_ENDSTOP - #error "Y2 Endstop Pin must be defined for Y_DUAL_ENDSTOPS." + #elif !HAS_Y2_STATE + #error "Some kind of Y2 Endstop must be defined for Y_DUAL_ENDSTOPS." + #elif Y_SPI_SENSORLESS && !AXIS_HAS_SPI(Y2) + #error "All Y Stepper Drivers must be SPI-capable to use SPI Endstops on Y." #endif #endif #if ENABLED(Z_MULTI_ENDSTOPS) #if ENABLED(DELTA) #error "Z_MULTI_ENDSTOPS is not compatible with DELTA." - #elif !HAS_Z2_ENDSTOP - #error "Z2 Endstop Pin must be defined for Z_MULTI_ENDSTOPS." - #elif NUM_Z_STEPPERS >= 3 && !HAS_Z3_ENDSTOP - #error "Z3 Endstop Pin must be defined for Z_MULTI_ENDSTOPS and Z3_DRIVER_TYPE." - #elif NUM_Z_STEPPERS >= 4 && !HAS_Z4_ENDSTOP - #error "Z4 Endstop Pin must be defined for Z_MULTI_ENDSTOPS and Z4_DRIVER_TYPE." + #elif !HAS_Z2_STATE + #error "Some kind of Z2 Endstop must be defined for Z_MULTI_ENDSTOPS." + #elif NUM_Z_STEPPERS >= 3 && !HAS_Z3_STATE + #error "Some kind of Z3 Endstop must be defined for Z_MULTI_ENDSTOPS and Z3_DRIVER_TYPE." + #elif NUM_Z_STEPPERS >= 4 && !HAS_Z4_STATE + #error "Some kind of Z4 Endstop must be defined for Z_MULTI_ENDSTOPS and Z4_DRIVER_TYPE." + #elif Z_SPI_SENSORLESS && !(AXIS_HAS_SPI(Z2) && (NUM_Z_STEPPERS < 3 || AXIS_HAS_SPI(Z3)) && (NUM_Z_STEPPERS < 4 || AXIS_HAS_SPI(Z4))) + #error "All Z Stepper Drivers must be SPI-capable to use SPI Endstops on Z." #endif #endif diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index 4dd3d7a369..d76c10dfdb 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -70,9 +70,9 @@ void ESDiag::draw() { DWINUI::drawButton(BTN_Continue, 86, 250); DWINUI::cursor.y = 80; #define ES_LABEL(S) draw_es_label(F(STR_##S)) - TERN_(USE_X_MIN, ES_LABEL(X_MIN)); TERN_(USE_X_MAX, ES_LABEL(X_MAX)); - TERN_(USE_Y_MIN, ES_LABEL(Y_MIN)); TERN_(USE_Y_MAX, ES_LABEL(Y_MAX)); - TERN_(HAS_Z_MIN_PIN, ES_LABEL(Z_MIN)); TERN_(USE_Z_MAX, ES_LABEL(Z_MAX)); + TERN_(USE_X_MIN, ES_LABEL(X_MIN)); TERN_(USE_X_MAX, ES_LABEL(X_MAX)); + TERN_(USE_Y_MIN, ES_LABEL(Y_MIN)); TERN_(USE_Y_MAX, ES_LABEL(Y_MAX)); + TERN_(USE_Z_MIN, ES_LABEL(Z_MIN)); TERN_(USE_Z_MAX, ES_LABEL(Z_MAX)); TERN_(HAS_FILAMENT_SENSOR, draw_es_label(F(STR_FILAMENT))); update(); } @@ -80,9 +80,9 @@ void ESDiag::draw() { void ESDiag::update() { DWINUI::cursor.y = 80; #define ES_REPORT(S) draw_es_state(READ(S##_PIN) == S##_ENDSTOP_HIT_STATE) - TERN_(USE_X_MIN, ES_REPORT(X_MIN)); TERN_(USE_X_MAX, ES_REPORT(X_MAX)); - TERN_(USE_Y_MIN, ES_REPORT(Y_MIN)); TERN_(USE_Y_MAX, ES_REPORT(Y_MAX)); - TERN_(HAS_Z_MIN_PIN, ES_REPORT(Z_MIN)); TERN_(USE_Z_MAX, ES_REPORT(Z_MAX)); + TERN_(USE_X_MIN, ES_REPORT(X_MIN)); TERN_(USE_X_MAX, ES_REPORT(X_MAX)); + TERN_(USE_Y_MIN, ES_REPORT(Y_MIN)); TERN_(USE_Y_MAX, ES_REPORT(Y_MAX)); + TERN_(USE_Z_MIN, ES_REPORT(Z_MIN)); TERN_(USE_Z_MAX, ES_REPORT(Z_MAX)); TERN_(HAS_FILAMENT_SENSOR, draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE)); dwinUpdateLCD(); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp index 1d81649444..6105591d15 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp @@ -79,7 +79,7 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) { #else PIN_DISABLED(3, 3, PSTR(STR_Y_MIN), Y_MIN) #endif - #if HAS_Z_MIN_PIN + #if USE_Z_MIN PIN_ENABLED (5, 3, PSTR(STR_Z_MIN), Z_MIN, Z_MIN_ENDSTOP_HIT_STATE) #else PIN_DISABLED(5, 3, PSTR(STR_Z_MIN), Z_MIN) diff --git a/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp index c46a532d9a..a759f8677e 100644 --- a/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp +++ b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp @@ -45,36 +45,56 @@ #if PIN_EXISTS(MT_DET_2) bool mt_det2_sta; #endif - #if HAS_X_ENDSTOP - bool endstopx1_sta; + #if USE_X_MIN + bool endstopx1_min; #else - constexpr static bool endstopx1_sta = true; + constexpr static bool endstopx1_min = true; #endif - #if HAS_X2_ENDSTOP + #if USE_X_MAX + bool endstopx1_max; + #else + constexpr static bool endstopx1_max = true; + #endif + #if USE_X2_MIN bool endstopx2_sta; #else constexpr static bool endstopx2_sta = true; #endif - #if HAS_Y_ENDSTOP + #if USE_Y_MIN bool endstopy1_sta; #else constexpr static bool endstopy1_sta = true; #endif - #if HAS_Y2_ENDSTOP + #if USE_Y2_MIN bool endstopy2_sta; #else constexpr static bool endstopy2_sta = true; #endif - #if HAS_Z_ENDSTOP - bool endstopz1_sta; + #if USE_Z_MIN + bool endstopz1_min; #else - constexpr static bool endstopz1_sta = true; + constexpr static bool endstopz1_min = true; #endif - #if HAS_Z2_ENDSTOP + #if USE_Z_MAX + bool endstopz1_max; + #else + constexpr static bool endstopz1_max = true; + #endif + #if USE_Z2_MIN || USE_Z2_MAX bool endstopz2_sta; #else constexpr static bool endstopz2_sta = true; #endif + #if USE_Z3_MIN || USE_Z3_MAX + bool endstopz3_sta; + #else + constexpr static bool endstopz3_sta = true; + #endif + #if USE_Z4_MIN || USE_Z4_MAX + bool endstopz4_sta; + #else + constexpr static bool endstopz4_sta = true; + #endif #define ESTATE(S) (READ(S##_PIN) == S##_ENDSTOP_HIT_STATE) @@ -87,12 +107,28 @@ #if PIN_EXISTS(MT_DET_2) mt_det2_sta = (READ(MT_DET_2_PIN) == LOW); #endif - TERN_(HAS_X_ENDSTOP, endstopx1_sta = ESTATE(TERN(USE_X_MIN, X_MIN, X_MAX))); - TERN_(HAS_X2_ENDSTOP, endstopx2_sta = ESTATE(TERN(USE_X2_MIN, X2_MIN, X2_MAX))); - TERN_(HAS_Y_ENDSTOP, endstopy1_sta = ESTATE(TERN(USE_Y_MIN, Y_MIN, Y_MAX))); - TERN_(HAS_Y2_ENDSTOP, endstopy2_sta = ESTATE(TERN(USE_Y2_MIN, Y2_MIN, Y2_MAX))); - TERN_(HAS_Z_ENDSTOP, endstopz1_sta = ESTATE(TERN(HAS_Z_MIN_PIN, Z_MIN, Z_MAX))); - TERN_(HAS_Z2_ENDSTOP, endstopz2_sta = ESTATE(TERN(USE_Z2_MIN, Z2_MIN, Z2_MAX))); + TERN_(USE_X_MIN, endstopx1_min = ESTATE(X_MIN)); + TERN_(USE_X_MAX, endstopx1_max = ESTATE(X_MAX)); + #if USE_X2_MIN || USE_X2_MAX + endstopx2_sta = ESTATE(TERN(USE_X2_MIN, X2_MIN, X2_MAX)); + #endif + #if USE_Y_MIN || USE_Y_MAX + endstopy1_sta = ESTATE(TERN(USE_Y_MIN, Y_MIN, Y_MAX)); + #endif + #if USE_Y2_MIN || USE_Y2_MAX + endstopy2_sta = ESTATE(TERN(USE_Y2_MIN, Y2_MIN, Y2_MAX)); + #endif + TERN_(USE_Z_MIN, endstopz1_min = ESTATE(Z_MIN)); + TERN_(USE_Z_MAX, endstopz1_max = ESTATE(Z_MAX)); + #if USE_Z2_MIN || USE_Z2_MAX + endstopz2_sta = ESTATE(TERN(USE_Z2_MIN, Z2_MIN, Z2_MAX)); + #endif + #if USE_Z3_MIN || USE_Z3_MAX + endstopz3_sta = ESTATE(TERN(USE_Z3_MIN, Z3_MIN, Z3_MAX)); + #endif + #if USE_Z4_MIN || USE_Z4_MAX + endstopz4_sta = ESTATE(TERN(USE_Z4_MIN, Z4_MIN, Z4_MAX)); + #endif } void test_gpio_readlevel_H() { @@ -104,12 +140,28 @@ #if PIN_EXISTS(MT_DET_2) mt_det2_sta = (READ(MT_DET_2_PIN) == HIGH); #endif - TERN_(HAS_X_ENDSTOP, endstopx1_sta = !ESTATE(TERN(USE_X_MIN, X_MIN, X_MAX))); - TERN_(HAS_X2_ENDSTOP, endstopx2_sta = !ESTATE(TERN(USE_X2_MIN, X2_MIN, X2_MAX))); - TERN_(HAS_Y_ENDSTOP, endstopy1_sta = !ESTATE(TERN(USE_Y_MIN, Y_MIN, Y_MAX))); - TERN_(HAS_Y2_ENDSTOP, endstopy2_sta = !ESTATE(TERN(USE_Y2_MIN, Y2_MIN, Y2_MAX))); - TERN_(HAS_Z_ENDSTOP, endstopz1_sta = !ESTATE(TERN(HAS_Z_MIN_PIN, Z_MIN, Z_MAX))); - TERN_(HAS_Z2_ENDSTOP, endstopz2_sta = !ESTATE(TERN(USE_Z2_MIN, Z2_MIN, Z2_MAX))); + TERN_(USE_X_MIN, endstopx1_min = !ESTATE(X_MIN)); + TERN_(USE_X_MAX, endstopx1_max = !ESTATE(X_MAX)); + #if USE_X2_MIN || USE_X2_MAX + endstopx2_sta = !ESTATE(TERN(USE_X2_MIN, X2_MIN, X2_MAX)); + #endif + #if USE_Y_MIN || USE_Y_MAX + endstopy1_sta = !ESTATE(TERN(USE_Y_MIN, Y_MIN, Y_MAX)); + #endif + #if USE_Y2_MIN || USE_Y2_MAX + endstopy2_sta = !ESTATE(TERN(USE_Y2_MIN, Y2_MIN, Y2_MAX)); + #endif + TERN_(USE_Z_MIN, endstopz1_min = !ESTATE(Z_MIN)); + TERN_(USE_Z_MAX, endstopz1_max = !ESTATE(Z_MAX)); + #if USE_Z2_MIN || USE_Z2_MAX + endstopz2_sta = !ESTATE(TERN(USE_Z2_MIN, Z2_MIN, Z2_MAX)); + #endif + #if USE_Z3_MIN || USE_Z3_MAX + endstopz3_sta = !ESTATE(TERN(USE_Z3_MIN, Z3_MIN, Z3_MAX)); + #endif + #if USE_Z4_MIN || USE_Z4_MAX + endstopz4_sta = !ESTATE(TERN(USE_Z4_MIN, Z4_MIN, Z4_MAX)); + #endif } #include "../../../libs/buzzer.h" @@ -185,7 +237,7 @@ else disp_det_error(); - if (endstopx1_sta && endstopy1_sta && endstopz1_sta && endstopz2_sta) + if (endstopx1_min && endstopx1_max && endstopy1_sta && endstopz1_min && endstopz1_max && endstopz2_sta && endstopz3_sta && endstopz4_sta) disp_Limit_ok(); else disp_Limit_error(); @@ -247,7 +299,9 @@ #endif } - if (endstopx1_sta && endstopx2_sta && endstopy1_sta && endstopy2_sta && endstopz1_sta && endstopz2_sta) { + if ( endstopx1_min && endstopx1_max && endstopx2_sta && endstopy1_sta && endstopy2_sta + && endstopz1_min && endstopz1_max && endstopz2_sta && endstopz3_sta && endstopz4_sta + ) { // nothing here } else { diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 4e9b302263..edbf78ed76 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -102,9 +102,10 @@ void menu_advanced_settings(); #if ENABLED(LCD_ENDSTOP_TEST) - #define __STOP_ITEM(F,S) PSTRING_ITEM_F_P(F, TEST(stops, S) ? PSTR(STR_ENDSTOP_HIT) : PSTR(STR_ENDSTOP_OPEN), SS_FULL) + #define __STOP_ITEM(F,S) PSTRING_ITEM_F_P(F, TEST(stops, S) ? PSTR(STR_ENDSTOP_HIT) : PSTR(STR_ENDSTOP_OPEN), SS_FULL); #define _STOP_ITEM(L,S) __STOP_ITEM(F(L), S) - #define STOP_ITEM(A,I) _STOP_ITEM(STRINGIFY(A) STRINGIFY(I) " " TERN(A##_HOME_TO_MAX, "Max", "Min"), A##I##_ENDSTOP) + #define STOP_ITEM(A,I,M,L) TERN(HAS_##A##I##_##M_STATE, _STOP_ITEM, _IF_1_ELSE)(STRINGIFY(A) STRINGIFY(I) " " STRINGIFY(L), A##I##_##M) + #define STOP_MINMAX(A,I) STOP_ITEM(A,,MIN,"Min") STOP_ITEM(A,,MAX,"Max") #define FIL_ITEM(N) PSTRING_ITEM_N_P(N-1, MSG_FILAMENT_EN, (READ(FIL_RUNOUT##N##_PIN) != FIL_RUNOUT##N##_STATE) ? PSTR("PRESENT") : PSTR("out"), SS_FULL); static void endstop_test() { @@ -120,48 +121,12 @@ void menu_advanced_settings(); START_SCREEN(); STATIC_ITEM_F(GET_TEXT_F(MSG_ENDSTOP_TEST), SS_DEFAULT|SS_INVERT); - #if HAS_X_ENDSTOP - STOP_ITEM(X,); - #if ENABLED(X_DUAL_ENDSTOPS) - STOP_ITEM(X,2); - #endif - #endif - #if HAS_Y_ENDSTOP - STOP_ITEM(Y,); - #if ENABLED(Y_DUAL_ENDSTOPS) - STOP_ITEM(Y,2); - #endif - #endif - #if HAS_Z_ENDSTOP - STOP_ITEM(Z,); - #if ENABLED(Z_MULTI_ENDSTOPS) - STOP_ITEM(Z,2); - #if NUM_Z_STEPPERS >= 3 - STOP_ITEM(Z,3); - #if NUM_Z_STEPPERS >= 4 - STOP_ITEM(Z,4); - #endif - #endif - #endif - #endif - #if HAS_I_ENDSTOP - STOP_ITEM(I,); - #endif - #if HAS_J_ENDSTOP - STOP_ITEM(J,); - #endif - #if HAS_K_ENDSTOP - STOP_ITEM(K,); - #endif - #if HAS_U_ENDSTOP - STOP_ITEM(U,); - #endif - #if HAS_V_ENDSTOP - STOP_ITEM(V,); - #endif - #if HAS_W_ENDSTOP - STOP_ITEM(W,); - #endif + STOP_MINMAX(X,) STOP_MINMAX(X,2) + STOP_MINMAX(Y,) STOP_MINMAX(Y,2) + STOP_MINMAX(Z,) STOP_MINMAX(Z,2) STOP_MINMAX(Z,3) STOP_MINMAX(Z,4) + STOP_MINMAX(I,) STOP_MINMAX(J,) STOP_MINMAX(K,) + STOP_MINMAX(U,) STOP_MINMAX(V,) STOP_MINMAX(W,) + #if HAS_BED_PROBE && !HAS_DELTA_SENSORLESS_PROBING __STOP_ITEM(GET_TEXT_F(MSG_Z_PROBE), Z_MIN_PROBE); #endif diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 3c1fcc72a9..0f060f5720 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -138,7 +138,7 @@ void Endstops::init() { #if USE_Y2_MAX _INIT_ENDSTOP(MAX,Y,2); #endif - #if HAS_Z_MIN_PIN + #if USE_Z_MIN _INIT_ENDSTOP(MIN,Z,); #endif #if USE_Z_MAX @@ -315,7 +315,7 @@ void Endstops::event_handler() { SERIAL_ECHOPGM(" " STRINGIFY(A) ":", planner.triggered_position_mm(_AXIS(A))); _SET_STOP_CHAR(A,C); }while(0) #define _ENDSTOP_HIT_TEST(A,C) \ - if (TERN0(USE_##A##_MIN, TEST(hit_state, ES_ENUM(A,MIN))) || TERN0(USE_##A##_MAX, TEST(hit_state, ES_ENUM(A,MAX)))) \ + if (TERN0(HAS_##A##_MIN_STATE, TEST(hit_state, ES_ENUM(A,MIN))) || TERN0(HAS_##A##_MAX_STATE, TEST(hit_state, ES_ENUM(A,MAX)))) \ _ENDSTOP_HIT_ECHO(A,C) #define ENDSTOP_HIT_TEST_X() _ENDSTOP_HIT_TEST(X,'X') @@ -504,11 +504,6 @@ void __O2 Endstops::report_states() { } // Endstops::report_states -#define __ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX -#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN -#define _ENDSTOP_HIT_STATE(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_HIT_STATE -#define _ENDSTOP(AXIS, MINMAX) __ENDSTOP(AXIS, MINMAX) - /** * Called from interrupt context by the Endstop ISR or Stepper ISR! * Read endstops to get their current states, register hits for all @@ -521,7 +516,9 @@ void Endstops::update() { #endif // Macros to update / copy the live_state - #define UPDATE_LIVE_STATE(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ_ENDSTOP(_ENDSTOP_PIN(AXIS, MINMAX)) == _ENDSTOP_HIT_STATE(AXIS, MINMAX))) + #define _ES_PIN(A,M) A##_##M##_PIN + #define _ES_HIT(A,M) A##_##M##_ENDSTOP_HIT_STATE + #define UPDATE_LIVE_STATE(AXIS, MINMAX) SET_BIT_TO(live_state, ES_ENUM(AXIS, MINMAX), (READ_ENDSTOP(_ES_PIN(AXIS, MINMAX)) == _ES_HIT(AXIS, MINMAX))) #define COPY_LIVE_STATE(SRC_BIT, DST_BIT) SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT)) #if ENABLED(G38_PROBE_TARGET) @@ -560,7 +557,7 @@ void Endstops::update() { /** * Check and update endstops */ - #if USE_X_MIN && !X_SPI_SENSORLESS + #if USE_X_MIN UPDATE_LIVE_STATE(X, MIN); #if ENABLED(X_DUAL_ENDSTOPS) #if USE_X2_MIN @@ -571,7 +568,7 @@ void Endstops::update() { #endif #endif - #if USE_X_MAX && !X_SPI_SENSORLESS + #if USE_X_MAX UPDATE_LIVE_STATE(X, MAX); #if ENABLED(X_DUAL_ENDSTOPS) #if USE_X2_MAX @@ -582,7 +579,7 @@ void Endstops::update() { #endif #endif - #if USE_Y_MIN && !Y_SPI_SENSORLESS + #if USE_Y_MIN UPDATE_LIVE_STATE(Y, MIN); #if ENABLED(Y_DUAL_ENDSTOPS) #if USE_Y2_MIN @@ -593,7 +590,7 @@ void Endstops::update() { #endif #endif - #if USE_Y_MAX && !Y_SPI_SENSORLESS + #if USE_Y_MAX UPDATE_LIVE_STATE(Y, MAX); #if ENABLED(Y_DUAL_ENDSTOPS) #if USE_Y2_MAX @@ -605,159 +602,84 @@ void Endstops::update() { #endif #if USE_Z_MIN && NONE(Z_SPI_SENSORLESS, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) - #if HAS_Z_MIN_PIN - UPDATE_LIVE_STATE(Z, MIN); - #endif - #if ENABLED(Z_MULTI_ENDSTOPS) - #if USE_Z2_MIN - UPDATE_LIVE_STATE(Z2, MIN); - #else - COPY_LIVE_STATE(Z_MIN, Z2_MIN); - #endif - #if NUM_Z_STEPPERS >= 3 - #if USE_Z3_MIN - UPDATE_LIVE_STATE(Z3, MIN); - #else - COPY_LIVE_STATE(Z_MIN, Z3_MIN); - #endif - #endif - #if NUM_Z_STEPPERS >= 4 - #if USE_Z4_MIN - UPDATE_LIVE_STATE(Z4, MIN); - #else - COPY_LIVE_STATE(Z_MIN, Z4_MIN); - #endif - #endif - #endif + UPDATE_LIVE_STATE(Z, MIN); + #endif + #if USE_Z2_MIN + UPDATE_LIVE_STATE(Z2, MIN); + #elif HAS_Z2_MIN_STATE + COPY_LIVE_STATE(Z_MIN, Z2_MIN); + #endif + #if USE_Z3_MIN + UPDATE_LIVE_STATE(Z3, MIN); + #elif HAS_Z3_MIN_STATE + COPY_LIVE_STATE(Z_MIN, Z3_MIN); + #endif + #if USE_Z4_MIN + UPDATE_LIVE_STATE(Z4, MIN); + #elif HAS_Z4_MIN_STATE + COPY_LIVE_STATE(Z_MIN, Z4_MIN); #endif - #if HAS_BED_PROBE + #if HAS_REAL_BED_PROBE // When closing the gap check the enabled probe if (probe_switch_activated()) UPDATE_LIVE_STATE(Z, TERN(USE_Z_MIN_PROBE, MIN_PROBE, MIN)); #endif - #if USE_Z_MAX && !Z_SPI_SENSORLESS - // Check both Z dual endstops - #if ENABLED(Z_MULTI_ENDSTOPS) - UPDATE_LIVE_STATE(Z, MAX); - #if USE_Z2_MAX - UPDATE_LIVE_STATE(Z2, MAX); - #else - COPY_LIVE_STATE(Z_MAX, Z2_MAX); - #endif - #if NUM_Z_STEPPERS >= 3 - #if USE_Z3_MAX - UPDATE_LIVE_STATE(Z3, MAX); - #else - COPY_LIVE_STATE(Z_MAX, Z3_MAX); - #endif - #endif - #if NUM_Z_STEPPERS >= 4 - #if USE_Z4_MAX - UPDATE_LIVE_STATE(Z4, MAX); - #else - COPY_LIVE_STATE(Z_MAX, Z4_MAX); - #endif - #endif - #elif TERN1(USE_Z_MIN_PROBE, Z_MAX_PIN != Z_MIN_PROBE_PIN) - // If this pin isn't the bed probe it's the Z endstop - UPDATE_LIVE_STATE(Z, MAX); - #endif + #if USE_Z_MAX + UPDATE_LIVE_STATE(Z, MAX); + #endif + #if USE_Z2_MAX + UPDATE_LIVE_STATE(Z2, MAX); + #elif HAS_Z2_MAX_STATE + COPY_LIVE_STATE(Z_MAX, Z2_MAX); + #endif + #if USE_Z3_MAX + UPDATE_LIVE_STATE(Z3, MAX); + #elif HAS_Z3_MAX_STATE + COPY_LIVE_STATE(Z_MAX, Z3_MAX); + #endif + #if USE_Z4_MAX + UPDATE_LIVE_STATE(Z4, MAX); + #elif HAS_Z4_MAX_STATE + COPY_LIVE_STATE(Z_MAX, Z4_MAX); #endif - #if USE_I_MIN && !I_SPI_SENSORLESS - #if ENABLED(I_DUAL_ENDSTOPS) - UPDATE_LIVE_STATE(I, MIN); - #else - UPDATE_LIVE_STATE(I, MIN); - #endif + #if USE_I_MIN + UPDATE_LIVE_STATE(I, MIN); #endif - - #if USE_I_MAX && !I_SPI_SENSORLESS - #if ENABLED(I_DUAL_ENDSTOPS) - UPDATE_LIVE_STATE(I, MAX); - #else - UPDATE_LIVE_STATE(I, MAX); - #endif + #if USE_I_MAX + UPDATE_LIVE_STATE(I, MAX); #endif - - #if USE_J_MIN && !J_SPI_SENSORLESS - #if ENABLED(J_DUAL_ENDSTOPS) - UPDATE_LIVE_STATE(J, MIN); - #else - UPDATE_LIVE_STATE(J, MIN); - #endif + #if USE_J_MIN + UPDATE_LIVE_STATE(J, MIN); #endif - - #if USE_J_MAX && !J_SPI_SENSORLESS - #if ENABLED(J_DUAL_ENDSTOPS) - UPDATE_LIVE_STATE(J, MAX); - #else - UPDATE_LIVE_STATE(J, MAX); - #endif + #if USE_J_MAX + UPDATE_LIVE_STATE(J, MAX); #endif - - #if USE_K_MIN && !K_SPI_SENSORLESS - #if ENABLED(K_DUAL_ENDSTOPS) - UPDATE_LIVE_STATE(K, MIN); - #else - UPDATE_LIVE_STATE(K, MIN); - #endif + #if USE_K_MIN + UPDATE_LIVE_STATE(K, MIN); #endif - - #if USE_K_MAX && !K_SPI_SENSORLESS - #if ENABLED(K_DUAL_ENDSTOPS) - UPDATE_LIVE_STATE(K, MAX); - #else - UPDATE_LIVE_STATE(K, MAX); - #endif + #if USE_K_MAX + UPDATE_LIVE_STATE(K, MAX); #endif - - #if USE_U_MIN && !U_SPI_SENSORLESS - #if ENABLED(U_DUAL_ENDSTOPS) - UPDATE_LIVE_STATE(U, MIN); - #else - UPDATE_LIVE_STATE(U, MIN); - #endif + #if USE_U_MIN + UPDATE_LIVE_STATE(U, MIN); #endif - - #if USE_U_MAX && !U_SPI_SENSORLESS - #if ENABLED(U_DUAL_ENDSTOPS) - UPDATE_LIVE_STATE(U, MAX); - #else - UPDATE_LIVE_STATE(U, MAX); - #endif + #if USE_U_MAX + UPDATE_LIVE_STATE(U, MAX); #endif - - #if USE_V_MIN && !V_SPI_SENSORLESS - #if ENABLED(V_DUAL_ENDSTOPS) - UPDATE_LIVE_STATE(V, MIN); - #else - UPDATE_LIVE_STATE(V, MIN); - #endif + #if USE_V_MIN + UPDATE_LIVE_STATE(V, MIN); #endif - #if USE_V_MAX && !V_SPI_SENSORLESS - #if ENABLED(O_DUAL_ENDSTOPS) - UPDATE_LIVE_STATE(V, MAX); - #else - UPDATE_LIVE_STATE(V, MAX); - #endif + #if USE_V_MAX + UPDATE_LIVE_STATE(V, MAX); #endif - - #if USE_W_MIN && !W_SPI_SENSORLESS - #if ENABLED(W_DUAL_ENDSTOPS) - UPDATE_LIVE_STATE(W, MIN); - #else - UPDATE_LIVE_STATE(W, MIN); - #endif + #if USE_W_MIN + UPDATE_LIVE_STATE(W, MIN); #endif - #if USE_W_MAX && !W_SPI_SENSORLESS - #if ENABLED(W_DUAL_ENDSTOPS) - UPDATE_LIVE_STATE(W, MAX); - #else - UPDATE_LIVE_STATE(W, MAX); - #endif + #if USE_W_MAX + UPDATE_LIVE_STATE(W, MAX); #endif #if ENDSTOP_NOISE_THRESHOLD @@ -788,11 +710,11 @@ void Endstops::update() { #define TEST_ENDSTOP(ENDSTOP) (TEST(state(), ENDSTOP)) // Record endstop was hit - #define _ENDSTOP_HIT(AXIS, MINMAX) SBI(hit_state, _ENDSTOP(AXIS, MINMAX)) + #define _ENDSTOP_HIT(AXIS, MINMAX) SBI(hit_state, ES_ENUM(AXIS, MINMAX)) // Call the endstop triggered routine for single endstops #define PROCESS_ENDSTOP(AXIS, MINMAX) do { \ - if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX))) { \ + if (TEST_ENDSTOP(ES_ENUM(AXIS, MINMAX))) { \ _ENDSTOP_HIT(AXIS, MINMAX); \ planner.endstop_triggered(_AXIS(AXIS)); \ } \ @@ -801,7 +723,7 @@ void Endstops::update() { // Core Sensorless Homing needs to test an Extra Pin #define CORE_DIAG(QQ,A,MM) (CORE_IS_##QQ && A##_SENSORLESS && !A##_SPI_SENSORLESS && USE_##A##_##MM) #define PROCESS_CORE_ENDSTOP(A1,M1,A2,M2) do { \ - if (TEST_ENDSTOP(_ENDSTOP(A1,M1))) { \ + if (TEST_ENDSTOP(ES_ENUM(A1,M1))) { \ _ENDSTOP_HIT(A2,M2); \ planner.endstop_triggered(_AXIS(A2)); \ } \ @@ -809,7 +731,7 @@ void Endstops::update() { // Call the endstop triggered routine for dual endstops #define PROCESS_DUAL_ENDSTOP(A, MINMAX) do { \ - const byte dual_hit = TEST_ENDSTOP(_ENDSTOP(A, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(A##2, MINMAX)) << 1); \ + const byte dual_hit = TEST_ENDSTOP(ES_ENUM(A, MINMAX)) | (TEST_ENDSTOP(ES_ENUM(A##2, MINMAX)) << 1); \ if (dual_hit) { \ _ENDSTOP_HIT(A, MINMAX); \ /* if not performing home or if both endstops were triggered during homing... */ \ @@ -819,7 +741,7 @@ void Endstops::update() { }while(0) #define PROCESS_TRIPLE_ENDSTOP(A, MINMAX) do { \ - const byte triple_hit = TEST_ENDSTOP(_ENDSTOP(A, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(A##2, MINMAX)) << 1) | (TEST_ENDSTOP(_ENDSTOP(A##3, MINMAX)) << 2); \ + const byte triple_hit = TEST_ENDSTOP(ES_ENUM(A, MINMAX)) | (TEST_ENDSTOP(ES_ENUM(A##2, MINMAX)) << 1) | (TEST_ENDSTOP(ES_ENUM(A##3, MINMAX)) << 2); \ if (triple_hit) { \ _ENDSTOP_HIT(A, MINMAX); \ /* if not performing home or if both endstops were triggered during homing... */ \ @@ -829,7 +751,7 @@ void Endstops::update() { }while(0) #define PROCESS_QUAD_ENDSTOP(A, MINMAX) do { \ - const byte quad_hit = TEST_ENDSTOP(_ENDSTOP(A, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(A##2, MINMAX)) << 1) | (TEST_ENDSTOP(_ENDSTOP(A##3, MINMAX)) << 2) | (TEST_ENDSTOP(_ENDSTOP(A##4, MINMAX)) << 3); \ + const byte quad_hit = TEST_ENDSTOP(ES_ENUM(A, MINMAX)) | (TEST_ENDSTOP(ES_ENUM(A##2, MINMAX)) << 1) | (TEST_ENDSTOP(ES_ENUM(A##3, MINMAX)) << 2) | (TEST_ENDSTOP(ES_ENUM(A##4, MINMAX)) << 3); \ if (quad_hit) { \ _ENDSTOP_HIT(A, MINMAX); \ /* if not performing home or if both endstops were triggered during homing... */ \ @@ -876,7 +798,7 @@ void Endstops::update() { #if HAS_X_AXIS if (stepper.axis_is_moving(X_AXIS)) { if (!stepper.motor_direction(X_AXIS_HEAD)) { // -direction - #if USE_X_MIN || (X_SPI_SENSORLESS && X_HOME_TO_MIN) + #if HAS_X_MIN_STATE PROCESS_ENDSTOP_X(MIN); #if CORE_DIAG(XY, Y, MIN) PROCESS_CORE_ENDSTOP(Y,MIN,X,MIN); @@ -890,7 +812,7 @@ void Endstops::update() { #endif } else { // +direction - #if USE_X_MAX || (X_SPI_SENSORLESS && X_HOME_TO_MAX) + #if HAS_X_MAX_STATE PROCESS_ENDSTOP_X(MAX); #if CORE_DIAG(XY, Y, MIN) PROCESS_CORE_ENDSTOP(Y,MIN,X,MAX); @@ -909,7 +831,7 @@ void Endstops::update() { #if HAS_Y_AXIS if (stepper.axis_is_moving(Y_AXIS)) { if (!stepper.motor_direction(Y_AXIS_HEAD)) { // -direction - #if USE_Y_MIN || (Y_SPI_SENSORLESS && Y_HOME_TO_MIN) + #if HAS_Y_MIN_STATE PROCESS_ENDSTOP_Y(MIN); #if CORE_DIAG(XY, X, MIN) PROCESS_CORE_ENDSTOP(X,MIN,Y,MIN); @@ -923,7 +845,7 @@ void Endstops::update() { #endif } else { // +direction - #if USE_Y_MAX || (Y_SPI_SENSORLESS && Y_HOME_TO_MAX) + #if HAS_Y_MAX_STATE PROCESS_ENDSTOP_Y(MAX); #if CORE_DIAG(XY, X, MIN) PROCESS_CORE_ENDSTOP(X,MIN,Y,MAX); @@ -942,34 +864,34 @@ void Endstops::update() { #if HAS_Z_AXIS if (stepper.axis_is_moving(Z_AXIS)) { if (!stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up. - - #if USE_Z_MIN || (Z_SPI_SENSORLESS && Z_HOME_TO_MIN) - if ( TERN1(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, z_probe_enabled) - && TERN1(USE_Z_MIN_PROBE, !z_probe_enabled) - ) PROCESS_ENDSTOP_Z(MIN); - #if CORE_DIAG(XZ, X, MIN) - PROCESS_CORE_ENDSTOP(X,MIN,Z,MIN); - #elif CORE_DIAG(XZ, X, MAX) - PROCESS_CORE_ENDSTOP(X,MAX,Z,MIN); - #elif CORE_DIAG(YZ, Y, MIN) - PROCESS_CORE_ENDSTOP(Y,MIN,Z,MIN); - #elif CORE_DIAG(YZ, Y, MAX) - PROCESS_CORE_ENDSTOP(Y,MAX,Z,MIN); - #endif + #if HAS_Z_MIN_STATE + // If the Z_MIN_PIN is being used for the probe there's no + // separate Z_MIN endstop. But a Z endstop could be wired + // in series, so someone might find this useful. + if ( TERN1(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, z_probe_enabled) // When Z_MIN is the probe, the probe must be enabled + && TERN1(USE_Z_MIN_PROBE, !z_probe_enabled) // When Z_MIN isn't the probe, Z MIN is ignored while probing + ) { + PROCESS_ENDSTOP_Z(MIN); + #if CORE_DIAG(XZ, X, MIN) + PROCESS_CORE_ENDSTOP(X,MIN,Z,MIN); + #elif CORE_DIAG(XZ, X, MAX) + PROCESS_CORE_ENDSTOP(X,MAX,Z,MIN); + #elif CORE_DIAG(YZ, Y, MIN) + PROCESS_CORE_ENDSTOP(Y,MIN,Z,MIN); + #elif CORE_DIAG(YZ, Y, MAX) + PROCESS_CORE_ENDSTOP(Y,MAX,Z,MIN); + #endif + } #endif - // When closing the gap check the enabled probe + // When closing the gap use the probe trigger state #if USE_Z_MIN_PROBE if (z_probe_enabled) PROCESS_ENDSTOP(Z, MIN_PROBE); #endif } else { // Z +direction. Gantry up, bed down. - #if USE_Z_MAX || (Z_SPI_SENSORLESS && Z_HOME_TO_MAX) - #if ENABLED(Z_MULTI_ENDSTOPS) - PROCESS_ENDSTOP_Z(MAX); - #elif TERN1(USE_Z_MIN_PROBE, Z_MAX_PIN != Z_MIN_PROBE_PIN) // No probe or probe is Z_MIN || Probe is not Z_MAX - PROCESS_ENDSTOP(Z, MAX); - #endif + #if HAS_Z_MAX_STATE + PROCESS_ENDSTOP_Z(MAX); #if CORE_DIAG(XZ, X, MIN) PROCESS_CORE_ENDSTOP(X,MIN,Z,MAX); #elif CORE_DIAG(XZ, X, MAX) @@ -987,12 +909,12 @@ void Endstops::update() { #if HAS_I_AXIS if (stepper.axis_is_moving(I_AXIS)) { if (!stepper.motor_direction(I_AXIS_HEAD)) { // -direction - #if USE_I_MIN || (I_SPI_SENSORLESS && I_HOME_TO_MIN) + #if HAS_I_MIN_STATE PROCESS_ENDSTOP(I, MIN); #endif } else { // +direction - #if USE_I_MAX || (I_SPI_SENSORLESS && I_HOME_TO_MAX) + #if HAS_I_MAX_STATE PROCESS_ENDSTOP(I, MAX); #endif } @@ -1002,12 +924,12 @@ void Endstops::update() { #if HAS_J_AXIS if (stepper.axis_is_moving(J_AXIS)) { if (!stepper.motor_direction(J_AXIS_HEAD)) { // -direction - #if USE_J_MIN || (J_SPI_SENSORLESS && J_HOME_TO_MIN) + #if HAS_J_MIN_STATE PROCESS_ENDSTOP(J, MIN); #endif } else { // +direction - #if USE_J_MAX || (J_SPI_SENSORLESS && J_HOME_TO_MAX) + #if HAS_J_MAX_STATE PROCESS_ENDSTOP(J, MAX); #endif } @@ -1017,12 +939,12 @@ void Endstops::update() { #if HAS_K_AXIS if (stepper.axis_is_moving(K_AXIS)) { if (!stepper.motor_direction(K_AXIS_HEAD)) { // -direction - #if USE_K_MIN || (K_SPI_SENSORLESS && K_HOME_TO_MIN) + #if HAS_K_MIN_STATE PROCESS_ENDSTOP(K, MIN); #endif } else { // +direction - #if USE_K_MAX || (K_SPI_SENSORLESS && K_HOME_TO_MAX) + #if HAS_K_MAX_STATE PROCESS_ENDSTOP(K, MAX); #endif } @@ -1032,12 +954,12 @@ void Endstops::update() { #if HAS_U_AXIS if (stepper.axis_is_moving(U_AXIS)) { if (!stepper.motor_direction(U_AXIS_HEAD)) { // -direction - #if USE_U_MIN || (U_SPI_SENSORLESS && U_HOME_TO_MIN) + #if HAS_U_MIN_STATE PROCESS_ENDSTOP(U, MIN); #endif } else { // +direction - #if USE_U_MAX || (U_SPI_SENSORLESS && U_HOME_TO_MAX) + #if HAS_U_MAX_STATE PROCESS_ENDSTOP(U, MAX); #endif } @@ -1047,12 +969,12 @@ void Endstops::update() { #if HAS_V_AXIS if (stepper.axis_is_moving(V_AXIS)) { if (!stepper.motor_direction(V_AXIS_HEAD)) { // -direction - #if USE_V_MIN || (V_SPI_SENSORLESS && V_HOME_TO_MIN) + #if HAS_V_MIN_STATE PROCESS_ENDSTOP(V, MIN); #endif } else { // +direction - #if USE_V_MAX || (V_SPI_SENSORLESS && V_HOME_TO_MAX) + #if HAS_V_MAX_STATE PROCESS_ENDSTOP(V, MAX); #endif } @@ -1062,17 +984,18 @@ void Endstops::update() { #if HAS_W_AXIS if (stepper.axis_is_moving(W_AXIS)) { if (!stepper.motor_direction(W_AXIS_HEAD)) { // -direction - #if USE_W_MIN || (W_SPI_SENSORLESS && W_HOME_TO_MIN) + #if HAS_W_MIN_STATE PROCESS_ENDSTOP(W, MIN); #endif } else { // +direction - #if USE_W_MAX || (W_SPI_SENSORLESS && W_HOME_TO_MAX) + #if HAS_W_MAX_STATE PROCESS_ENDSTOP(W, MAX); #endif } } #endif // HAS_W_AXIS + } // Endstops::update() #if ENABLED(SPI_ENDSTOPS) @@ -1080,39 +1003,67 @@ void Endstops::update() { // Called from idle() to read Trinamic stall states bool Endstops::tmc_spi_homing_check() { bool hit = false; + #if X_SPI_SENSORLESS - if (tmc_spi_homing.x && (stepperX.test_stall_status() - #if Y_SPI_SENSORLESS && ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) - || stepperY.test_stall_status() - #elif Z_SPI_SENSORLESS && CORE_IS_XZ - || stepperZ.test_stall_status() + if (tmc_spi_homing.x) { + #if ENABLED(DUAL_X_CARRIAGE) + const bool ismin = X_MIN_TEST(); #endif - )) { SBI(live_state, X_ENDSTOP); hit = true; } - #if ENABLED(X_DUAL_ENDSTOPS) - if (tmc_spi_homing.x && stepperX2.test_stall_status()) { SBI(live_state, X2_ENDSTOP); hit = true; } - #endif + const bool xhit = ( + #if ENABLED(DUAL_X_CARRIAGE) + ismin ? stepperX.test_stall_status() : stepperX2.test_stall_status() + #else + stepperX.test_stall_status() + #if Y_SPI_SENSORLESS && ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) + || stepperY.test_stall_status() + #elif Z_SPI_SENSORLESS && CORE_IS_XZ + || stepperZ.test_stall_status() + #endif + #endif + ); + if (xhit) { SBI(live_state, TERN(DUAL_X_CARRIAGE, ismin ? X_MIN : X_MAX, X_ENDSTOP)); hit = true; } + #if ENABLED(X_DUAL_ENDSTOPS) + if (stepperX2.test_stall_status()) { SBI(live_state, X2_ENDSTOP); hit = true; } + #endif + } #endif + #if Y_SPI_SENSORLESS - if (tmc_spi_homing.y && (stepperY.test_stall_status() - #if X_SPI_SENSORLESS && ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) - || stepperX.test_stall_status() - #elif Z_SPI_SENSORLESS && CORE_IS_YZ - || stepperZ.test_stall_status() + if (tmc_spi_homing.y) { + if (stepperY.test_stall_status() + #if X_SPI_SENSORLESS && ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) + || stepperX.test_stall_status() + #elif Z_SPI_SENSORLESS && CORE_IS_YZ + || stepperZ.test_stall_status() + #endif + ) { SBI(live_state, Y_ENDSTOP); hit = true; } + #if ENABLED(Y_DUAL_ENDSTOPS) + if (stepperY2.test_stall_status()) { SBI(live_state, Y2_ENDSTOP); hit = true; } #endif - )) { SBI(live_state, Y_ENDSTOP); hit = true; } - #if ENABLED(Y_DUAL_ENDSTOPS) - if (tmc_spi_homing.y && stepperY2.test_stall_status()) { SBI(live_state, Y2_ENDSTOP); hit = true; } - #endif + } #endif + #if Z_SPI_SENSORLESS - if (tmc_spi_homing.z && (stepperZ.test_stall_status() - #if X_SPI_SENSORLESS && CORE_IS_XZ - || stepperX.test_stall_status() - #elif Y_SPI_SENSORLESS && CORE_IS_YZ - || stepperY.test_stall_status() + if (tmc_spi_homing.z) { + if (stepperZ.test_stall_status() + #if X_SPI_SENSORLESS && CORE_IS_XZ + || stepperX.test_stall_status() + #elif Y_SPI_SENSORLESS && CORE_IS_YZ + || stepperY.test_stall_status() + #endif + ) { SBI(live_state, Z_ENDSTOP); hit = true; } + #if ENABLED(Z_MULTI_ENDSTOPS) + if (stepperZ2.test_stall_status()) { SBI(live_state, Z2_ENDSTOP); hit = true; } + #if NUM_Z_STEPPERS >= 3 + if (stepperZ3.test_stall_status()) { SBI(live_state, Z3_ENDSTOP); hit = true; } + #if NUM_Z_STEPPERS >= 4 + if (stepperZ4.test_stall_status()) { SBI(live_state, Z4_ENDSTOP); hit = true; } + #endif + #endif #endif - )) { SBI(live_state, Z_ENDSTOP); hit = true; } + } #endif + #if I_SPI_SENSORLESS if (tmc_spi_homing.i && stepperI.test_stall_status()) { SBI(live_state, I_ENDSTOP); hit = true; } #endif @@ -1147,6 +1098,15 @@ void Endstops::update() { CBI(live_state, Y2_ENDSTOP); #endif TERN_(Z_SPI_SENSORLESS, CBI(live_state, Z_ENDSTOP)); + #if ALL(Z_SPI_SENSORLESS, Z_MULTI_ENDSTOPS) + CBI(live_state, Z2_ENDSTOP); + #if NUM_Z_STEPPERS >= 3 + CBI(live_state, Z3_ENDSTOP); + #if NUM_Z_STEPPERS >= 4 + CBI(live_state, Z4_ENDSTOP); + #endif + #endif + #endif TERN_(I_SPI_SENSORLESS, CBI(live_state, I_ENDSTOP)); TERN_(J_SPI_SENSORLESS, CBI(live_state, J_ENDSTOP)); TERN_(K_SPI_SENSORLESS, CBI(live_state, K_ENDSTOP)); @@ -1190,7 +1150,7 @@ void Endstops::update() { #if USE_Y_MAX ES_GET_STATE(Y_MAX); #endif - #if HAS_Z_MIN_PIN + #if USE_Z_MIN ES_GET_STATE(Z_MIN); #endif #if USE_Z_MAX @@ -1266,7 +1226,7 @@ void Endstops::update() { ES_GET_STATE(W_MIN); #endif - uint16_t endstop_change = live_state_local ^ old_live_state_local; + const uint16_t endstop_change = live_state_local ^ old_live_state_local; #define ES_REPORT_CHANGE(S) if (TEST(endstop_change, S)) SERIAL_ECHOPGM(" " STRINGIFY(S) ":", TEST(live_state_local, S)) if (endstop_change) { @@ -1371,52 +1331,80 @@ void Endstops::update() { /** * Change TMC driver currents to N##_CURRENT_HOME, saving the current configuration of each. */ - void Endstops::set_homing_current(const bool onoff) { - #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) - #define HAS_DELTA_X_CURRENT (ENABLED(DELTA) && HAS_CURRENT_HOME(X)) - #define HAS_DELTA_Y_CURRENT (ENABLED(DELTA) && HAS_CURRENT_HOME(Y)) - #if HAS_DELTA_X_CURRENT || HAS_DELTA_Y_CURRENT || HAS_CURRENT_HOME(Z) + void Endstops::set_z_sensorless_current(const bool onoff) { + #if ENABLED(DELTA) && HAS_CURRENT_HOME(X) + #define HAS_DELTA_X_CURRENT 1 + #endif + #if ENABLED(DELTA) && HAS_CURRENT_HOME(Y) + #define HAS_DELTA_Y_CURRENT 1 + #endif + #if HAS_DELTA_X_CURRENT || HAS_DELTA_Y_CURRENT || HAS_CURRENT_HOME(Z) || HAS_CURRENT_HOME(Z2) || HAS_CURRENT_HOME(Z3) || HAS_CURRENT_HOME(Z4) #if HAS_DELTA_X_CURRENT - static int16_t saved_current_x; + static int16_t saved_current_X; #endif #if HAS_DELTA_Y_CURRENT - static int16_t saved_current_y; + static int16_t saved_current_Y; #endif #if HAS_CURRENT_HOME(Z) - static int16_t saved_current_z; + static int16_t saved_current_Z; #endif - auto debug_current_on = [](PGM_P const s, const int16_t a, const int16_t b) { - if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM_P(s); DEBUG_ECHOLNPGM(" current: ", a, " -> ", b); } - }; + #if HAS_CURRENT_HOME(Z2) + static int16_t saved_current_Z2; + #endif + #if HAS_CURRENT_HOME(Z3) + static int16_t saved_current_Z3; + #endif + #if HAS_CURRENT_HOME(Z4) + static int16_t saved_current_Z4; + #endif + + #if ENABLED(DEBUG_LEVELING_FEATURE) + auto debug_current = [](FSTR_P const s, const int16_t a, const int16_t b) { + if (DEBUGGING(LEVELING)) { DEBUG_ECHOF(s); DEBUG_ECHOLNPGM(" current: ", a, " -> ", b); } + }; + #else + #define debug_current(...) + #endif + + #define _SAVE_SET_CURRENT(A) \ + saved_current_##A = stepper##A.getMilliamps(); \ + stepper##A.rms_current(A##_CURRENT_HOME); \ + debug_current(F(STR_##A), saved_current_##A, A##_CURRENT_HOME) + + #define _RESTORE_CURRENT(A) \ + stepper##A.rms_current(saved_current_##A); \ + debug_current(F(STR_##A), saved_current_##A, A##_CURRENT_HOME) + if (onoff) { - #if HAS_DELTA_X_CURRENT - saved_current_x = stepperX.getMilliamps(); - stepperX.rms_current(X_CURRENT_HOME); - debug_current_on(PSTR("X"), saved_current_x, X_CURRENT_HOME); - #endif - #if HAS_DELTA_Y_CURRENT - saved_current_y = stepperY.getMilliamps(); - stepperY.rms_current(Y_CURRENT_HOME); - debug_current_on(PSTR("Y"), saved_current_y, Y_CURRENT_HOME); - #endif + TERN_(HAS_DELTA_X_CURRENT, _SAVE_SET_CURRENT(X)); + TERN_(HAS_DELTA_Y_CURRENT, _SAVE_SET_CURRENT(Y)); #if HAS_CURRENT_HOME(Z) - saved_current_z = stepperZ.getMilliamps(); - stepperZ.rms_current(Z_CURRENT_HOME); - debug_current_on(PSTR("Z"), saved_current_z, Z_CURRENT_HOME); + _SAVE_SET_CURRENT(Z); + #endif + #if HAS_CURRENT_HOME(Z2) + _SAVE_SET_CURRENT(Z2); + #endif + #if HAS_CURRENT_HOME(Z3) + _SAVE_SET_CURRENT(Z3); + #endif + #if HAS_CURRENT_HOME(Z4) + _SAVE_SET_CURRENT(Z4); #endif } else { - #if HAS_DELTA_X_CURRENT - stepperX.rms_current(saved_current_x); - debug_current_on(PSTR("X"), X_CURRENT_HOME, saved_current_x); - #endif - #if HAS_DELTA_Y_CURRENT - stepperY.rms_current(saved_current_y); - debug_current_on(PSTR("Y"), Y_CURRENT_HOME, saved_current_y); - #endif + TERN_(HAS_DELTA_X_CURRENT, _RESTORE_CURRENT(X)); + TERN_(HAS_DELTA_Y_CURRENT, _RESTORE_CURRENT(Y)); #if HAS_CURRENT_HOME(Z) - stepperZ.rms_current(saved_current_z); - debug_current_on(PSTR("Z"), Z_CURRENT_HOME, saved_current_z); + _RESTORE_CURRENT(Z); + #endif + #if HAS_CURRENT_HOME(Z2) + _RESTORE_CURRENT(Z2); + #endif + #if HAS_CURRENT_HOME(Z3) + _RESTORE_CURRENT(Z3); + #endif + #if HAS_CURRENT_HOME(Z4) + _RESTORE_CURRENT(Z4); #endif } diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index d348e58ab7..bbdb0bc77b 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -32,7 +32,12 @@ #define ES_ENUM(A,M) _ES_ENUM(A,M) #define _ES_ITEM(N) N, -#define ES_ITEM(K,N) TERN_(K,DEFER4(_ES_ITEM)(N)) +#define ES_ITEM(K,N) TERN(K,_ES_ITEM,_IF_1_ELSE)(N) + +#define _ESN_ITEM(K,A,M) ES_ITEM(K,ES_ENUM(A,M)) +#define ES_MINMAX(A) ES_ITEM(HAS_##A##_MIN_STATE, ES_ENUM(A,MIN)) ES_ITEM(HAS_##A##_MAX_STATE, ES_ENUM(A,MAX)) + +#define HAS_CURRENT_HOME(N) ((N##_CURRENT_HOME > 0) && (N##_CURRENT_HOME != N##_CURRENT)) /** * Basic Endstop Flag Bits: @@ -54,90 +59,71 @@ */ enum EndstopEnum : char { // Common XYZ (ABC) endstops. - ES_ITEM(USE_X_MIN, X_MIN) ES_ITEM(USE_X_MAX, X_MAX) - ES_ITEM(USE_Y_MIN, Y_MIN) ES_ITEM(USE_Y_MAX, Y_MAX) - ES_ITEM(USE_Z_MIN, Z_MIN) ES_ITEM(USE_Z_MAX, Z_MAX) - ES_ITEM(USE_I_MIN, I_MIN) ES_ITEM(USE_I_MAX, I_MAX) - ES_ITEM(USE_J_MIN, J_MIN) ES_ITEM(USE_J_MAX, J_MAX) - ES_ITEM(USE_K_MIN, K_MIN) ES_ITEM(USE_K_MAX, K_MAX) - ES_ITEM(USE_U_MIN, U_MIN) ES_ITEM(USE_U_MAX, U_MAX) - ES_ITEM(USE_V_MIN, V_MIN) ES_ITEM(USE_V_MAX, V_MAX) - ES_ITEM(USE_W_MIN, W_MIN) ES_ITEM(USE_W_MAX, W_MAX) + ES_MINMAX(X) ES_MINMAX(Y) ES_MINMAX(Z) + ES_MINMAX(I) ES_MINMAX(J) ES_MINMAX(K) + ES_MINMAX(U) ES_MINMAX(V) ES_MINMAX(W) // Extra Endstops for XYZ - #if ENABLED(X_DUAL_ENDSTOPS) - ES_ITEM(USE_X_MIN, X2_MIN) ES_ITEM(USE_X_MAX, X2_MAX) - #endif - #if ENABLED(Y_DUAL_ENDSTOPS) - ES_ITEM(USE_Y_MIN, Y2_MIN) ES_ITEM(USE_Y_MAX, Y2_MAX) - #endif - #if ENABLED(Z_MULTI_ENDSTOPS) - ES_ITEM(USE_Z_MIN, Z2_MIN) ES_ITEM(USE_Z_MAX, Z2_MAX) - #if NUM_Z_STEPPERS >= 3 - ES_ITEM(USE_Z_MIN, Z3_MIN) ES_ITEM(USE_Z_MAX, Z3_MAX) - #if NUM_Z_STEPPERS >= 4 - ES_ITEM(USE_Z_MIN, Z4_MIN) ES_ITEM(USE_Z_MAX, Z4_MAX) - #endif - #endif - #endif + ES_MINMAX(X2) ES_MINMAX(Y2) ES_MINMAX(Z2) ES_MINMAX(Z3) ES_MINMAX(Z4) // Bed Probe state is distinct or shared with Z_MIN (i.e., when the probe is the only Z endstop) - #if !HAS_DELTA_SENSORLESS_PROBING - ES_ITEM(HAS_BED_PROBE, Z_MIN_PROBE IF_DISABLED(USE_Z_MIN_PROBE, = Z_MIN)) - #endif + ES_ITEM(HAS_Z_PROBE_STATE, Z_MIN_PROBE IF_DISABLED(USE_Z_MIN_PROBE, = Z_MIN)) // The total number of states NUM_ENDSTOP_STATES - // Endstop aliased to MIN or MAX - #if HAS_X_ENDSTOP + // Endstop aliases + #if HAS_X_STATE , X_ENDSTOP = TERN(X_HOME_TO_MAX, X_MAX, X_MIN) - #if ENABLED(X_DUAL_ENDSTOPS) - , X2_ENDSTOP = TERN(X_HOME_TO_MAX, X2_MAX, X2_MIN) - #endif #endif - #if HAS_Y_ENDSTOP + #if HAS_X2_STATE + , X2_ENDSTOP = TERN(X_HOME_TO_MAX, X2_MAX, X2_MIN) + #endif + #if HAS_Y_STATE , Y_ENDSTOP = TERN(Y_HOME_TO_MAX, Y_MAX, Y_MIN) - #if ENABLED(Y_DUAL_ENDSTOPS) - , Y2_ENDSTOP = TERN(Y_HOME_TO_MAX, Y2_MAX, Y2_MIN) - #endif #endif + #if HAS_Y2_STATE + , Y2_ENDSTOP = TERN(Y_HOME_TO_MAX, Y2_MAX, Y2_MIN) + #endif + #if HOMING_Z_WITH_PROBE - , Z_ENDSTOP = Z_MIN_PROBE - #elif HAS_Z_ENDSTOP + , Z_ENDSTOP = Z_MIN_PROBE // "Z" endstop alias when homing with the probe + #elif HAS_Z_STATE , Z_ENDSTOP = TERN(Z_HOME_TO_MAX, Z_MAX, Z_MIN) - #if ENABLED(Z_MULTI_ENDSTOPS) - , Z2_ENDSTOP = TERN(Z_HOME_TO_MAX, Z2_MAX, Z2_MIN) - #if NUM_Z_STEPPERS >= 3 - , Z3_ENDSTOP = TERN(Z_HOME_TO_MAX, Z3_MAX, Z3_MIN) - #if NUM_Z_STEPPERS >= 4 - , Z4_ENDSTOP = TERN(Z_HOME_TO_MAX, Z4_MAX, Z4_MIN) - #endif - #endif - #endif #endif - #if HAS_I_ENDSTOP + #if HAS_Z2_STATE + , Z2_ENDSTOP = TERN(Z_HOME_TO_MAX, Z2_MAX, Z2_MIN) + #endif + #if HAS_Z3_STATE + , Z3_ENDSTOP = TERN(Z_HOME_TO_MAX, Z3_MAX, Z3_MIN) + #endif + #if HAS_Z4_STATE + , Z4_ENDSTOP = TERN(Z_HOME_TO_MAX, Z4_MAX, Z4_MIN) + #endif + #if HAS_I_STATE , I_ENDSTOP = TERN(I_HOME_TO_MAX, I_MAX, I_MIN) #endif - #if HAS_J_ENDSTOP + #if HAS_J_STATE , J_ENDSTOP = TERN(J_HOME_TO_MAX, J_MAX, J_MIN) #endif - #if HAS_K_ENDSTOP + #if HAS_K_STATE , K_ENDSTOP = TERN(K_HOME_TO_MAX, K_MAX, K_MIN) #endif - #if HAS_U_ENDSTOP + #if HAS_U_STATE , U_ENDSTOP = TERN(U_HOME_TO_MAX, U_MAX, U_MIN) #endif - #if HAS_V_ENDSTOP + #if HAS_V_STATE , V_ENDSTOP = TERN(V_HOME_TO_MAX, V_MAX, V_MIN) #endif - #if HAS_W_ENDSTOP + #if HAS_W_STATE , W_ENDSTOP = TERN(W_HOME_TO_MAX, W_MAX, W_MIN) #endif }; #undef _ES_ITEM #undef ES_ITEM +#undef _ESN_ITEM +#undef ES_MINMAX class Endstops { public: @@ -288,7 +274,7 @@ class Endstops { public: // Basic functions for Sensorless Homing #if USE_SENSORLESS - static void set_homing_current(const bool onoff); + static void set_z_sensorless_current(const bool onoff); #endif }; diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index cd768d9e40..80729df759 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1718,38 +1718,36 @@ void prepare_line_to_destination() { #endif } - #if ENABLED(SPI_ENDSTOPS) - switch (axis) { - #if HAS_X_AXIS - case X_AXIS: if (ENABLED(X_SPI_SENSORLESS)) endstops.tmc_spi_homing.x = true; break; - #endif - #if HAS_Y_AXIS - case Y_AXIS: if (ENABLED(Y_SPI_SENSORLESS)) endstops.tmc_spi_homing.y = true; break; - #endif - #if HAS_Z_AXIS - case Z_AXIS: if (ENABLED(Z_SPI_SENSORLESS)) endstops.tmc_spi_homing.z = true; break; - #endif - #if HAS_I_AXIS - case I_AXIS: if (ENABLED(I_SPI_SENSORLESS)) endstops.tmc_spi_homing.i = true; break; - #endif - #if HAS_J_AXIS - case J_AXIS: if (ENABLED(J_SPI_SENSORLESS)) endstops.tmc_spi_homing.j = true; break; - #endif - #if HAS_K_AXIS - case K_AXIS: if (ENABLED(K_SPI_SENSORLESS)) endstops.tmc_spi_homing.k = true; break; - #endif - #if HAS_U_AXIS - case U_AXIS: if (ENABLED(U_SPI_SENSORLESS)) endstops.tmc_spi_homing.u = true; break; - #endif - #if HAS_V_AXIS - case V_AXIS: if (ENABLED(V_SPI_SENSORLESS)) endstops.tmc_spi_homing.v = true; break; - #endif - #if HAS_W_AXIS - case W_AXIS: if (ENABLED(W_SPI_SENSORLESS)) endstops.tmc_spi_homing.w = true; break; - #endif - default: break; - } - #endif + switch (axis) { + #if X_SPI_SENSORLESS + case X_AXIS: endstops.tmc_spi_homing.x = true; break; + #endif + #if Y_SPI_SENSORLESS + case Y_AXIS: endstops.tmc_spi_homing.y = true; break; + #endif + #if Z_SPI_SENSORLESS + case Z_AXIS: endstops.tmc_spi_homing.z = true; break; + #endif + #if I_SPI_SENSORLESS + case I_AXIS: endstops.tmc_spi_homing.i = true; break; + #endif + #if J_SPI_SENSORLESS + case J_AXIS: endstops.tmc_spi_homing.j = true; break; + #endif + #if K_SPI_SENSORLESS + case K_AXIS: endstops.tmc_spi_homing.k = true; break; + #endif + #if U_SPI_SENSORLESS + case U_AXIS: endstops.tmc_spi_homing.u = true; break; + #endif + #if V_SPI_SENSORLESS + case V_AXIS: endstops.tmc_spi_homing.v = true; break; + #endif + #if W_SPI_SENSORLESS + case W_AXIS: endstops.tmc_spi_homing.w = true; break; + #endif + default: break; + } TERN_(IMPROVE_HOMING_RELIABILITY, sg_guard_period = millis() + default_sg_guard_duration); @@ -1814,38 +1812,36 @@ void prepare_line_to_destination() { #endif } - #if ENABLED(SPI_ENDSTOPS) - switch (axis) { - #if HAS_X_AXIS - case X_AXIS: if (ENABLED(X_SPI_SENSORLESS)) endstops.tmc_spi_homing.x = false; break; - #endif - #if HAS_Y_AXIS - case Y_AXIS: if (ENABLED(Y_SPI_SENSORLESS)) endstops.tmc_spi_homing.y = false; break; - #endif - #if HAS_Z_AXIS - case Z_AXIS: if (ENABLED(Z_SPI_SENSORLESS)) endstops.tmc_spi_homing.z = false; break; - #endif - #if HAS_I_AXIS - case I_AXIS: if (ENABLED(I_SPI_SENSORLESS)) endstops.tmc_spi_homing.i = false; break; - #endif - #if HAS_J_AXIS - case J_AXIS: if (ENABLED(J_SPI_SENSORLESS)) endstops.tmc_spi_homing.j = false; break; - #endif - #if HAS_K_AXIS - case K_AXIS: if (ENABLED(K_SPI_SENSORLESS)) endstops.tmc_spi_homing.k = false; break; - #endif - #if HAS_U_AXIS - case U_AXIS: if (ENABLED(U_SPI_SENSORLESS)) endstops.tmc_spi_homing.u = false; break; - #endif - #if HAS_V_AXIS - case V_AXIS: if (ENABLED(V_SPI_SENSORLESS)) endstops.tmc_spi_homing.v = false; break; - #endif - #if HAS_W_AXIS - case W_AXIS: if (ENABLED(W_SPI_SENSORLESS)) endstops.tmc_spi_homing.w = false; break; - #endif - default: break; - } - #endif + switch (axis) { + #if X_SPI_SENSORLESS + case X_AXIS: endstops.tmc_spi_homing.x = false; break; + #endif + #if Y_SPI_SENSORLESS + case Y_AXIS: endstops.tmc_spi_homing.y = false; break; + #endif + #if Z_SPI_SENSORLESS + case Z_AXIS: endstops.tmc_spi_homing.z = false; break; + #endif + #if I_SPI_SENSORLESS + case I_AXIS: endstops.tmc_spi_homing.i = false; break; + #endif + #if J_SPI_SENSORLESS + case J_AXIS: endstops.tmc_spi_homing.j = false; break; + #endif + #if K_SPI_SENSORLESS + case K_AXIS: endstops.tmc_spi_homing.k = false; break; + #endif + #if U_SPI_SENSORLESS + case U_AXIS: endstops.tmc_spi_homing.u = false; break; + #endif + #if V_SPI_SENSORLESS + case V_AXIS: endstops.tmc_spi_homing.v = false; break; + #endif + #if W_SPI_SENSORLESS + case W_AXIS: endstops.tmc_spi_homing.w = false; break; + #endif + default: break; + } } #endif // SENSORLESS_HOMING @@ -2118,7 +2114,7 @@ void prepare_line_to_destination() { // Only Z homing (with probe) is permitted if (axis != Z_AXIS) { BUZZ(100, 880); return; } #else - #define _CAN_HOME(A) (axis == _AXIS(A) && (ANY(A##_SPI_SENSORLESS, HAS_##A##_ENDSTOP) || TERN0(HOMING_Z_WITH_PROBE, _AXIS(A) == Z_AXIS))) + #define _CAN_HOME(A) (axis == _AXIS(A) && (ANY(A##_SPI_SENSORLESS, HAS_##A##_STATE) || TERN0(HOMING_Z_WITH_PROBE, _AXIS(A) == Z_AXIS))) #define _ANDCANT(N) && !_CAN_HOME(N) if (true MAIN_AXIS_MAP(_ANDCANT)) return; #endif diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 8c13da36f9..68fcfd00e0 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -610,8 +610,19 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { if (test_sensitivity.x) stealth_states.x = tmc_enable_stallguard(stepperX); // Delta watches all DIAG pins for a stall if (test_sensitivity.y) stealth_states.y = tmc_enable_stallguard(stepperY); #endif - if (test_sensitivity.z) stealth_states.z = tmc_enable_stallguard(stepperZ); // All machines will check Z-DIAG for stall - endstops.set_homing_current(true); // The "homing" current also applies to probing + if (test_sensitivity.z) { + stealth_states.z = tmc_enable_stallguard(stepperZ); // All machines will check Z-DIAG for stall + #if ENABLED(Z_MULTI_ENDSTOPS) + stealth_states.z2 = tmc_enable_stallguard(stepperZ2); + #if NUM_Z_STEPPERS >= 3 + stealth_states.z3 = tmc_enable_stallguard(stepperZ3); + #if NUM_Z_STEPPERS >= 4 + stealth_states.z4 = tmc_enable_stallguard(stepperZ4); + #endif + #endif + #endif + } + endstops.set_z_sensorless_current(true); // The "homing" current also applies to probing endstops.enable(true); #endif // SENSORLESS_PROBING @@ -643,9 +654,20 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { if (test_sensitivity.x) tmc_disable_stallguard(stepperX, stealth_states.x); if (test_sensitivity.y) tmc_disable_stallguard(stepperY, stealth_states.y); #endif - if (test_sensitivity.z) tmc_disable_stallguard(stepperZ, stealth_states.z); - endstops.set_homing_current(false); - #endif + if (test_sensitivity.z) { + tmc_disable_stallguard(stepperZ, stealth_states.z); + #if ENABLED(Z_MULTI_ENDSTOPS) + tmc_disable_stallguard(stepperZ2, stealth_states.z2); + #if NUM_Z_STEPPERS >= 3 + tmc_disable_stallguard(stepperZ3, stealth_states.z3); + #if NUM_Z_STEPPERS >= 4 + tmc_disable_stallguard(stepperZ4, stealth_states.z4); + #endif + #endif + #endif + } + endstops.set_z_sensorless_current(false); + #endif // SENSORLESS_PROBING #if ENABLED(BLTOUCH) if (probe_triggered && !bltouch.high_speed_mode && bltouch.stow()) diff --git a/buildroot/tests/BIGTREE_BTT002 b/buildroot/tests/BIGTREE_BTT002 index 7288c5ef52..5398d30fea 100755 --- a/buildroot/tests/BIGTREE_BTT002 +++ b/buildroot/tests/BIGTREE_BTT002 @@ -12,8 +12,8 @@ set -e restore_configs opt_set MOTHERBOARD BOARD_BTT_BTT002_V1_0 \ SERIAL_PORT 1 \ - X_DRIVER_TYPE TMC2209 \ - Y_DRIVER_TYPE TMC2130 + X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2130 +opt_enable SENSORLESS_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY SPI_ENDSTOPS exec_test $1 $2 "BigTreeTech BTT002 Default Configuration plus TMC steppers" "$3" # diff --git a/buildroot/tests/FYSETC_F6 b/buildroot/tests/FYSETC_F6 index 314e207c58..713408b550 100755 --- a/buildroot/tests/FYSETC_F6 +++ b/buildroot/tests/FYSETC_F6 @@ -50,9 +50,16 @@ opt_set MOTHERBOARD BOARD_FYSETC_F6_13 \ opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER \ MARLIN_BRICKOUT MARLIN_INVADERS MARLIN_SNAKE \ MONITOR_DRIVER_STATUS STEALTHCHOP_XY STEALTHCHOP_Z STEALTHCHOP_E HYBRID_THRESHOLD \ - SENSORLESS_HOMING TMC_DEBUG M114_DETAIL + SENSORLESS_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY TMC_DEBUG M114_DETAIL exec_test $1 $2 "Mixed TMC | Sensorless | RRDFGSC | Games" "$3" +# +# Delta Config (FLSUN AC because it's complex) +# +use_example_configs delta/FLSUN/auto_calibrate +opt_set MOTHERBOARD BOARD_FYSETC_F6_13 +exec_test $1 $2 "RAMPS 1.3 | DELTA | FLSUN AC Config" "$3" + # # SCARA with Mixed TMC # @@ -64,7 +71,7 @@ opt_set MOTHERBOARD BOARD_FYSETC_F6_13 \ X_HARDWARE_SERIAL Serial2 opt_enable FIX_MOUNTED_PROBE AUTO_BED_LEVELING_BILINEAR PAUSE_BEFORE_DEPLOY_STOW \ FYSETC_242_OLED_12864 EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL Z_SAFE_HOMING \ - STEALTHCHOP_XY STEALTHCHOP_Z STEALTHCHOP_E HYBRID_THRESHOLD SENSORLESS_HOMING EDGE_STEPPING + STEALTHCHOP_XY STEALTHCHOP_Z STEALTHCHOP_E HYBRID_THRESHOLD SENSORLESS_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY EDGE_STEPPING exec_test $1 $2 "SCARA | Mixed TMC | EEPROM" "$3" # clean up diff --git a/buildroot/tests/LPC1769 b/buildroot/tests/LPC1769 index a7348bffe9..9987d155ad 100755 --- a/buildroot/tests/LPC1769 +++ b/buildroot/tests/LPC1769 @@ -53,14 +53,15 @@ opt_set MOTHERBOARD BOARD_COHESION3D_REMIX \ HOMING_FEEDRATE_MM_M '{ (50*60), (50*60), (4*60), (50*60) }' \ HOMING_BUMP_MM '{ 0, 0, 0, 0 }' HOMING_BUMP_DIVISOR '{ 1, 1, 1, 1 }' \ NOZZLE_TO_PROBE_OFFSET '{ 0, 0, 0, 0 }' \ - I_MIN_PIN P1_25 + I_MIN_PIN P1_25 \ + X_CURRENT_HOME 750 Y_CURRENT_HOME 750 Z_CURRENT_HOME 750 opt_enable AUTO_BED_LEVELING_BILINEAR EEPROM_SETTINGS EEPROM_CHITCHAT MECHANICAL_GANTRY_CALIBRATION \ TMC_USE_SW_SPI MONITOR_DRIVER_STATUS STEALTHCHOP_XY STEALTHCHOP_Z HYBRID_THRESHOLD \ - SENSORLESS_PROBING Z_SAFE_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY Z_STALL_SENSITIVITY TMC_DEBUG \ + SENSORLESS_PROBING SENSORLESS_HOMING Z_SAFE_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY Z_STALL_SENSITIVITY TMC_DEBUG \ AXIS4_ROTATES I_MIN_POS I_MAX_POS I_HOME_DIR I_ENABLE_ON INVERT_I_DIR \ EXPERIMENTAL_I2CBUS opt_disable PSU_CONTROL Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN -exec_test $1 $2 "Cohesion3D Remix DELTA + ABL Bilinear + EEPROM + SENSORLESS_PROBING + I Axis" "$3" +exec_test $1 $2 "Cohesion3D Remix DELTA | ABL Bilinear | EEPROM | Sensorless Homing/Probing | I Axis" "$3" # clean up restore_configs diff --git a/buildroot/tests/SAMD21_minitronics20 b/buildroot/tests/SAMD21_minitronics20 index f4a75afafe..ae9fa55ea4 100755 --- a/buildroot/tests/SAMD21_minitronics20 +++ b/buildroot/tests/SAMD21_minitronics20 @@ -25,8 +25,7 @@ opt_enable ENDSTOP_INTERRUPTS_FEATURE BLTOUCH Z_MIN_PROBE_REPEATABILITY_TEST \ LONG_FILENAME_HOST_SUPPORT CUSTOM_FIRMWARE_UPLOAD M20_TIMESTAMP_SUPPORT \ SCROLL_LONG_FILENAMES BABYSTEPPING DOUBLECLICK_FOR_Z_BABYSTEPPING \ MOVE_Z_WHEN_IDLE BABYSTEP_ZPROBE_OFFSET BABYSTEP_GFX_OVERLAY \ - LIN_ADVANCE ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE MONITOR_DRIVER_STATUS SENSORLESS_HOMING \ - EDGE_STEPPING + LIN_ADVANCE ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE MONITOR_DRIVER_STATUS exec_test $1 $2 "Minitronics 2.0 with assorted features" "$3" # clean up diff --git a/buildroot/tests/SAMD51_grandcentral_m4 b/buildroot/tests/SAMD51_grandcentral_m4 index 72996e7b7f..312bd627ba 100755 --- a/buildroot/tests/SAMD51_grandcentral_m4 +++ b/buildroot/tests/SAMD51_grandcentral_m4 @@ -25,7 +25,8 @@ opt_enable ENDSTOP_INTERRUPTS_FEATURE S_CURVE_ACCELERATION BLTOUCH Z_MIN_PROBE_R LONG_FILENAME_HOST_SUPPORT CUSTOM_FIRMWARE_UPLOAD M20_TIMESTAMP_SUPPORT \ SCROLL_LONG_FILENAMES BABYSTEPPING DOUBLECLICK_FOR_Z_BABYSTEPPING \ MOVE_Z_WHEN_IDLE BABYSTEP_ZPROBE_OFFSET BABYSTEP_GFX_OVERLAY \ - LIN_ADVANCE ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE MONITOR_DRIVER_STATUS SENSORLESS_HOMING \ + LIN_ADVANCE ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE MONITOR_DRIVER_STATUS \ + SENSORLESS_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY Z_STALL_SENSITIVITY Z2_STALL_SENSITIVITY \ EDGE_STEPPING TMC_DEBUG exec_test $1 $2 "Grand Central M4 with assorted features" "$3" diff --git a/buildroot/tests/mega1280 b/buildroot/tests/mega1280 index 53016e8406..7e99ee4a60 100755 --- a/buildroot/tests/mega1280 +++ b/buildroot/tests/mega1280 @@ -41,6 +41,7 @@ opt_set MOTHERBOARD BOARD_ZRIB_V52 \ LCD_LANGUAGE pt REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 \ EXTRUDERS 2 TEMP_SENSOR_1 1 X2_DRIVER_TYPE A4988 opt_enable DUAL_X_CARRIAGE REPRAPWORLD_KEYPAD +opt_add DEBUG_DXC_MODE exec_test $1 $2 "ZRIB_V52 | DUAL_X_CARRIAGE" "$3" # diff --git a/buildroot/tests/teensy35 b/buildroot/tests/teensy35 index 959a207aee..4a752c7f5a 100755 --- a/buildroot/tests/teensy35 +++ b/buildroot/tests/teensy35 @@ -85,9 +85,10 @@ exec_test $1 $2 "Mixing Extruder" "$3" restore_configs opt_set MOTHERBOARD BOARD_TEENSY35_36 \ X_DRIVER_TYPE TMC5160 Y_DRIVER_TYPE TMC5160 \ + X_CURRENT_HOME 750 Y_CURRENT_HOME 750 \ X_MIN_ENDSTOP_HIT_STATE LOW Y_MIN_ENDSTOP_HIT_STATE LOW \ X_CS_PIN 46 Y_CS_PIN 47 -opt_enable COREXY MONITOR_DRIVER_STATUS SENSORLESS_HOMING +opt_enable COREXY MONITOR_DRIVER_STATUS SENSORLESS_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY exec_test $1 $2 "Teensy 3.5/3.6 COREXY" "$3" #