From 5fe1f6647875b2f325db52b74f356bdaec19dce5 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Thu, 1 Sep 2022 21:16:52 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Strict=20index=202=20for=20M913?= =?UTF-8?q?=20/=20M914=20XY=20(#24680)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/feature/trinamic/M911-M914.cpp | 9 ++++----- Marlin/src/inc/SanityCheck.h | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index 0a9d1760e9..0fbf1def67 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -294,14 +294,14 @@ #if X_HAS_STEALTHCHOP || X2_HAS_STEALTHCHOP case X_AXIS: TERN_(X_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(X,X)); - TERN_(X2_HAS_STEALTHCHOP, if (!(index & 1)) TMC_SET_PWMTHRS(X,X2)); + TERN_(X2_HAS_STEALTHCHOP, if (!index || index == 2) TMC_SET_PWMTHRS(X,X2)); break; #endif #if Y_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP case Y_AXIS: TERN_(Y_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(Y,Y)); - TERN_(Y2_HAS_STEALTHCHOP, if (!(index & 1)) TMC_SET_PWMTHRS(Y,Y2)); + TERN_(Y2_HAS_STEALTHCHOP, if (!index || index == 2) TMC_SET_PWMTHRS(Y,Y2)); break; #endif @@ -499,7 +499,6 @@ * M914: Set StallGuard sensitivity. */ void GcodeSuite::M914() { - bool report = true; const uint8_t index = parser.byteval('I'); LOOP_NUM_AXES(i) if (parser.seen(AXIS_CHAR(i))) { @@ -509,13 +508,13 @@ #if X_SENSORLESS case X_AXIS: if (index < 2) stepperX.homing_threshold(value); - TERN_(X2_SENSORLESS, if (!(index & 1)) stepperX2.homing_threshold(value)); + TERN_(X2_SENSORLESS, if (!index || index == 2) stepperX2.homing_threshold(value)); break; #endif #if Y_SENSORLESS case Y_AXIS: if (index < 2) stepperY.homing_threshold(value); - TERN_(Y2_SENSORLESS, if (!(index & 1)) stepperY2.homing_threshold(value)); + TERN_(Y2_SENSORLESS, if (!index || index == 2) stepperY2.homing_threshold(value)); break; #endif #if Z_SENSORLESS diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index ea39aa1b70..e9675feaf1 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2044,6 +2044,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS ); #endif +#define COUNT_SENSORLESS COUNT_ENABLED(Z_SENSORLESS, Z2_SENSORLESS, Z3_SENSORLESS, Z4_SENSORLESS) +#if COUNT_SENSORLESS && COUNT_SENSORLESS != NUM_Z_STEPPERS + #error "All Z steppers must have *_STALL_SENSITIVITY defined to use Z sensorless homing." +#endif +#undef COUNT_SENSORLESS + #ifdef SENSORLESS_BACKOFF_MM constexpr float sbm[] = SENSORLESS_BACKOFF_MM; static_assert(COUNT(sbm) == NUM_AXES, "SENSORLESS_BACKOFF_MM must have " _NUM_AXES_STR "elements (and no others).");