Skip to content

Commit

Permalink
🚸 Strict index 2 for M913 / M914 XY (MarlinFirmware#24680)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMagician authored and Andy-Big committed Jun 30, 2023
1 parent 8c8ec62 commit ef4e085
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Marlin/src/gcode/feature/trinamic/M911-M914.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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))) {
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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).");
Expand Down

0 comments on commit ef4e085

Please sign in to comment.