🎨 Apply _TERN where possible

This commit is contained in:
Scott Lahteine
2022-03-22 19:17:12 -05:00
committed by Scott Lahteine
parent 10a0c9a9b3
commit ced0ad8e09
5 changed files with 57 additions and 158 deletions

View File

@ -1359,9 +1359,7 @@ void prepare_line_to_destination() {
#if X_SENSORLESS
case X_AXIS:
stealth_states.x = tmc_enable_stallguard(stepperX);
#if AXIS_HAS_STALLGUARD(X2)
stealth_states.x2 = tmc_enable_stallguard(stepperX2);
#endif
TERN_(X2_SENSORLESS, stealth_states.x2 = tmc_enable_stallguard(stepperX2));
#if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SENSORLESS
stealth_states.y = tmc_enable_stallguard(stepperY);
#elif CORE_IS_XZ && Z_SENSORLESS
@ -1372,9 +1370,7 @@ void prepare_line_to_destination() {
#if Y_SENSORLESS
case Y_AXIS:
stealth_states.y = tmc_enable_stallguard(stepperY);
#if AXIS_HAS_STALLGUARD(Y2)
stealth_states.y2 = tmc_enable_stallguard(stepperY2);
#endif
TERN_(Y2_SENSORLESS, stealth_states.y2 = tmc_enable_stallguard(stepperY2));
#if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SENSORLESS
stealth_states.x = tmc_enable_stallguard(stepperX);
#elif CORE_IS_YZ && Z_SENSORLESS
@ -1385,15 +1381,9 @@ void prepare_line_to_destination() {
#if Z_SENSORLESS
case Z_AXIS:
stealth_states.z = tmc_enable_stallguard(stepperZ);
#if AXIS_HAS_STALLGUARD(Z2)
stealth_states.z2 = tmc_enable_stallguard(stepperZ2);
#endif
#if AXIS_HAS_STALLGUARD(Z3)
stealth_states.z3 = tmc_enable_stallguard(stepperZ3);
#endif
#if AXIS_HAS_STALLGUARD(Z4)
stealth_states.z4 = tmc_enable_stallguard(stepperZ4);
#endif
TERN_(Z2_SENSORLESS, stealth_states.z2 = tmc_enable_stallguard(stepperZ2));
TERN_(Z3_SENSORLESS, stealth_states.z3 = tmc_enable_stallguard(stepperZ3));
TERN_(Z4_SENSORLESS, stealth_states.z4 = tmc_enable_stallguard(stepperZ4));
#if CORE_IS_XZ && X_SENSORLESS
stealth_states.x = tmc_enable_stallguard(stepperX);
#elif CORE_IS_YZ && Y_SENSORLESS
@ -1445,9 +1435,7 @@ void prepare_line_to_destination() {
#if X_SENSORLESS
case X_AXIS:
tmc_disable_stallguard(stepperX, enable_stealth.x);
#if AXIS_HAS_STALLGUARD(X2)
tmc_disable_stallguard(stepperX2, enable_stealth.x2);
#endif
TERN_(X2_SENSORLESS, tmc_disable_stallguard(stepperX2, enable_stealth.x2));
#if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SENSORLESS
tmc_disable_stallguard(stepperY, enable_stealth.y);
#elif CORE_IS_XZ && Z_SENSORLESS
@ -1458,9 +1446,7 @@ void prepare_line_to_destination() {
#if Y_SENSORLESS
case Y_AXIS:
tmc_disable_stallguard(stepperY, enable_stealth.y);
#if AXIS_HAS_STALLGUARD(Y2)
tmc_disable_stallguard(stepperY2, enable_stealth.y2);
#endif
TERN_(Y2_SENSORLESS, tmc_disable_stallguard(stepperY2, enable_stealth.y2));
#if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SENSORLESS
tmc_disable_stallguard(stepperX, enable_stealth.x);
#elif CORE_IS_YZ && Z_SENSORLESS
@ -1471,15 +1457,9 @@ void prepare_line_to_destination() {
#if Z_SENSORLESS
case Z_AXIS:
tmc_disable_stallguard(stepperZ, enable_stealth.z);
#if AXIS_HAS_STALLGUARD(Z2)
tmc_disable_stallguard(stepperZ2, enable_stealth.z2);
#endif
#if AXIS_HAS_STALLGUARD(Z3)
tmc_disable_stallguard(stepperZ3, enable_stealth.z3);
#endif
#if AXIS_HAS_STALLGUARD(Z4)
tmc_disable_stallguard(stepperZ4, enable_stealth.z4);
#endif
TERN_(Z2_SENSORLESS, tmc_disable_stallguard(stepperZ2, enable_stealth.z2));
TERN_(Z3_SENSORLESS, tmc_disable_stallguard(stepperZ3, enable_stealth.z3));
TERN_(Z4_SENSORLESS, tmc_disable_stallguard(stepperZ4, enable_stealth.z4));
#if CORE_IS_XZ && X_SENSORLESS
tmc_disable_stallguard(stepperX, enable_stealth.x);
#elif CORE_IS_YZ && Y_SENSORLESS

View File

@ -906,49 +906,18 @@ void reset_trinamic_drivers() {
#endif
#if USE_SENSORLESS
#if X_SENSORLESS
stepperX.homing_threshold(X_STALL_SENSITIVITY);
#if AXIS_HAS_STALLGUARD(X2)
stepperX2.homing_threshold(CAT(TERN(X2_SENSORLESS, X2, X), _STALL_SENSITIVITY));
#endif
#endif
#if Y_SENSORLESS
stepperY.homing_threshold(Y_STALL_SENSITIVITY);
#if AXIS_HAS_STALLGUARD(Y2)
stepperY2.homing_threshold(CAT(TERN(Y2_SENSORLESS, Y2, Y), _STALL_SENSITIVITY));
#endif
#endif
#if Z_SENSORLESS
stepperZ.homing_threshold(Z_STALL_SENSITIVITY);
#if AXIS_HAS_STALLGUARD(Z2)
stepperZ2.homing_threshold(CAT(TERN(Z2_SENSORLESS, Z2, Z), _STALL_SENSITIVITY));
#endif
#if AXIS_HAS_STALLGUARD(Z3)
stepperZ3.homing_threshold(CAT(TERN(Z3_SENSORLESS, Z3, Z), _STALL_SENSITIVITY));
#endif
#if AXIS_HAS_STALLGUARD(Z4)
stepperZ4.homing_threshold(CAT(TERN(Z4_SENSORLESS, Z4, Z), _STALL_SENSITIVITY));
#endif
#endif
#if I_SENSORLESS
stepperI.homing_threshold(I_STALL_SENSITIVITY);
#if AXIS_HAS_STALLGUARD(I)
stepperI.homing_threshold(CAT(TERN(I_SENSORLESS, I, I), _STALL_SENSITIVITY));
#endif
#endif
#if J_SENSORLESS
stepperJ.homing_threshold(J_STALL_SENSITIVITY);
#if AXIS_HAS_STALLGUARD(J)
stepperJ.homing_threshold(CAT(TERN(J_SENSORLESS, J, J), _STALL_SENSITIVITY));
#endif
#endif
#if K_SENSORLESS
stepperK.homing_threshold(K_STALL_SENSITIVITY);
#if AXIS_HAS_STALLGUARD(K)
stepperK.homing_threshold(CAT(TERN(K_SENSORLESS, K, K), _STALL_SENSITIVITY));
#endif
#endif
#endif // USE SENSORLESS
TERN_(X_SENSORLESS, stepperX.homing_threshold(X_STALL_SENSITIVITY));
TERN_(X2_SENSORLESS, stepperX2.homing_threshold(CAT(TERN(X2_SENSORLESS, X2, X), _STALL_SENSITIVITY)));
TERN_(Y_SENSORLESS, stepperY.homing_threshold(Y_STALL_SENSITIVITY));
TERN_(Y2_SENSORLESS, stepperY2.homing_threshold(CAT(TERN(Y2_SENSORLESS, Y2, Y), _STALL_SENSITIVITY)));
TERN_(Z_SENSORLESS, stepperZ.homing_threshold(Z_STALL_SENSITIVITY));
TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(CAT(TERN(Z2_SENSORLESS, Z2, Z), _STALL_SENSITIVITY)));
TERN_(Z3_SENSORLESS, stepperZ3.homing_threshold(CAT(TERN(Z3_SENSORLESS, Z3, Z), _STALL_SENSITIVITY)));
TERN_(Z4_SENSORLESS, stepperZ4.homing_threshold(CAT(TERN(Z4_SENSORLESS, Z4, Z), _STALL_SENSITIVITY)));
TERN_(I_SENSORLESS, stepperI.homing_threshold(I_STALL_SENSITIVITY));
TERN_(J_SENSORLESS, stepperJ.homing_threshold(J_STALL_SENSITIVITY));
TERN_(K_SENSORLESS, stepperK.homing_threshold(K_STALL_SENSITIVITY));
#endif
#ifdef TMC_ADV
TMC_ADV()