diff --git a/Marlin/src/feature/digipot/digipot_mcp4451.cpp b/Marlin/src/feature/digipot/digipot_mcp4451.cpp index e35b42a28b..156755856c 100644 --- a/Marlin/src/feature/digipot/digipot_mcp4451.cpp +++ b/Marlin/src/feature/digipot/digipot_mcp4451.cpp @@ -87,13 +87,7 @@ void DigipotI2C::init() { Wire.begin(); #endif // Set up initial currents as defined in Configuration_adv.h - static const float digipot_motor_current[] PROGMEM = - #if ENABLED(DIGIPOT_USE_RAW_VALUES) - DIGIPOT_MOTOR_CURRENT - #else - DIGIPOT_I2C_MOTOR_CURRENTS - #endif - ; + static const float digipot_motor_current[] PROGMEM = TERN(DIGIPOT_USE_RAW_VALUES, DIGIPOT_MOTOR_CURRENT, DIGIPOT_I2C_MOTOR_CURRENTS); for (uint8_t i = 0; i < COUNT(digipot_motor_current); ++i) set_current(i, pgm_read_float(&digipot_motor_current[i])); } diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index 6afbf4a0ce..62972eb7f5 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -344,127 +344,70 @@ if (need_update_error_counters || need_debug_reporting) { - #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) - { - bool result = false; - #if AXIS_IS_TMC(X) - if (monitor_tmc_driver(stepperX, need_update_error_counters, need_debug_reporting)) result = true; - #endif - #if AXIS_IS_TMC(X2) - if (monitor_tmc_driver(stepperX2, need_update_error_counters, need_debug_reporting)) result = true; - #endif - if (result) { - #if AXIS_IS_TMC(X) - step_current_down(stepperX); - #endif - #if AXIS_IS_TMC(X2) - step_current_down(stepperX2); - #endif + #if X_IS_TRINAMIC || X2_IS_TRINAMIC + if ( TERN0(X_IS_TRINAMIC, monitor_tmc_driver(stepperX, need_update_error_counters, need_debug_reporting)) + || TERN0(X2_IS_TRINAMIC, monitor_tmc_driver(stepperX2, need_update_error_counters, need_debug_reporting)) + ) { + TERN_(X_IS_TRINAMIC, step_current_down(stepperX)); + TERN_(X2_IS_TRINAMIC, step_current_down(stepperX2)); } - } #endif - #if AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) - { - bool result = false; - #if AXIS_IS_TMC(Y) - if (monitor_tmc_driver(stepperY, need_update_error_counters, need_debug_reporting)) result = true; - #endif - #if AXIS_IS_TMC(Y2) - if (monitor_tmc_driver(stepperY2, need_update_error_counters, need_debug_reporting)) result = true; - #endif - if (result) { - #if AXIS_IS_TMC(Y) - step_current_down(stepperY); - #endif - #if AXIS_IS_TMC(Y2) - step_current_down(stepperY2); - #endif + #if Y_IS_TRINAMIC || Y2_IS_TRINAMIC + if ( TERN0(Y_IS_TRINAMIC, monitor_tmc_driver(stepperY, need_update_error_counters, need_debug_reporting)) + || TERN0(Y2_IS_TRINAMIC, monitor_tmc_driver(stepperY2, need_update_error_counters, need_debug_reporting)) + ) { + TERN_(Y_IS_TRINAMIC, step_current_down(stepperY)); + TERN_(Y2_IS_TRINAMIC, step_current_down(stepperY2)); } - } #endif - #if AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) - { - bool result = false; - #if AXIS_IS_TMC(Z) - if (monitor_tmc_driver(stepperZ, need_update_error_counters, need_debug_reporting)) result = true; - #endif - #if AXIS_IS_TMC(Z2) - if (monitor_tmc_driver(stepperZ2, need_update_error_counters, need_debug_reporting)) result = true; - #endif - #if AXIS_IS_TMC(Z3) - if (monitor_tmc_driver(stepperZ3, need_update_error_counters, need_debug_reporting)) result = true; - #endif - #if AXIS_IS_TMC(Z4) - if (monitor_tmc_driver(stepperZ4, need_update_error_counters, need_debug_reporting)) result = true; - #endif - if (result) { - #if AXIS_IS_TMC(Z) - step_current_down(stepperZ); - #endif - #if AXIS_IS_TMC(Z2) - step_current_down(stepperZ2); - #endif - #if AXIS_IS_TMC(Z3) - step_current_down(stepperZ3); - #endif - #if AXIS_IS_TMC(Z4) - step_current_down(stepperZ4); - #endif + #if ANY(Z_IS_TRINAMIC, Z2_IS_TRINAMIC, Z3_IS_TRINAMIC, Z4_IS_TRINAMIC) + if ( TERN0(Z_IS_TRINAMIC, monitor_tmc_driver(stepperZ, need_update_error_counters, need_debug_reporting)) + || TERN0(Z2_IS_TRINAMIC, monitor_tmc_driver(stepperZ2, need_update_error_counters, need_debug_reporting)) + || TERN0(Z3_IS_TRINAMIC, monitor_tmc_driver(stepperZ3, need_update_error_counters, need_debug_reporting)) + || TERN0(Z4_IS_TRINAMIC, monitor_tmc_driver(stepperZ4, need_update_error_counters, need_debug_reporting)) + ) { + TERN_(Z_IS_TRINAMIC, step_current_down(stepperZ)); + TERN_(Z2_IS_TRINAMIC, step_current_down(stepperZ2)); + TERN_(Z3_IS_TRINAMIC, step_current_down(stepperZ3)); + TERN_(Z4_IS_TRINAMIC, step_current_down(stepperZ4)); } - } #endif - #if AXIS_IS_TMC(I) + #if I_IS_TRINAMIC if (monitor_tmc_driver(stepperI, need_update_error_counters, need_debug_reporting)) step_current_down(stepperI); #endif - #if AXIS_IS_TMC(J) + #if J_IS_TRINAMIC if (monitor_tmc_driver(stepperJ, need_update_error_counters, need_debug_reporting)) step_current_down(stepperJ); #endif - #if AXIS_IS_TMC(K) + #if K_IS_TRINAMIC if (monitor_tmc_driver(stepperK, need_update_error_counters, need_debug_reporting)) step_current_down(stepperK); #endif - #if AXIS_IS_TMC(U) + #if U_IS_TRINAMIC if (monitor_tmc_driver(stepperU, need_update_error_counters, need_debug_reporting)) step_current_down(stepperU); #endif - #if AXIS_IS_TMC(V) + #if V_IS_TRINAMIC if (monitor_tmc_driver(stepperV, need_update_error_counters, need_debug_reporting)) step_current_down(stepperV); #endif - #if AXIS_IS_TMC(W) + #if W_IS_TRINAMIC if (monitor_tmc_driver(stepperW, need_update_error_counters, need_debug_reporting)) step_current_down(stepperW); #endif - #if AXIS_IS_TMC(E0) - (void)monitor_tmc_driver(stepperE0, need_update_error_counters, need_debug_reporting); - #endif - #if AXIS_IS_TMC(E1) - (void)monitor_tmc_driver(stepperE1, need_update_error_counters, need_debug_reporting); - #endif - #if AXIS_IS_TMC(E2) - (void)monitor_tmc_driver(stepperE2, need_update_error_counters, need_debug_reporting); - #endif - #if AXIS_IS_TMC(E3) - (void)monitor_tmc_driver(stepperE3, need_update_error_counters, need_debug_reporting); - #endif - #if AXIS_IS_TMC(E4) - (void)monitor_tmc_driver(stepperE4, need_update_error_counters, need_debug_reporting); - #endif - #if AXIS_IS_TMC(E5) - (void)monitor_tmc_driver(stepperE5, need_update_error_counters, need_debug_reporting); - #endif - #if AXIS_IS_TMC(E6) - (void)monitor_tmc_driver(stepperE6, need_update_error_counters, need_debug_reporting); - #endif - #if AXIS_IS_TMC(E7) - (void)monitor_tmc_driver(stepperE7, need_update_error_counters, need_debug_reporting); - #endif + TERN_(E0_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE0, need_update_error_counters, need_debug_reporting)); + TERN_(E1_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE1, need_update_error_counters, need_debug_reporting)); + TERN_(E2_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE2, need_update_error_counters, need_debug_reporting)); + TERN_(E3_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE3, need_update_error_counters, need_debug_reporting)); + TERN_(E4_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE4, need_update_error_counters, need_debug_reporting)); + TERN_(E5_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE5, need_update_error_counters, need_debug_reporting)); + TERN_(E6_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE6, need_update_error_counters, need_debug_reporting)); + TERN_(E7_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE7, need_update_error_counters, need_debug_reporting)); if (TERN0(TMC_DEBUG, need_debug_reporting)) SERIAL_EOL(); } @@ -781,82 +724,38 @@ static void tmc_debug_loop(const TMC_debug_enum n OPTARGS_LOGICAL(const bool)) { if (TERN0(HAS_X_AXIS, x)) { - #if AXIS_IS_TMC(X) - tmc_status(stepperX, n); - #endif - #if AXIS_IS_TMC(X2) - tmc_status(stepperX2, n); - #endif + TERN_(X_IS_TRINAMIC, tmc_status(stepperX, n)); + TERN_(X2_IS_TRINAMIC, tmc_status(stepperX2, n)); } if (TERN0(HAS_Y_AXIS, y)) { - #if AXIS_IS_TMC(Y) - tmc_status(stepperY, n); - #endif - #if AXIS_IS_TMC(Y2) - tmc_status(stepperY2, n); - #endif + TERN_(Y_IS_TRINAMIC, tmc_status(stepperY, n)); + TERN_(Y2_IS_TRINAMIC, tmc_status(stepperY2, n)); } if (TERN0(HAS_Z_AXIS, z)) { - #if AXIS_IS_TMC(Z) - tmc_status(stepperZ, n); - #endif - #if AXIS_IS_TMC(Z2) - tmc_status(stepperZ2, n); - #endif - #if AXIS_IS_TMC(Z3) - tmc_status(stepperZ3, n); - #endif - #if AXIS_IS_TMC(Z4) - tmc_status(stepperZ4, n); - #endif + TERN_(Z_IS_TRINAMIC, tmc_status(stepperZ, n)); + TERN_(Z2_IS_TRINAMIC, tmc_status(stepperZ2, n)); + TERN_(Z3_IS_TRINAMIC, tmc_status(stepperZ3, n)); + TERN_(Z4_IS_TRINAMIC, tmc_status(stepperZ4, n)); } - #if AXIS_IS_TMC(I) - if (i) tmc_status(stepperI, n); - #endif - #if AXIS_IS_TMC(J) - if (j) tmc_status(stepperJ, n); - #endif - #if AXIS_IS_TMC(K) - if (k) tmc_status(stepperK, n); - #endif - #if AXIS_IS_TMC(U) - if (u) tmc_status(stepperU, n); - #endif - #if AXIS_IS_TMC(V) - if (v) tmc_status(stepperV, n); - #endif - #if AXIS_IS_TMC(W) - if (w) tmc_status(stepperW, n); - #endif + TERN_(I_IS_TRINAMIC, if (i) tmc_status(stepperI, n)); + TERN_(J_IS_TRINAMIC, if (j) tmc_status(stepperJ, n)); + TERN_(K_IS_TRINAMIC, if (k) tmc_status(stepperK, n)); + TERN_(U_IS_TRINAMIC, if (u) tmc_status(stepperU, n)); + TERN_(V_IS_TRINAMIC, if (v) tmc_status(stepperV, n)); + TERN_(W_IS_TRINAMIC, if (w) tmc_status(stepperW, n)); if (TERN0(HAS_EXTRUDERS, e)) { - #if AXIS_IS_TMC(E0) - tmc_status(stepperE0, n); - #endif - #if AXIS_IS_TMC(E1) - tmc_status(stepperE1, n); - #endif - #if AXIS_IS_TMC(E2) - tmc_status(stepperE2, n); - #endif - #if AXIS_IS_TMC(E3) - tmc_status(stepperE3, n); - #endif - #if AXIS_IS_TMC(E4) - tmc_status(stepperE4, n); - #endif - #if AXIS_IS_TMC(E5) - tmc_status(stepperE5, n); - #endif - #if AXIS_IS_TMC(E6) - tmc_status(stepperE6, n); - #endif - #if AXIS_IS_TMC(E7) - tmc_status(stepperE7, n); - #endif + TERN_(E0_IS_TRINAMIC, tmc_status(stepperE0, n)); + TERN_(E1_IS_TRINAMIC, tmc_status(stepperE1, n)); + TERN_(E2_IS_TRINAMIC, tmc_status(stepperE2, n)); + TERN_(E3_IS_TRINAMIC, tmc_status(stepperE3, n)); + TERN_(E4_IS_TRINAMIC, tmc_status(stepperE4, n)); + TERN_(E5_IS_TRINAMIC, tmc_status(stepperE5, n)); + TERN_(E6_IS_TRINAMIC, tmc_status(stepperE6, n)); + TERN_(E7_IS_TRINAMIC, tmc_status(stepperE7, n)); } SERIAL_EOL(); @@ -864,82 +763,38 @@ static void drv_status_loop(const TMC_drv_status_enum n OPTARGS_LOGICAL(const bool)) { if (TERN0(HAS_X_AXIS, x)) { - #if AXIS_IS_TMC(X) - tmc_parse_drv_status(stepperX, n); - #endif - #if AXIS_IS_TMC(X2) - tmc_parse_drv_status(stepperX2, n); - #endif + TERN_(X_IS_TRINAMIC, tmc_parse_drv_status(stepperX, n)); + TERN_(X2_IS_TRINAMIC, tmc_parse_drv_status(stepperX2, n)); } if (TERN0(HAS_Y_AXIS, y)) { - #if AXIS_IS_TMC(Y) - tmc_parse_drv_status(stepperY, n); - #endif - #if AXIS_IS_TMC(Y2) - tmc_parse_drv_status(stepperY2, n); - #endif + TERN_(Y_IS_TRINAMIC, tmc_parse_drv_status(stepperY, n)); + TERN_(Y2_IS_TRINAMIC, tmc_parse_drv_status(stepperY2, n)); } if (TERN0(HAS_Z_AXIS, z)) { - #if AXIS_IS_TMC(Z) - tmc_parse_drv_status(stepperZ, n); - #endif - #if AXIS_IS_TMC(Z2) - tmc_parse_drv_status(stepperZ2, n); - #endif - #if AXIS_IS_TMC(Z3) - tmc_parse_drv_status(stepperZ3, n); - #endif - #if AXIS_IS_TMC(Z4) - tmc_parse_drv_status(stepperZ4, n); - #endif + TERN_(Z_IS_TRINAMIC, tmc_parse_drv_status(stepperZ, n)); + TERN_(Z2_IS_TRINAMIC, tmc_parse_drv_status(stepperZ2, n)); + TERN_(Z3_IS_TRINAMIC, tmc_parse_drv_status(stepperZ3, n)); + TERN_(Z4_IS_TRINAMIC, tmc_parse_drv_status(stepperZ4, n)); } - #if AXIS_IS_TMC(I) - if (i) tmc_parse_drv_status(stepperI, n); - #endif - #if AXIS_IS_TMC(J) - if (j) tmc_parse_drv_status(stepperJ, n); - #endif - #if AXIS_IS_TMC(K) - if (k) tmc_parse_drv_status(stepperK, n); - #endif - #if AXIS_IS_TMC(U) - if (u) tmc_parse_drv_status(stepperU, n); - #endif - #if AXIS_IS_TMC(V) - if (v) tmc_parse_drv_status(stepperV, n); - #endif - #if AXIS_IS_TMC(W) - if (w) tmc_parse_drv_status(stepperW, n); - #endif + TERN_(I_IS_TRINAMIC, if (i) tmc_parse_drv_status(stepperI, n)); + TERN_(J_IS_TRINAMIC, if (j) tmc_parse_drv_status(stepperJ, n)); + TERN_(K_IS_TRINAMIC, if (k) tmc_parse_drv_status(stepperK, n)); + TERN_(U_IS_TRINAMIC, if (u) tmc_parse_drv_status(stepperU, n)); + TERN_(V_IS_TRINAMIC, if (v) tmc_parse_drv_status(stepperV, n)); + TERN_(W_IS_TRINAMIC, if (w) tmc_parse_drv_status(stepperW, n)); if (TERN0(HAS_EXTRUDERS, e)) { - #if AXIS_IS_TMC(E0) - tmc_parse_drv_status(stepperE0, n); - #endif - #if AXIS_IS_TMC(E1) - tmc_parse_drv_status(stepperE1, n); - #endif - #if AXIS_IS_TMC(E2) - tmc_parse_drv_status(stepperE2, n); - #endif - #if AXIS_IS_TMC(E3) - tmc_parse_drv_status(stepperE3, n); - #endif - #if AXIS_IS_TMC(E4) - tmc_parse_drv_status(stepperE4, n); - #endif - #if AXIS_IS_TMC(E5) - tmc_parse_drv_status(stepperE5, n); - #endif - #if AXIS_IS_TMC(E6) - tmc_parse_drv_status(stepperE6, n); - #endif - #if AXIS_IS_TMC(E7) - tmc_parse_drv_status(stepperE7, n); - #endif + TERN_(E0_IS_TRINAMIC, tmc_parse_drv_status(stepperE0, n)); + TERN_(E1_IS_TRINAMIC, tmc_parse_drv_status(stepperE1, n)); + TERN_(E2_IS_TRINAMIC, tmc_parse_drv_status(stepperE2, n)); + TERN_(E3_IS_TRINAMIC, tmc_parse_drv_status(stepperE3, n)); + TERN_(E4_IS_TRINAMIC, tmc_parse_drv_status(stepperE4, n)); + TERN_(E5_IS_TRINAMIC, tmc_parse_drv_status(stepperE5, n)); + TERN_(E6_IS_TRINAMIC, tmc_parse_drv_status(stepperE6, n)); + TERN_(E7_IS_TRINAMIC, tmc_parse_drv_status(stepperE7, n)); } SERIAL_EOL(); @@ -1078,82 +933,38 @@ static void tmc_get_registers(TMC_get_registers_enum n OPTARGS_LOGICAL(const bool)) { if (TERN0(HAS_X_AXIS, x)) { - #if AXIS_IS_TMC(X) - tmc_get_registers(stepperX, n); - #endif - #if AXIS_IS_TMC(X2) - tmc_get_registers(stepperX2, n); - #endif + TERN_(X_IS_TRINAMIC, tmc_get_registers(stepperX, n)); + TERN_(X2_IS_TRINAMIC, tmc_get_registers(stepperX2, n)); } if (TERN0(HAS_Y_AXIS, y)) { - #if AXIS_IS_TMC(Y) - tmc_get_registers(stepperY, n); - #endif - #if AXIS_IS_TMC(Y2) - tmc_get_registers(stepperY2, n); - #endif + TERN_(Y_IS_TRINAMIC, tmc_get_registers(stepperY, n)); + TERN_(Y2_IS_TRINAMIC, tmc_get_registers(stepperY2, n)); } if (TERN0(HAS_Z_AXIS, z)) { - #if AXIS_IS_TMC(Z) - tmc_get_registers(stepperZ, n); - #endif - #if AXIS_IS_TMC(Z2) - tmc_get_registers(stepperZ2, n); - #endif - #if AXIS_IS_TMC(Z3) - tmc_get_registers(stepperZ3, n); - #endif - #if AXIS_IS_TMC(Z4) - tmc_get_registers(stepperZ4, n); - #endif + TERN_(Z_IS_TRINAMIC, tmc_get_registers(stepperZ, n)); + TERN_(Z2_IS_TRINAMIC, tmc_get_registers(stepperZ2, n)); + TERN_(Z3_IS_TRINAMIC, tmc_get_registers(stepperZ3, n)); + TERN_(Z4_IS_TRINAMIC, tmc_get_registers(stepperZ4, n)); } - #if AXIS_IS_TMC(I) - if (i) tmc_get_registers(stepperI, n); - #endif - #if AXIS_IS_TMC(J) - if (j) tmc_get_registers(stepperJ, n); - #endif - #if AXIS_IS_TMC(K) - if (k) tmc_get_registers(stepperK, n); - #endif - #if AXIS_IS_TMC(U) - if (u) tmc_get_registers(stepperU, n); - #endif - #if AXIS_IS_TMC(V) - if (v) tmc_get_registers(stepperV, n); - #endif - #if AXIS_IS_TMC(W) - if (w) tmc_get_registers(stepperW, n); - #endif + TERN_(I_IS_TRINAMIC, if (i) tmc_get_registers(stepperI, n)); + TERN_(J_IS_TRINAMIC, if (j) tmc_get_registers(stepperJ, n)); + TERN_(K_IS_TRINAMIC, if (k) tmc_get_registers(stepperK, n)); + TERN_(U_IS_TRINAMIC, if (u) tmc_get_registers(stepperU, n)); + TERN_(V_IS_TRINAMIC, if (v) tmc_get_registers(stepperV, n)); + TERN_(W_IS_TRINAMIC, if (w) tmc_get_registers(stepperW, n)); if (TERN0(HAS_EXTRUDERS, e)) { - #if AXIS_IS_TMC(E0) - tmc_get_registers(stepperE0, n); - #endif - #if AXIS_IS_TMC(E1) - tmc_get_registers(stepperE1, n); - #endif - #if AXIS_IS_TMC(E2) - tmc_get_registers(stepperE2, n); - #endif - #if AXIS_IS_TMC(E3) - tmc_get_registers(stepperE3, n); - #endif - #if AXIS_IS_TMC(E4) - tmc_get_registers(stepperE4, n); - #endif - #if AXIS_IS_TMC(E5) - tmc_get_registers(stepperE5, n); - #endif - #if AXIS_IS_TMC(E6) - tmc_get_registers(stepperE6, n); - #endif - #if AXIS_IS_TMC(E7) - tmc_get_registers(stepperE7, n); - #endif + TERN_(E0_IS_TRINAMIC, tmc_get_registers(stepperE0, n)); + TERN_(E1_IS_TRINAMIC, tmc_get_registers(stepperE1, n)); + TERN_(E2_IS_TRINAMIC, tmc_get_registers(stepperE2, n)); + TERN_(E3_IS_TRINAMIC, tmc_get_registers(stepperE3, n)); + TERN_(E4_IS_TRINAMIC, tmc_get_registers(stepperE4, n)); + TERN_(E5_IS_TRINAMIC, tmc_get_registers(stepperE5, n)); + TERN_(E6_IS_TRINAMIC, tmc_get_registers(stepperE6, n)); + TERN_(E7_IS_TRINAMIC, tmc_get_registers(stepperE7, n)); } SERIAL_EOL(); @@ -1243,82 +1054,38 @@ void test_tmc_connection(LOGICAL_AXIS_ARGS_LC(const bool)) { uint8_t axis_connection = 0; if (TERN0(HAS_X_AXIS, x)) { - #if AXIS_IS_TMC(X) - axis_connection += test_connection(stepperX); - #endif - #if AXIS_IS_TMC(X2) - axis_connection += test_connection(stepperX2); - #endif + TERN_(X_IS_TRINAMIC, axis_connection += test_connection(stepperX)); + TERN_(X2_IS_TRINAMIC, axis_connection += test_connection(stepperX2)); } if (TERN0(HAS_Y_AXIS, y)) { - #if AXIS_IS_TMC(Y) - axis_connection += test_connection(stepperY); - #endif - #if AXIS_IS_TMC(Y2) - axis_connection += test_connection(stepperY2); - #endif + TERN_(Y_IS_TRINAMIC, axis_connection += test_connection(stepperY)); + TERN_(Y2_IS_TRINAMIC, axis_connection += test_connection(stepperY2)); } if (TERN0(HAS_Z_AXIS, z)) { - #if AXIS_IS_TMC(Z) - axis_connection += test_connection(stepperZ); - #endif - #if AXIS_IS_TMC(Z2) - axis_connection += test_connection(stepperZ2); - #endif - #if AXIS_IS_TMC(Z3) - axis_connection += test_connection(stepperZ3); - #endif - #if AXIS_IS_TMC(Z4) - axis_connection += test_connection(stepperZ4); - #endif + TERN_(Z_IS_TRINAMIC, axis_connection += test_connection(stepperZ)); + TERN_(Z2_IS_TRINAMIC, axis_connection += test_connection(stepperZ2)); + TERN_(Z3_IS_TRINAMIC, axis_connection += test_connection(stepperZ3)); + TERN_(Z4_IS_TRINAMIC, axis_connection += test_connection(stepperZ4)); } - #if AXIS_IS_TMC(I) - if (i) axis_connection += test_connection(stepperI); - #endif - #if AXIS_IS_TMC(J) - if (j) axis_connection += test_connection(stepperJ); - #endif - #if AXIS_IS_TMC(K) - if (k) axis_connection += test_connection(stepperK); - #endif - #if AXIS_IS_TMC(U) - if (u) axis_connection += test_connection(stepperU); - #endif - #if AXIS_IS_TMC(V) - if (v) axis_connection += test_connection(stepperV); - #endif - #if AXIS_IS_TMC(W) - if (w) axis_connection += test_connection(stepperW); - #endif + TERN_(I_IS_TRINAMIC, if (i) axis_connection += test_connection(stepperI)); + TERN_(J_IS_TRINAMIC, if (j) axis_connection += test_connection(stepperJ)); + TERN_(K_IS_TRINAMIC, if (k) axis_connection += test_connection(stepperK)); + TERN_(U_IS_TRINAMIC, if (u) axis_connection += test_connection(stepperU)); + TERN_(V_IS_TRINAMIC, if (v) axis_connection += test_connection(stepperV)); + TERN_(W_IS_TRINAMIC, if (w) axis_connection += test_connection(stepperW)); if (TERN0(HAS_EXTRUDERS, e)) { - #if AXIS_IS_TMC(E0) - axis_connection += test_connection(stepperE0); - #endif - #if AXIS_IS_TMC(E1) - axis_connection += test_connection(stepperE1); - #endif - #if AXIS_IS_TMC(E2) - axis_connection += test_connection(stepperE2); - #endif - #if AXIS_IS_TMC(E3) - axis_connection += test_connection(stepperE3); - #endif - #if AXIS_IS_TMC(E4) - axis_connection += test_connection(stepperE4); - #endif - #if AXIS_IS_TMC(E5) - axis_connection += test_connection(stepperE5); - #endif - #if AXIS_IS_TMC(E6) - axis_connection += test_connection(stepperE6); - #endif - #if AXIS_IS_TMC(E7) - axis_connection += test_connection(stepperE7); - #endif + TERN_(E0_IS_TRINAMIC, axis_connection += test_connection(stepperE0)); + TERN_(E1_IS_TRINAMIC, axis_connection += test_connection(stepperE1)); + TERN_(E2_IS_TRINAMIC, axis_connection += test_connection(stepperE2)); + TERN_(E3_IS_TRINAMIC, axis_connection += test_connection(stepperE3)); + TERN_(E4_IS_TRINAMIC, axis_connection += test_connection(stepperE4)); + TERN_(E5_IS_TRINAMIC, axis_connection += test_connection(stepperE5)); + TERN_(E6_IS_TRINAMIC, axis_connection += test_connection(stepperE6)); + TERN_(E7_IS_TRINAMIC, axis_connection += test_connection(stepperE7)); } if (axis_connection) LCD_MESSAGE(MSG_ERROR_TMC); diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 85d27e14e8..6c8af9ddb0 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -88,10 +88,8 @@ fr_mm_s = HYPOT(minfr, minfr); // Set homing current to X and Y axis if defined - #if HAS_CURRENT_HOME(X) - set_homing_current(X_AXIS); - #endif - #if HAS_CURRENT_HOME(Y) && NONE(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) + TERN_(X_HAS_HOME_CURRENT, set_homing_current(X_AXIS)); + #if Y_HAS_HOME_CURRENT && NONE(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) set_homing_current(Y_AXIS); #endif @@ -113,10 +111,8 @@ current_position.set(0.0, 0.0); - #if HAS_CURRENT_HOME(X) - restore_homing_current(X_AXIS); - #endif - #if HAS_CURRENT_HOME(Y) && NONE(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) + TERN_(X_HAS_HOME_CURRENT, restore_homing_current(X_AXIS)); + #if Y_HAS_HOME_CURRENT && NONE(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) restore_homing_current(Y_AXIS); #endif diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp index 9a0cb0054b..0654eb0ec9 100644 --- a/Marlin/src/gcode/calibrate/G34.cpp +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -95,37 +95,36 @@ void GcodeSuite::G34() { #if HAS_MOTOR_CURRENT_SPI const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); - const uint32_t previous_current = stepper.motor_current_setting[Z_AXIS]; + const uint32_t previous_current_Z = stepper.motor_current_setting[Z_AXIS]; stepper.set_digipot_current(Z_AXIS, target_current); #elif HAS_MOTOR_CURRENT_PWM const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); - const uint32_t previous_current = stepper.motor_current_setting[1]; // Z + const uint32_t previous_current_Z = stepper.motor_current_setting[1]; // Z stepper.set_digipot_current(1, target_current); #elif HAS_MOTOR_CURRENT_DAC const float target_current = parser.floatval('S', GANTRY_CALIBRATION_CURRENT); - const float previous_current = dac_amps(Z_AXIS, target_current); + const float previous_current_Z = dac_amps(Z_AXIS, target_current); stepper_dac.set_current_value(Z_AXIS, target_current); #elif HAS_MOTOR_CURRENT_I2C const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); - previous_current = dac_amps(Z_AXIS); + const float previous_current_Z = dac_amps(Z_AXIS); digipot_i2c.set_current(Z_AXIS, target_current) #elif HAS_TRINAMIC_CONFIG const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); - static uint16_t previous_current_arr[NUM_Z_STEPPERS]; - #if AXIS_IS_TMC(Z) - previous_current_arr[0] = stepperZ.getMilliamps(); + #if Z_IS_TRINAMIC + static uint16_t previous_current_Z = stepperZ.getMilliamps(); stepperZ.rms_current(target_current); #endif - #if AXIS_IS_TMC(Z2) - previous_current_arr[1] = stepperZ2.getMilliamps(); + #if Z2_IS_TRINAMIC + static uint16_t previous_current_Z2 = stepperZ2.getMilliamps(); stepperZ2.rms_current(target_current); #endif - #if AXIS_IS_TMC(Z3) - previous_current_arr[2] = stepperZ3.getMilliamps(); + #if Z3_IS_TRINAMIC + static uint16_t previous_current_Z3 = stepperZ3.getMilliamps(); stepperZ3.rms_current(target_current); #endif - #if AXIS_IS_TMC(Z4) - previous_current_arr[3] = stepperZ4.getMilliamps(); + #if Z4_IS_TRINAMIC + static uint16_t previous_current_Z4 = stepperZ4.getMilliamps(); stepperZ4.rms_current(target_current); #endif #endif @@ -140,26 +139,18 @@ void GcodeSuite::G34() { #endif #if HAS_MOTOR_CURRENT_SPI - stepper.set_digipot_current(Z_AXIS, previous_current); + stepper.set_digipot_current(Z_AXIS, previous_current_Z); #elif HAS_MOTOR_CURRENT_PWM - stepper.set_digipot_current(1, previous_current); + stepper.set_digipot_current(1, previous_current_Z); #elif HAS_MOTOR_CURRENT_DAC - stepper_dac.set_current_value(Z_AXIS, previous_current); + stepper_dac.set_current_value(Z_AXIS, previous_current_Z); #elif HAS_MOTOR_CURRENT_I2C - digipot_i2c.set_current(Z_AXIS, previous_current) + digipot_i2c.set_current(Z_AXIS, previous_current_Z) #elif HAS_TRINAMIC_CONFIG - #if AXIS_IS_TMC(Z) - stepperZ.rms_current(previous_current_arr[0]); - #endif - #if AXIS_IS_TMC(Z2) - stepperZ2.rms_current(previous_current_arr[1]); - #endif - #if AXIS_IS_TMC(Z3) - stepperZ3.rms_current(previous_current_arr[2]); - #endif - #if AXIS_IS_TMC(Z4) - stepperZ4.rms_current(previous_current_arr[3]); - #endif + TERN_(Z_IS_TRINAMIC, stepperZ.rms_current(previous_current_Z)); + TERN_(Z2_IS_TRINAMIC, stepperZ2.rms_current(previous_current_Z2)); + TERN_(Z3_IS_TRINAMIC, stepperZ3.rms_current(previous_current_Z3)); + TERN_(Z4_IS_TRINAMIC, stepperZ4.rms_current(previous_current_Z4)); #endif // Back off end plate, back to normal motion range diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index c0dc456a8a..43d980098e 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -60,173 +60,96 @@ void GcodeSuite::M906() { bool report = true; - #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) + #if ANY(X2_IS_TRINAMIC, Y2_IS_TRINAMIC, Z2_IS_TRINAMIC, Z3_IS_TRINAMIC, Z4_IS_TRINAMIC) const int8_t index = parser.byteval('I', -1); - #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) + #elif ANY(X_IS_TRINAMIC, Y_IS_TRINAMIC, Z_IS_TRINAMIC) constexpr int8_t index = -1; #endif LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(AXIS_CHAR(i))) { report = false; switch (i) { - #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) + #if X_IS_TRINAMIC || X2_IS_TRINAMIC case X_AXIS: - #if AXIS_IS_TMC(X) - if (index < 0 || index == 0) TMC_SET_CURRENT(X); - #endif - #if AXIS_IS_TMC(X2) - if (index < 0 || index == 1) TMC_SET_CURRENT(X2); - #endif + TERN_(X_IS_TRINAMIC, if (index < 0 || index == 0) TMC_SET_CURRENT(X)); + TERN_(X2_IS_TRINAMIC, if (index < 0 || index == 1) TMC_SET_CURRENT(X2)); break; #endif - #if AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) + #if Y_IS_TRINAMIC || Y2_IS_TRINAMIC case Y_AXIS: - #if AXIS_IS_TMC(Y) - if (index < 0 || index == 0) TMC_SET_CURRENT(Y); - #endif - #if AXIS_IS_TMC(Y2) - if (index < 0 || index == 1) TMC_SET_CURRENT(Y2); - #endif + TERN_(Y_IS_TRINAMIC, if (index < 0 || index == 0) TMC_SET_CURRENT(Y)); + TERN_(Y2_IS_TRINAMIC, if (index < 0 || index == 1) TMC_SET_CURRENT(Y2)); break; #endif - #if AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) + #if ANY(Z_IS_TRINAMIC, Z2_IS_TRINAMIC, Z3_IS_TRINAMIC, Z4_IS_TRINAMIC) case Z_AXIS: - #if AXIS_IS_TMC(Z) - if (index < 0 || index == 0) TMC_SET_CURRENT(Z); - #endif - #if AXIS_IS_TMC(Z2) - if (index < 0 || index == 1) TMC_SET_CURRENT(Z2); - #endif - #if AXIS_IS_TMC(Z3) - if (index < 0 || index == 2) TMC_SET_CURRENT(Z3); - #endif - #if AXIS_IS_TMC(Z4) - if (index < 0 || index == 3) TMC_SET_CURRENT(Z4); - #endif + TERN_(Z_IS_TRINAMIC, if (index < 0 || index == 0) TMC_SET_CURRENT(Z)); + TERN_(Z2_IS_TRINAMIC, if (index < 0 || index == 1) TMC_SET_CURRENT(Z2)); + TERN_(Z3_IS_TRINAMIC, if (index < 0 || index == 2) TMC_SET_CURRENT(Z3)); + TERN_(Z4_IS_TRINAMIC, if (index < 0 || index == 3) TMC_SET_CURRENT(Z4)); break; #endif - #if AXIS_IS_TMC(I) + #if I_IS_TRINAMIC case I_AXIS: TMC_SET_CURRENT(I); break; #endif - #if AXIS_IS_TMC(J) + #if J_IS_TRINAMIC case J_AXIS: TMC_SET_CURRENT(J); break; #endif - #if AXIS_IS_TMC(K) + #if K_IS_TRINAMIC case K_AXIS: TMC_SET_CURRENT(K); break; #endif - #if AXIS_IS_TMC(U) + #if U_IS_TRINAMIC case U_AXIS: TMC_SET_CURRENT(U); break; #endif - #if AXIS_IS_TMC(V) + #if V_IS_TRINAMIC case V_AXIS: TMC_SET_CURRENT(V); break; #endif - #if AXIS_IS_TMC(W) + #if W_IS_TRINAMIC case W_AXIS: TMC_SET_CURRENT(W); break; #endif - #if AXIS_IS_TMC(E0) || AXIS_IS_TMC(E1) || AXIS_IS_TMC(E2) || AXIS_IS_TMC(E3) || AXIS_IS_TMC(E4) || AXIS_IS_TMC(E5) || AXIS_IS_TMC(E6) || AXIS_IS_TMC(E7) + #if ANY(E0_IS_TRINAMIC, E1_IS_TRINAMIC, E2_IS_TRINAMIC, E3_IS_TRINAMIC, E4_IS_TRINAMIC, E5_IS_TRINAMIC, E6_IS_TRINAMIC, E7_IS_TRINAMIC) case E_AXIS: { const int8_t eindex = get_target_e_stepper_from_command(-2); - #if AXIS_IS_TMC(E0) - if (eindex < 0 || eindex == 0) TMC_SET_CURRENT(E0); - #endif - #if AXIS_IS_TMC(E1) - if (eindex < 0 || eindex == 1) TMC_SET_CURRENT(E1); - #endif - #if AXIS_IS_TMC(E2) - if (eindex < 0 || eindex == 2) TMC_SET_CURRENT(E2); - #endif - #if AXIS_IS_TMC(E3) - if (eindex < 0 || eindex == 3) TMC_SET_CURRENT(E3); - #endif - #if AXIS_IS_TMC(E4) - if (eindex < 0 || eindex == 4) TMC_SET_CURRENT(E4); - #endif - #if AXIS_IS_TMC(E5) - if (eindex < 0 || eindex == 5) TMC_SET_CURRENT(E5); - #endif - #if AXIS_IS_TMC(E6) - if (eindex < 0 || eindex == 6) TMC_SET_CURRENT(E6); - #endif - #if AXIS_IS_TMC(E7) - if (eindex < 0 || eindex == 7) TMC_SET_CURRENT(E7); - #endif + TERN_(E0_IS_TRINAMIC, if (eindex < 0 || eindex == 0) TMC_SET_CURRENT(E0)); + TERN_(E1_IS_TRINAMIC, if (eindex < 0 || eindex == 1) TMC_SET_CURRENT(E1)); + TERN_(E2_IS_TRINAMIC, if (eindex < 0 || eindex == 2) TMC_SET_CURRENT(E2)); + TERN_(E3_IS_TRINAMIC, if (eindex < 0 || eindex == 3) TMC_SET_CURRENT(E3)); + TERN_(E4_IS_TRINAMIC, if (eindex < 0 || eindex == 4) TMC_SET_CURRENT(E4)); + TERN_(E5_IS_TRINAMIC, if (eindex < 0 || eindex == 5) TMC_SET_CURRENT(E5)); + TERN_(E6_IS_TRINAMIC, if (eindex < 0 || eindex == 6) TMC_SET_CURRENT(E6)); + TERN_(E7_IS_TRINAMIC, if (eindex < 0 || eindex == 7) TMC_SET_CURRENT(E7)); } break; #endif } } if (report) { - #if AXIS_IS_TMC(X) - TMC_SAY_CURRENT(X); - #endif - #if AXIS_IS_TMC(X2) - TMC_SAY_CURRENT(X2); - #endif - #if AXIS_IS_TMC(Y) - TMC_SAY_CURRENT(Y); - #endif - #if AXIS_IS_TMC(Y2) - TMC_SAY_CURRENT(Y2); - #endif - #if AXIS_IS_TMC(Z) - TMC_SAY_CURRENT(Z); - #endif - #if AXIS_IS_TMC(Z2) - TMC_SAY_CURRENT(Z2); - #endif - #if AXIS_IS_TMC(Z3) - TMC_SAY_CURRENT(Z3); - #endif - #if AXIS_IS_TMC(Z4) - TMC_SAY_CURRENT(Z4); - #endif - #if AXIS_IS_TMC(I) - TMC_SAY_CURRENT(I); - #endif - #if AXIS_IS_TMC(J) - TMC_SAY_CURRENT(J); - #endif - #if AXIS_IS_TMC(K) - TMC_SAY_CURRENT(K); - #endif - #if AXIS_IS_TMC(U) - TMC_SAY_CURRENT(U); - #endif - #if AXIS_IS_TMC(V) - TMC_SAY_CURRENT(V); - #endif - #if AXIS_IS_TMC(W) - TMC_SAY_CURRENT(W); - #endif - - #if AXIS_IS_TMC(E0) - TMC_SAY_CURRENT(E0); - #endif - #if AXIS_IS_TMC(E1) - TMC_SAY_CURRENT(E1); - #endif - #if AXIS_IS_TMC(E2) - TMC_SAY_CURRENT(E2); - #endif - #if AXIS_IS_TMC(E3) - TMC_SAY_CURRENT(E3); - #endif - #if AXIS_IS_TMC(E4) - TMC_SAY_CURRENT(E4); - #endif - #if AXIS_IS_TMC(E5) - TMC_SAY_CURRENT(E5); - #endif - #if AXIS_IS_TMC(E6) - TMC_SAY_CURRENT(E6); - #endif - #if AXIS_IS_TMC(E7) - TMC_SAY_CURRENT(E7); - #endif + TERN_(X_IS_TRINAMIC, TMC_SAY_CURRENT(X)); + TERN_(X2_IS_TRINAMIC, TMC_SAY_CURRENT(X2)); + TERN_(Y_IS_TRINAMIC, TMC_SAY_CURRENT(Y)); + TERN_(Y2_IS_TRINAMIC, TMC_SAY_CURRENT(Y2)); + TERN_(Z_IS_TRINAMIC, TMC_SAY_CURRENT(Z)); + TERN_(Z2_IS_TRINAMIC, TMC_SAY_CURRENT(Z2)); + TERN_(Z3_IS_TRINAMIC, TMC_SAY_CURRENT(Z3)); + TERN_(Z4_IS_TRINAMIC, TMC_SAY_CURRENT(Z4)); + TERN_(I_IS_TRINAMIC, TMC_SAY_CURRENT(I)); + TERN_(J_IS_TRINAMIC, TMC_SAY_CURRENT(J)); + TERN_(K_IS_TRINAMIC, TMC_SAY_CURRENT(K)); + TERN_(U_IS_TRINAMIC, TMC_SAY_CURRENT(U)); + TERN_(V_IS_TRINAMIC, TMC_SAY_CURRENT(V)); + TERN_(W_IS_TRINAMIC, TMC_SAY_CURRENT(W)); + TERN_(E0_IS_TRINAMIC, TMC_SAY_CURRENT(E0)); + TERN_(E1_IS_TRINAMIC, TMC_SAY_CURRENT(E1)); + TERN_(E2_IS_TRINAMIC, TMC_SAY_CURRENT(E2)); + TERN_(E3_IS_TRINAMIC, TMC_SAY_CURRENT(E3)); + TERN_(E4_IS_TRINAMIC, TMC_SAY_CURRENT(E4)); + TERN_(E5_IS_TRINAMIC, TMC_SAY_CURRENT(E5)); + TERN_(E6_IS_TRINAMIC, TMC_SAY_CURRENT(E6)); + TERN_(E7_IS_TRINAMIC, TMC_SAY_CURRENT(E7)); } } @@ -240,93 +163,67 @@ void GcodeSuite::M906_report(const bool forReplay/*=true*/) { SERIAL_ECHOPGM(" M906"); }; - #if AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) \ - || AXIS_IS_TMC(I) || AXIS_IS_TMC(J) || AXIS_IS_TMC(K) \ - || AXIS_IS_TMC(U) || AXIS_IS_TMC(V) || AXIS_IS_TMC(W) + #if ANY(X_IS_TRINAMIC, Y_IS_TRINAMIC, Z_IS_TRINAMIC, I_IS_TRINAMIC, J_IS_TRINAMIC, K_IS_TRINAMIC, U_IS_TRINAMIC, V_IS_TRINAMIC, W_IS_TRINAMIC) say_M906(forReplay); - #if AXIS_IS_TMC(X) - SERIAL_ECHOPGM_P(SP_X_STR, stepperX.getMilliamps()); - #endif - #if AXIS_IS_TMC(Y) - SERIAL_ECHOPGM_P(SP_Y_STR, stepperY.getMilliamps()); - #endif - #if AXIS_IS_TMC(Z) - SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ.getMilliamps()); - #endif - #if AXIS_IS_TMC(I) - SERIAL_ECHOPGM_P(SP_I_STR, stepperI.getMilliamps()); - #endif - #if AXIS_IS_TMC(J) - SERIAL_ECHOPGM_P(SP_J_STR, stepperJ.getMilliamps()); - #endif - #if AXIS_IS_TMC(K) - SERIAL_ECHOPGM_P(SP_K_STR, stepperK.getMilliamps()); - #endif - #if AXIS_IS_TMC(U) - SERIAL_ECHOPGM_P(SP_U_STR, stepperU.getMilliamps()); - #endif - #if AXIS_IS_TMC(V) - SERIAL_ECHOPGM_P(SP_V_STR, stepperV.getMilliamps()); - #endif - #if AXIS_IS_TMC(W) - SERIAL_ECHOPGM_P(SP_W_STR, stepperW.getMilliamps()); - #endif + TERN_(X_IS_TRINAMIC, SERIAL_ECHOPGM_P(SP_X_STR, stepperX.getMilliamps())); + TERN_(Y_IS_TRINAMIC, SERIAL_ECHOPGM_P(SP_Y_STR, stepperY.getMilliamps())); + TERN_(Z_IS_TRINAMIC, SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ.getMilliamps())); + TERN_(I_IS_TRINAMIC, SERIAL_ECHOPGM_P(SP_I_STR, stepperI.getMilliamps())); + TERN_(J_IS_TRINAMIC, SERIAL_ECHOPGM_P(SP_J_STR, stepperJ.getMilliamps())); + TERN_(K_IS_TRINAMIC, SERIAL_ECHOPGM_P(SP_K_STR, stepperK.getMilliamps())); + TERN_(U_IS_TRINAMIC, SERIAL_ECHOPGM_P(SP_U_STR, stepperU.getMilliamps())); + TERN_(V_IS_TRINAMIC, SERIAL_ECHOPGM_P(SP_V_STR, stepperV.getMilliamps())); + TERN_(W_IS_TRINAMIC, SERIAL_ECHOPGM_P(SP_W_STR, stepperW.getMilliamps())); SERIAL_EOL(); #endif - #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) + #if X2_IS_TRINAMIC || Y2_IS_TRINAMIC || Z2_IS_TRINAMIC say_M906(forReplay); SERIAL_ECHOPGM(" I1"); - #if AXIS_IS_TMC(X2) - SERIAL_ECHOPGM_P(SP_X_STR, stepperX2.getMilliamps()); - #endif - #if AXIS_IS_TMC(Y2) - SERIAL_ECHOPGM_P(SP_Y_STR, stepperY2.getMilliamps()); - #endif - #if AXIS_IS_TMC(Z2) - SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ2.getMilliamps()); - #endif + TERN_(X2_IS_TRINAMIC, SERIAL_ECHOPGM_P(SP_X_STR, stepperX2.getMilliamps())); + TERN_(Y2_IS_TRINAMIC, SERIAL_ECHOPGM_P(SP_Y_STR, stepperY2.getMilliamps())); + TERN_(Z2_IS_TRINAMIC, SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ2.getMilliamps())); SERIAL_EOL(); #endif - #if AXIS_IS_TMC(Z3) + #if Z3_IS_TRINAMIC say_M906(forReplay); SERIAL_ECHOLNPGM(" I2 Z", stepperZ3.getMilliamps()); #endif - #if AXIS_IS_TMC(Z4) + #if Z4_IS_TRINAMIC say_M906(forReplay); SERIAL_ECHOLNPGM(" I3 Z", stepperZ4.getMilliamps()); #endif - #if AXIS_IS_TMC(E0) + #if E0_IS_TRINAMIC say_M906(forReplay); SERIAL_ECHOLNPGM(" T0 E", stepperE0.getMilliamps()); #endif - #if AXIS_IS_TMC(E1) + #if E1_IS_TRINAMIC say_M906(forReplay); SERIAL_ECHOLNPGM(" T1 E", stepperE1.getMilliamps()); #endif - #if AXIS_IS_TMC(E2) + #if E2_IS_TRINAMIC say_M906(forReplay); SERIAL_ECHOLNPGM(" T2 E", stepperE2.getMilliamps()); #endif - #if AXIS_IS_TMC(E3) + #if E3_IS_TRINAMIC say_M906(forReplay); SERIAL_ECHOLNPGM(" T3 E", stepperE3.getMilliamps()); #endif - #if AXIS_IS_TMC(E4) + #if E4_IS_TRINAMIC say_M906(forReplay); SERIAL_ECHOLNPGM(" T4 E", stepperE4.getMilliamps()); #endif - #if AXIS_IS_TMC(E5) + #if E5_IS_TRINAMIC say_M906(forReplay); SERIAL_ECHOLNPGM(" T5 E", stepperE5.getMilliamps()); #endif - #if AXIS_IS_TMC(E6) + #if E6_IS_TRINAMIC say_M906(forReplay); SERIAL_ECHOLNPGM(" T6 E", stepperE6.getMilliamps()); #endif - #if AXIS_IS_TMC(E7) + #if E7_IS_TRINAMIC say_M906(forReplay); SERIAL_ECHOLNPGM(" T7 E", stepperE7.getMilliamps()); #endif diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index ba6d9538a4..f4b0ac3670 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -274,7 +274,23 @@ } /** - * M913: Set HYBRID_THRESHOLD speed. + * M913: Set HYBRID_THRESHOLD speed, aka PWM Threshold. + * + * Parameters: + * I - For multi-stepper axes, the one-based index of the stepper to modify in each set + * + * E - Set threshold for one or more Extruders + * T - The zero-based index of the Extruder to modify + * + * X - Set threshold for one or more X axis steppers + * Y - Set threshold for one or more Y axis steppers + * Z - Set threshold for one or more Z axis steppers + * A - Set threshold for one or more A axis steppers + * B - Set threshold for one or more B axis steppers + * C - Set threshold for one or more C axis steppers + * U - Set threshold for one or more U axis steppers + * V - Set threshold for one or more V axis steppers + * W - Set threshold for one or more W axis steppers */ void GcodeSuite::M913() { #define TMC_SAY_PWMTHRS(A,Q) tmc_print_pwmthrs(stepper##Q) @@ -283,9 +299,9 @@ #define TMC_SET_PWMTHRS_E(E) stepperE##E.set_pwm_thrs(value) bool report = true; - #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) + #if ANY(X2_IS_TRINAMIC, Y2_IS_TRINAMIC, Z2_IS_TRINAMIC, Z3_IS_TRINAMIC, Z4_IS_TRINAMIC) const uint8_t index = parser.byteval('I'); - #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) + #elif ANY(X_IS_TRINAMIC, Y_IS_TRINAMIC, Z_IS_TRINAMIC) constexpr uint8_t index = 0; #endif LOOP_LOGICAL_AXES(i) if (int32_t value = parser.longval(AXIS_CHAR(i))) { @@ -387,70 +403,37 @@ SERIAL_ECHOPGM(" M913"); }; - #if X_HAS_STEALTHCHOP || Y_HAS_STEALTHCHOP || Z_HAS_STEALTHCHOP + #if ANY(X_HAS_STEALTHCHOP, Y_HAS_STEALTHCHOP, Z_HAS_STEALTHCHOP, I_HAS_STEALTHCHOP, J_HAS_STEALTHCHOP, K_HAS_STEALTHCHOP, U_HAS_STEALTHCHOP, V_HAS_STEALTHCHOP, W_HAS_STEALTHCHOP) say_M913(forReplay); - #if X_HAS_STEALTHCHOP - SERIAL_ECHOPGM_P(SP_X_STR, stepperX.get_pwm_thrs()); - #endif - #if Y_HAS_STEALTHCHOP - SERIAL_ECHOPGM_P(SP_Y_STR, stepperY.get_pwm_thrs()); - #endif - #if Z_HAS_STEALTHCHOP - SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ.get_pwm_thrs()); - #endif + TERN_(X_HAS_STEALTHCHOP, SERIAL_ECHOPGM_P(SP_X_STR, stepperX.get_pwm_thrs())); + TERN_(Y_HAS_STEALTHCHOP, SERIAL_ECHOPGM_P(SP_Y_STR, stepperY.get_pwm_thrs())); + TERN_(Z_HAS_STEALTHCHOP, SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ.get_pwm_thrs())); + TERN_(I_HAS_STEALTHCHOP, SERIAL_ECHOPGM_P(SP_I_STR, stepperI.get_pwm_thrs())); + TERN_(J_HAS_STEALTHCHOP, SERIAL_ECHOPGM_P(SP_J_STR, stepperJ.get_pwm_thrs())); + TERN_(K_HAS_STEALTHCHOP, SERIAL_ECHOPGM_P(SP_K_STR, stepperK.get_pwm_thrs())); + TERN_(U_HAS_STEALTHCHOP, SERIAL_ECHOPGM_P(SP_U_STR, stepperU.get_pwm_thrs())); + TERN_(V_HAS_STEALTHCHOP, SERIAL_ECHOPGM_P(SP_V_STR, stepperV.get_pwm_thrs())); + TERN_(W_HAS_STEALTHCHOP, SERIAL_ECHOPGM_P(SP_W_STR, stepperW.get_pwm_thrs())); SERIAL_EOL(); #endif #if X2_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP say_M913(forReplay); SERIAL_ECHOPGM(" I2"); - #if X2_HAS_STEALTHCHOP - SERIAL_ECHOPGM_P(SP_X_STR, stepperX2.get_pwm_thrs()); - #endif - #if Y2_HAS_STEALTHCHOP - SERIAL_ECHOPGM_P(SP_Y_STR, stepperY2.get_pwm_thrs()); - #endif - #if Z2_HAS_STEALTHCHOP - SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ2.get_pwm_thrs()); - #endif + TERN_(X2_HAS_STEALTHCHOP, SERIAL_ECHOPGM_P(SP_X_STR, stepperX2.get_pwm_thrs())); + TERN_(Y2_HAS_STEALTHCHOP, SERIAL_ECHOPGM_P(SP_Y_STR, stepperY2.get_pwm_thrs())); + TERN_(Z2_HAS_STEALTHCHOP, SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ2.get_pwm_thrs())); SERIAL_EOL(); #endif - #if Z3_HAS_STEALTHCHOP say_M913(forReplay); SERIAL_ECHOLNPGM(" I3 Z", stepperZ3.get_pwm_thrs()); #endif - #if Z4_HAS_STEALTHCHOP say_M913(forReplay); SERIAL_ECHOLNPGM(" I4 Z", stepperZ4.get_pwm_thrs()); #endif - #if I_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPGM_P(SP_I_STR, stepperI.get_pwm_thrs()); - #endif - #if J_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPGM_P(SP_J_STR, stepperJ.get_pwm_thrs()); - #endif - #if K_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPGM_P(SP_K_STR, stepperK.get_pwm_thrs()); - #endif - #if U_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPGM_P(SP_U_STR, stepperU.get_pwm_thrs()); - #endif - #if V_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPGM_P(SP_V_STR, stepperV.get_pwm_thrs()); - #endif - #if W_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPGM_P(SP_W_STR, stepperW.get_pwm_thrs()); - #endif - #if E0_HAS_STEALTHCHOP say_M913(forReplay); SERIAL_ECHOLNPGM(" T0 E", stepperE0.get_pwm_thrs()); @@ -498,7 +481,19 @@ } /** - * M914: Set StallGuard sensitivity. + * M914: Set StallGuard sensitivity in terms of "homing threshold" (not for stall detection during printing). + * + * Parameters: + * I - For multi-stepper axes, the one-based index of the stepper to modify in each set + * X - Set threshold for one or more X axis steppers + * Y - Set threshold for one or more Y axis steppers + * Z - Set threshold for one or more Z axis steppers + * A - Set threshold for one or more A axis steppers + * B - Set threshold for one or more B axis steppers + * C - Set threshold for one or more C axis steppers + * U - Set threshold for one or more U axis steppers + * V - Set threshold for one or more V axis steppers + * W - Set threshold for one or more W axis steppers */ void GcodeSuite::M914() { bool report = true; @@ -536,33 +531,33 @@ #if K_SENSORLESS case K_AXIS: stepperK.homing_threshold(value); break; #endif - #if U_SENSORLESS && AXIS_HAS_STALLGUARD(U) + #if U_SENSORLESS case U_AXIS: stepperU.homing_threshold(value); break; #endif - #if V_SENSORLESS && AXIS_HAS_STALLGUARD(V) + #if V_SENSORLESS case V_AXIS: stepperV.homing_threshold(value); break; #endif - #if W_SENSORLESS && AXIS_HAS_STALLGUARD(W) + #if W_SENSORLESS case W_AXIS: stepperW.homing_threshold(value); break; #endif } } if (report) { - TERN_(X_SENSORLESS, tmc_print_sgt(stepperX)); + TERN_( X_SENSORLESS, tmc_print_sgt(stepperX)); TERN_(X2_SENSORLESS, tmc_print_sgt(stepperX2)); - TERN_(Y_SENSORLESS, tmc_print_sgt(stepperY)); + TERN_( Y_SENSORLESS, tmc_print_sgt(stepperY)); TERN_(Y2_SENSORLESS, tmc_print_sgt(stepperY2)); - TERN_(Z_SENSORLESS, tmc_print_sgt(stepperZ)); + TERN_( Z_SENSORLESS, tmc_print_sgt(stepperZ)); TERN_(Z2_SENSORLESS, tmc_print_sgt(stepperZ2)); TERN_(Z3_SENSORLESS, tmc_print_sgt(stepperZ3)); TERN_(Z4_SENSORLESS, tmc_print_sgt(stepperZ4)); - TERN_(I_SENSORLESS, tmc_print_sgt(stepperI)); - TERN_(J_SENSORLESS, tmc_print_sgt(stepperJ)); - TERN_(K_SENSORLESS, tmc_print_sgt(stepperK)); - TERN_(U_SENSORLESS, tmc_print_sgt(stepperU)); - TERN_(V_SENSORLESS, tmc_print_sgt(stepperV)); - TERN_(W_SENSORLESS, tmc_print_sgt(stepperW)); + TERN_( I_SENSORLESS, tmc_print_sgt(stepperI)); + TERN_( J_SENSORLESS, tmc_print_sgt(stepperJ)); + TERN_( K_SENSORLESS, tmc_print_sgt(stepperK)); + TERN_( U_SENSORLESS, tmc_print_sgt(stepperU)); + TERN_( V_SENSORLESS, tmc_print_sgt(stepperV)); + TERN_( W_SENSORLESS, tmc_print_sgt(stepperW)); } } @@ -578,67 +573,34 @@ #if X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS say_M914(forReplay); - #if X_SENSORLESS - SERIAL_ECHOPGM_P(SP_X_STR, stepperX.homing_threshold()); - #endif - #if Y_SENSORLESS - SERIAL_ECHOPGM_P(SP_Y_STR, stepperY.homing_threshold()); - #endif - #if Z_SENSORLESS - SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ.homing_threshold()); - #endif + TERN_(X_SENSORLESS, SERIAL_ECHOPGM_P(SP_X_STR, stepperX.homing_threshold())); + TERN_(Y_SENSORLESS, SERIAL_ECHOPGM_P(SP_Y_STR, stepperY.homing_threshold())); + TERN_(Z_SENSORLESS, SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ.homing_threshold())); + TERN_(I_SENSORLESS, SERIAL_ECHOPGM_P(SP_I_STR, stepperI.homing_threshold())); + TERN_(J_SENSORLESS, SERIAL_ECHOPGM_P(SP_J_STR, stepperJ.homing_threshold())); + TERN_(K_SENSORLESS, SERIAL_ECHOPGM_P(SP_K_STR, stepperK.homing_threshold())); + TERN_(U_SENSORLESS, SERIAL_ECHOPGM_P(SP_U_STR, stepperU.homing_threshold())); + TERN_(V_SENSORLESS, SERIAL_ECHOPGM_P(SP_V_STR, stepperV.homing_threshold())); + TERN_(W_SENSORLESS, SERIAL_ECHOPGM_P(SP_W_STR, stepperW.homing_threshold())); SERIAL_EOL(); #endif #if X2_SENSORLESS || Y2_SENSORLESS || Z2_SENSORLESS say_M914(forReplay); SERIAL_ECHOPGM(" I2"); - #if X2_SENSORLESS - SERIAL_ECHOPGM_P(SP_X_STR, stepperX2.homing_threshold()); - #endif - #if Y2_SENSORLESS - SERIAL_ECHOPGM_P(SP_Y_STR, stepperY2.homing_threshold()); - #endif - #if Z2_SENSORLESS - SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ2.homing_threshold()); - #endif + TERN_(X2_SENSORLESS, SERIAL_ECHOPGM_P(SP_X_STR, stepperX2.homing_threshold())); + TERN_(Y2_SENSORLESS, SERIAL_ECHOPGM_P(SP_Y_STR, stepperY2.homing_threshold())); + TERN_(Z2_SENSORLESS, SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ2.homing_threshold())); SERIAL_EOL(); #endif - #if Z3_SENSORLESS say_M914(forReplay); SERIAL_ECHOLNPGM(" I3 Z", stepperZ3.homing_threshold()); #endif - #if Z4_SENSORLESS say_M914(forReplay); SERIAL_ECHOLNPGM(" I4 Z", stepperZ4.homing_threshold()); #endif - - #if I_SENSORLESS - say_M914(forReplay); - SERIAL_ECHOLNPGM_P(SP_I_STR, stepperI.homing_threshold()); - #endif - #if J_SENSORLESS - say_M914(forReplay); - SERIAL_ECHOLNPGM_P(SP_J_STR, stepperJ.homing_threshold()); - #endif - #if K_SENSORLESS - say_M914(forReplay); - SERIAL_ECHOLNPGM_P(SP_K_STR, stepperK.homing_threshold()); - #endif - #if U_SENSORLESS - say_M914(forReplay); - SERIAL_ECHOLNPGM_P(SP_U_STR, stepperU.homing_threshold()); - #endif - #if V_SENSORLESS - say_M914(forReplay); - SERIAL_ECHOLNPGM_P(SP_V_STR, stepperV.homing_threshold()); - #endif - #if W_SENSORLESS - say_M914(forReplay); - SERIAL_ECHOLNPGM_P(SP_W_STR, stepperW.homing_threshold()); - #endif } #endif // USE_SENSORLESS diff --git a/Marlin/src/gcode/feature/trinamic/M919.cpp b/Marlin/src/gcode/feature/trinamic/M919.cpp index 98227c7125..cabb30d7ff 100644 --- a/Marlin/src/gcode/feature/trinamic/M919.cpp +++ b/Marlin/src/gcode/feature/trinamic/M919.cpp @@ -91,9 +91,9 @@ void GcodeSuite::M919() { if (err) return; - #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) + #if ANY(X2_IS_TRINAMIC, Y2_IS_TRINAMIC, Z2_IS_TRINAMIC, Z3_IS_TRINAMIC, Z4_IS_TRINAMIC) const int8_t index = parser.byteval('I'); - #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) + #elif ANY(X_IS_TRINAMIC, Y_IS_TRINAMIC, Z_IS_TRINAMIC) constexpr int8_t index = -1; #endif @@ -107,7 +107,7 @@ void GcodeSuite::M919() { #define TMC_SET_CHOPPER_TIME(Q) stepper##Q.set_chopper_times(make_chopper_timing(CHOPPER_TIMING_##Q, toff, hend, hstrt)) - #if AXIS_IS_TMC(E0) || AXIS_IS_TMC(E1) || AXIS_IS_TMC(E2) || AXIS_IS_TMC(E3) || AXIS_IS_TMC(E4) || AXIS_IS_TMC(E5) || AXIS_IS_TMC(E6) || AXIS_IS_TMC(E7) + #if ANY(E0_IS_TRINAMIC, E1_IS_TRINAMIC, E2_IS_TRINAMIC, E3_IS_TRINAMIC, E4_IS_TRINAMIC, E5_IS_TRINAMIC, E6_IS_TRINAMIC, E7_IS_TRINAMIC) #define HAS_E_CHOPPER 1 int8_t eindex = -1; #endif @@ -121,163 +121,66 @@ void GcodeSuite::M919() { SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Axis ", C(AXIS_CHAR(i)), " has no TMC drivers.")); break; - #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) + #if X_IS_TRINAMIC || X2_IS_TRINAMIC case X_AXIS: - #if AXIS_IS_TMC(X) - if (index <= 0) TMC_SET_CHOPPER_TIME(X); - #endif - #if AXIS_IS_TMC(X2) - if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(X2); - #endif + TERN_(X_IS_TRINAMIC, if (index <= 0) TMC_SET_CHOPPER_TIME(X)); + TERN_(X2_IS_TRINAMIC, if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(X2)); break; #endif - #if AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) + #if Y_IS_TRINAMIC || Y2_IS_TRINAMIC case Y_AXIS: - #if AXIS_IS_TMC(Y) - if (index <= 0) TMC_SET_CHOPPER_TIME(Y); - #endif - #if AXIS_IS_TMC(Y2) - if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(Y2); - #endif + TERN_(Y_IS_TRINAMIC, if (index <= 0) TMC_SET_CHOPPER_TIME(Y)); + TERN_(Y2_IS_TRINAMIC, if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(Y2)); break; #endif - #if AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) + #if ANY(Z_IS_TRINAMIC, Z2_IS_TRINAMIC, Z3_IS_TRINAMIC, Z4_IS_TRINAMIC) case Z_AXIS: - #if AXIS_IS_TMC(Z) - if (index <= 0) TMC_SET_CHOPPER_TIME(Z); - #endif - #if AXIS_IS_TMC(Z2) - if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(Z2); - #endif - #if AXIS_IS_TMC(Z3) - if (index < 0 || index == 2) TMC_SET_CHOPPER_TIME(Z3); - #endif - #if AXIS_IS_TMC(Z4) - if (index < 0 || index == 3) TMC_SET_CHOPPER_TIME(Z4); - #endif + TERN_(Z_IS_TRINAMIC, if (index <= 0) TMC_SET_CHOPPER_TIME(Z)); + TERN_(Z2_IS_TRINAMIC, if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(Z2)); + TERN_(Z3_IS_TRINAMIC, if (index < 0 || index == 2) TMC_SET_CHOPPER_TIME(Z3)); + TERN_(Z4_IS_TRINAMIC, if (index < 0 || index == 3) TMC_SET_CHOPPER_TIME(Z4)); break; #endif - #if AXIS_IS_TMC(I) + #if I_IS_TRINAMIC case I_AXIS: TMC_SET_CHOPPER_TIME(I); break; #endif - #if AXIS_IS_TMC(J) + #if J_IS_TRINAMIC case J_AXIS: TMC_SET_CHOPPER_TIME(J); break; #endif - #if AXIS_IS_TMC(K) + #if K_IS_TRINAMIC case K_AXIS: TMC_SET_CHOPPER_TIME(K); break; #endif - #if AXIS_IS_TMC(U) + #if U_IS_TRINAMIC case U_AXIS: TMC_SET_CHOPPER_TIME(U); break; #endif - #if AXIS_IS_TMC(V) + #if V_IS_TRINAMIC case V_AXIS: TMC_SET_CHOPPER_TIME(V); break; #endif - #if AXIS_IS_TMC(W) + #if W_IS_TRINAMIC case W_AXIS: TMC_SET_CHOPPER_TIME(W); break; #endif #if HAS_E_CHOPPER case E_AXIS: { - #if AXIS_IS_TMC(E0) - if (eindex <= 0) TMC_SET_CHOPPER_TIME(E0); - #endif - #if AXIS_IS_TMC(E1) - if (eindex < 0 || eindex == 1) TMC_SET_CHOPPER_TIME(E1); - #endif - #if AXIS_IS_TMC(E2) - if (eindex < 0 || eindex == 2) TMC_SET_CHOPPER_TIME(E2); - #endif - #if AXIS_IS_TMC(E3) - if (eindex < 0 || eindex == 3) TMC_SET_CHOPPER_TIME(E3); - #endif - #if AXIS_IS_TMC(E4) - if (eindex < 0 || eindex == 4) TMC_SET_CHOPPER_TIME(E4); - #endif - #if AXIS_IS_TMC(E5) - if (eindex < 0 || eindex == 5) TMC_SET_CHOPPER_TIME(E5); - #endif - #if AXIS_IS_TMC(E6) - if (eindex < 0 || eindex == 6) TMC_SET_CHOPPER_TIME(E6); - #endif - #if AXIS_IS_TMC(E7) - if (eindex < 0 || eindex == 7) TMC_SET_CHOPPER_TIME(E7); - #endif + TERN_(E0_IS_TRINAMIC, if (eindex <= 0) TMC_SET_CHOPPER_TIME(E0)); + TERN_(E1_IS_TRINAMIC, if (eindex < 0 || eindex == 1) TMC_SET_CHOPPER_TIME(E1)); + TERN_(E2_IS_TRINAMIC, if (eindex < 0 || eindex == 2) TMC_SET_CHOPPER_TIME(E2)); + TERN_(E3_IS_TRINAMIC, if (eindex < 0 || eindex == 3) TMC_SET_CHOPPER_TIME(E3)); + TERN_(E4_IS_TRINAMIC, if (eindex < 0 || eindex == 4) TMC_SET_CHOPPER_TIME(E4)); + TERN_(E5_IS_TRINAMIC, if (eindex < 0 || eindex == 5) TMC_SET_CHOPPER_TIME(E5)); + TERN_(E6_IS_TRINAMIC, if (eindex < 0 || eindex == 6) TMC_SET_CHOPPER_TIME(E6)); + TERN_(E7_IS_TRINAMIC, if (eindex < 0 || eindex == 7) TMC_SET_CHOPPER_TIME(E7)); } break; #endif } } if (report) { - #define TMC_SAY_CHOPPER_TIME(Q) tmc_print_chopper_time(stepper##Q) - #if AXIS_IS_TMC(X) - TMC_SAY_CHOPPER_TIME(X); - #endif - #if AXIS_IS_TMC(X2) - TMC_SAY_CHOPPER_TIME(X2); - #endif - #if AXIS_IS_TMC(Y) - TMC_SAY_CHOPPER_TIME(Y); - #endif - #if AXIS_IS_TMC(Y2) - TMC_SAY_CHOPPER_TIME(Y2); - #endif - #if AXIS_IS_TMC(Z) - TMC_SAY_CHOPPER_TIME(Z); - #endif - #if AXIS_IS_TMC(Z2) - TMC_SAY_CHOPPER_TIME(Z2); - #endif - #if AXIS_IS_TMC(Z3) - TMC_SAY_CHOPPER_TIME(Z3); - #endif - #if AXIS_IS_TMC(Z4) - TMC_SAY_CHOPPER_TIME(Z4); - #endif - #if AXIS_IS_TMC(I) - TMC_SAY_CHOPPER_TIME(I); - #endif - #if AXIS_IS_TMC(J) - TMC_SAY_CHOPPER_TIME(J); - #endif - #if AXIS_IS_TMC(K) - TMC_SAY_CHOPPER_TIME(K); - #endif - #if AXIS_IS_TMC(U) - TMC_SAY_CHOPPER_TIME(U); - #endif - #if AXIS_IS_TMC(V) - TMC_SAY_CHOPPER_TIME(V); - #endif - #if AXIS_IS_TMC(W) - TMC_SAY_CHOPPER_TIME(W); - #endif - #if AXIS_IS_TMC(E0) - TMC_SAY_CHOPPER_TIME(E0); - #endif - #if AXIS_IS_TMC(E1) - TMC_SAY_CHOPPER_TIME(E1); - #endif - #if AXIS_IS_TMC(E2) - TMC_SAY_CHOPPER_TIME(E2); - #endif - #if AXIS_IS_TMC(E3) - TMC_SAY_CHOPPER_TIME(E3); - #endif - #if AXIS_IS_TMC(E4) - TMC_SAY_CHOPPER_TIME(E4); - #endif - #if AXIS_IS_TMC(E5) - TMC_SAY_CHOPPER_TIME(E5); - #endif - #if AXIS_IS_TMC(E6) - TMC_SAY_CHOPPER_TIME(E6); - #endif - #if AXIS_IS_TMC(E7) - TMC_SAY_CHOPPER_TIME(E7); - #endif + #define TMC_SAY_CHOPPER_TIME(Q) OPTCODE(Q##_IS_TRINAMIC, tmc_print_chopper_time(stepper##Q)) + MAP(TMC_SAY_CHOPPER_TIME, ALL_AXIS_NAMES) } } diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 69d77e875e..64326b32af 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -139,6 +139,7 @@ int8_t GcodeSuite::get_target_extruder_from_command() { * Get the target E stepper from the 'T' parameter. * If there is no 'T' parameter then dval will be substituted. * Returns -1 if the resulting E stepper index is out of range. + * Use a default of -2 for silent failure. */ int8_t GcodeSuite::get_target_e_stepper_from_command(const int8_t dval/*=-1*/) { const int8_t e = parser.intval('T', dval); diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 1f3ccba37c..7ba1c58d2a 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -159,7 +159,7 @@ * M120 - Enable endstops detection. * M121 - Disable endstops detection. * - * M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) + * M122 - Debug stepper (Requires *_DRIVER_TYPE TMC(2130|2160|5130|5160|2208|2209|2660)) * M123 - Report fan tachometers. (Requires En_FAN_TACHO_PIN) Optionally set auto-report interval. (Requires AUTO_REPORT_FANS) * M125 - Save current position and move to filament change position. (Requires PARK_HEAD_ON_PAUSE) * @@ -265,7 +265,7 @@ * M552 - Get or set IP address. Enable/disable network interface. (Requires enabled Ethernet port) * M553 - Get or set IP netmask. (Requires enabled Ethernet port) * M554 - Get or set IP gateway. (Requires enabled Ethernet port) - * M569 - Enable stealthChop on an axis. (Requires at least one _DRIVER_TYPE to be TMC2130/2160/2208/2209/5130/5160) + * M569 - Enable stealthChop on an axis. (Requires *_DRIVER_TYPE TMC(2130|2160|2208|2209|5130|5160)) * M575 - Change the serial baud rate. (Requires BAUD_RATE_GCODE) * M592 - Get or set Nonlinear Extrusion parameters. (Requires NONLINEAR_EXTRUSION) * M593 - Get or set input shaping parameters. (Requires INPUT_SHAPING_[XY]) @@ -308,17 +308,18 @@ * * M871 - Print/reset/clear first layer temperature offset values. (Requires PTC_PROBE, PTC_BED, or PTC_HOTEND) * M876 - Handle Prompt Response. (Requires HOST_PROMPT_SUPPORT and not EMERGENCY_PARSER) - * M900 - Get or Set Linear Advance K-factor. (Requires LIN_ADVANCE) - * M906 - Set or get motor current in milliamps using axis codes XYZE, etc. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) + * M900 - Set or Report Linear Advance K-factor. (Requires LIN_ADVANCE) + * M906 - Set or Report motor current in milliamps using axis codes XYZE, etc. Report values if no axis codes given. (Requires *_DRIVER_TYPE TMC(2130|2160|5130|5160|2208|2209|2660)) * M907 - Set digital trimpot motor current using axis codes. (Requires a board with digital trimpots) * M908 - Control digital trimpot directly. (Requires HAS_MOTOR_CURRENT_DAC or DIGIPOTSS_PIN) * M909 - Print digipot/DAC current value. (Requires HAS_MOTOR_CURRENT_DAC) * M910 - Commit digipot/DAC value to external EEPROM via I2C. (Requires HAS_MOTOR_CURRENT_DAC) - * M911 - Report stepper driver overtemperature pre-warn condition. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) - * M912 - Clear stepper driver overtemperature pre-warn condition flag. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) + * M911 - Report stepper driver overtemperature pre-warn condition. (Requires *_DRIVER_TYPE TMC(2130|2160|5130|5160|2208|2209|2660)) + * M912 - Clear stepper driver overtemperature pre-warn condition flag. (Requires *_DRIVER_TYPE TMC(2130|2160|5130|5160|2208|2209|2660)) * M913 - Set HYBRID_THRESHOLD speed. (Requires HYBRID_THRESHOLD) * M914 - Set StallGuard sensitivity. (Requires SENSORLESS_HOMING or SENSORLESS_PROBING) - * M919 - Get or Set motor Chopper Times (time_off, hysteresis_end, hysteresis_start) using axis codes XYZE, etc. If no parameters are given, report. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) + * M919 - Set or Report motor Chopper Times (time_off, hysteresis_end, hysteresis_start) using axis codes XYZE, etc. + * If no parameters are given, report. (Requires *_DRIVER_TYPE TMC(2130|2160|5130|5160|2208|2209|2660)) * M936 - OTA update firmware. (Requires OTA_FIRMWARE_UPDATE) * M951 - Set Magnetic Parking Extruder parameters. (Requires MAGNETIC_PARKING_EXTRUDER) * M3426 - Read MCP3426 ADC over I2C. (Requires HAS_MCP3426_ADC) diff --git a/Marlin/src/inc/Conditionals-4-adv.h b/Marlin/src/inc/Conditionals-4-adv.h index b697f22a20..eaa8aca5b0 100644 --- a/Marlin/src/inc/Conditionals-4-adv.h +++ b/Marlin/src/inc/Conditionals-4-adv.h @@ -1307,8 +1307,75 @@ #endif #endif +#if AXIS_IS_TMC(X) + #define X_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(Y) + #define Y_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(Z) + #define Z_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(I) + #define I_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(J) + #define J_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(K) + #define K_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(U) + #define U_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(V) + #define V_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(W) + #define W_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(X2) + #define X2_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(Y2) + #define Y2_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(Z2) + #define Z2_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(Z3) + #define Z3_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(Z4) + #define Z4_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(E0) + #define E0_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(E1) + #define E1_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(E2) + #define E2_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(E3) + #define E3_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(E4) + #define E4_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(E5) + #define E5_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(E6) + #define E6_IS_TRINAMIC 1 +#endif +#if AXIS_IS_TMC(E7) + #define E7_IS_TRINAMIC 1 +#endif + // Test for edge stepping on any axis -#define AXIS_HAS_DEDGE(A) (ENABLED(EDGE_STEPPING) && AXIS_IS_TMC(A)) +#define AXIS_HAS_DEDGE(A) ALL(EDGE_STEPPING, A##_IS_TRINAMIC) #if ENABLED(DIRECT_STEPPING) #ifndef STEPPER_PAGES diff --git a/Marlin/src/inc/Conditionals-5-post.h b/Marlin/src/inc/Conditionals-5-post.h index d07a5914cd..93be95c95d 100644 --- a/Marlin/src/inc/Conditionals-5-post.h +++ b/Marlin/src/inc/Conditionals-5-post.h @@ -1052,7 +1052,7 @@ // Steppers #if HAS_X_AXIS - #if PIN_EXISTS(X_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X)) + #if PIN_EXISTS(X_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, X_IS_TRINAMIC) #define HAS_X_ENABLE 1 #endif #if PIN_EXISTS(X_DIR) @@ -1065,7 +1065,7 @@ #define HAS_X_MS_PINS 1 #endif - #if PIN_EXISTS(X2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2)) + #if PIN_EXISTS(X2_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, X2_IS_TRINAMIC) #define HAS_X2_ENABLE 1 #endif #if PIN_EXISTS(X2_DIR) @@ -1084,7 +1084,7 @@ */ #if HAS_Y_AXIS - #if PIN_EXISTS(Y_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y)) + #if PIN_EXISTS(Y_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, Y_IS_TRINAMIC) #define HAS_Y_ENABLE 1 #endif #if PIN_EXISTS(Y_DIR) @@ -1098,7 +1098,7 @@ #endif #if HAS_Y2_STEPPER - #if PIN_EXISTS(Y2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2)) + #if PIN_EXISTS(Y2_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, Y2_IS_TRINAMIC) #define HAS_Y2_ENABLE 1 #endif #if PIN_EXISTS(Y2_DIR) @@ -1114,7 +1114,7 @@ #endif #if HAS_Z_AXIS - #if PIN_EXISTS(Z_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z)) + #if PIN_EXISTS(Z_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, Z_IS_TRINAMIC) #define HAS_Z_ENABLE 1 #endif #if PIN_EXISTS(Z_DIR) @@ -1129,7 +1129,7 @@ #endif #if NUM_Z_STEPPERS >= 2 - #if PIN_EXISTS(Z2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)) + #if PIN_EXISTS(Z2_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, Z2_IS_TRINAMIC) #define HAS_Z2_ENABLE 1 #endif #if PIN_EXISTS(Z2_DIR) @@ -1144,7 +1144,7 @@ #endif #if NUM_Z_STEPPERS >= 3 - #if PIN_EXISTS(Z3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3)) + #if PIN_EXISTS(Z3_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, Z3_IS_TRINAMIC) #define HAS_Z3_ENABLE 1 #endif #if PIN_EXISTS(Z3_DIR) @@ -1159,7 +1159,7 @@ #endif #if NUM_Z_STEPPERS >= 4 - #if PIN_EXISTS(Z4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4)) + #if PIN_EXISTS(Z4_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, Z4_IS_TRINAMIC) #define HAS_Z4_ENABLE 1 #endif #if PIN_EXISTS(Z4_DIR) @@ -1174,7 +1174,7 @@ #endif #if HAS_I_AXIS - #if PIN_EXISTS(I_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(I)) + #if PIN_EXISTS(I_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, I_IS_TRINAMIC) #define HAS_I_ENABLE 1 #endif #if PIN_EXISTS(I_DIR) @@ -1189,7 +1189,7 @@ #endif #if HAS_J_AXIS - #if PIN_EXISTS(J_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(J)) + #if PIN_EXISTS(J_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, J_IS_TRINAMIC) #define HAS_J_ENABLE 1 #endif #if PIN_EXISTS(J_DIR) @@ -1204,7 +1204,7 @@ #endif #if HAS_K_AXIS - #if PIN_EXISTS(K_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(K)) + #if PIN_EXISTS(K_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, K_IS_TRINAMIC) #define HAS_K_ENABLE 1 #endif #if PIN_EXISTS(K_DIR) @@ -1219,7 +1219,7 @@ #endif #if HAS_U_AXIS - #if PIN_EXISTS(U_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(U)) + #if PIN_EXISTS(U_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, U_IS_TRINAMIC) #define HAS_U_ENABLE 1 #endif #if PIN_EXISTS(U_DIR) @@ -1234,7 +1234,7 @@ #endif #if HAS_V_AXIS - #if PIN_EXISTS(V_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(V)) + #if PIN_EXISTS(V_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, V_IS_TRINAMIC) #define HAS_V_ENABLE 1 #endif #if PIN_EXISTS(V_DIR) @@ -1249,7 +1249,7 @@ #endif #if HAS_W_AXIS - #if PIN_EXISTS(W_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(W)) + #if PIN_EXISTS(W_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, W_IS_TRINAMIC) #define HAS_W_ENABLE 1 #endif #if PIN_EXISTS(W_DIR) @@ -1266,7 +1266,7 @@ // Extruder steppers and solenoids #if HAS_EXTRUDERS - #if PIN_EXISTS(E0_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)) + #if PIN_EXISTS(E0_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, E0_IS_TRINAMIC) #define HAS_E0_ENABLE 1 #endif #if PIN_EXISTS(E0_DIR) @@ -1280,7 +1280,7 @@ #endif #if E_STEPPERS > 1 || ENABLED(E_DUAL_STEPPER_DRIVERS) - #if PIN_EXISTS(E1_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)) + #if PIN_EXISTS(E1_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, E1_IS_TRINAMIC) #define HAS_E1_ENABLE 1 #endif #if PIN_EXISTS(E1_DIR) @@ -1295,7 +1295,7 @@ #endif #if E_STEPPERS > 2 - #if PIN_EXISTS(E2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)) + #if PIN_EXISTS(E2_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, E2_IS_TRINAMIC) #define HAS_E2_ENABLE 1 #endif #if PIN_EXISTS(E2_DIR) @@ -1310,7 +1310,7 @@ #endif #if E_STEPPERS > 3 - #if PIN_EXISTS(E3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)) + #if PIN_EXISTS(E3_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, E3_IS_TRINAMIC) #define HAS_E3_ENABLE 1 #endif #if PIN_EXISTS(E3_DIR) @@ -1325,7 +1325,7 @@ #endif #if E_STEPPERS > 4 - #if PIN_EXISTS(E4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)) + #if PIN_EXISTS(E4_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, E4_IS_TRINAMIC) #define HAS_E4_ENABLE 1 #endif #if PIN_EXISTS(E4_DIR) @@ -1340,7 +1340,7 @@ #endif #if E_STEPPERS > 5 - #if PIN_EXISTS(E5_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)) + #if PIN_EXISTS(E5_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, E5_IS_TRINAMIC) #define HAS_E5_ENABLE 1 #endif #if PIN_EXISTS(E5_DIR) @@ -1355,7 +1355,7 @@ #endif #if E_STEPPERS > 6 - #if PIN_EXISTS(E6_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)) + #if PIN_EXISTS(E6_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, E6_IS_TRINAMIC) #define HAS_E6_ENABLE 1 #endif #if PIN_EXISTS(E6_DIR) @@ -1370,7 +1370,7 @@ #endif #if E_STEPPERS > 7 - #if PIN_EXISTS(E7_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)) + #if PIN_EXISTS(E7_ENABLE) || ALL(SOFTWARE_DRIVER_ENABLE, E7_IS_TRINAMIC) #define HAS_E7_ENABLE 1 #endif #if PIN_EXISTS(E7_DIR) @@ -1441,7 +1441,7 @@ #undef Z4_STALL_SENSITIVITY #endif - #if AXIS_IS_TMC(X) + #if X_IS_TRINAMIC #if defined(X_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X) #define X_SENSORLESS 1 #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(X) @@ -1461,7 +1461,7 @@ #define X_SLAVE_ADDRESS 0 #endif #endif - #if AXIS_IS_TMC(X2) + #if X2_IS_TRINAMIC #if defined(X2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X2) #define X2_SENSORLESS 1 #endif @@ -1479,7 +1479,7 @@ #endif #endif - #if AXIS_IS_TMC(Y) + #if Y_IS_TRINAMIC #if defined(Y_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y) #define Y_SENSORLESS 1 #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(Y) @@ -1499,7 +1499,7 @@ #define Y_SLAVE_ADDRESS 0 #endif #endif - #if AXIS_IS_TMC(Y2) + #if Y2_IS_TRINAMIC #if defined(Y2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y2) #define Y2_SENSORLESS 1 #endif @@ -1517,7 +1517,7 @@ #endif #endif - #if AXIS_IS_TMC(Z) + #if Z_IS_TRINAMIC #if defined(Z_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z) #define Z_SENSORLESS 1 #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(Z) @@ -1537,7 +1537,7 @@ #define Z_SLAVE_ADDRESS 0 #endif #endif - #if NUM_Z_STEPPERS >= 2 && AXIS_IS_TMC(Z2) + #if NUM_Z_STEPPERS >= 2 && Z2_IS_TRINAMIC #if defined(Z2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z2) #define Z2_SENSORLESS 1 #endif @@ -1554,7 +1554,7 @@ #define Z2_SLAVE_ADDRESS 0 #endif #endif - #if NUM_Z_STEPPERS >= 3 && AXIS_IS_TMC(Z3) + #if NUM_Z_STEPPERS >= 3 && Z3_IS_TRINAMIC #if defined(Z3_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z3) #define Z3_SENSORLESS 1 #endif @@ -1571,7 +1571,7 @@ #define Z3_SLAVE_ADDRESS 0 #endif #endif - #if NUM_Z_STEPPERS >= 4 && AXIS_IS_TMC(Z4) + #if NUM_Z_STEPPERS >= 4 && Z4_IS_TRINAMIC #if defined(Z4_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z4) #define Z4_SENSORLESS 1 #endif @@ -1589,7 +1589,7 @@ #endif #endif - #if AXIS_IS_TMC(I) + #if I_IS_TRINAMIC #if defined(I_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(I) #define I_SENSORLESS 1 #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(I) @@ -1610,7 +1610,7 @@ #endif #endif - #if AXIS_IS_TMC(J) + #if J_IS_TRINAMIC #if defined(J_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(J) #define J_SENSORLESS 1 #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(J) @@ -1631,7 +1631,7 @@ #endif #endif - #if AXIS_IS_TMC(K) + #if K_IS_TRINAMIC #if defined(K_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(K) #define K_SENSORLESS 1 #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(K) @@ -1652,7 +1652,7 @@ #endif #endif - #if AXIS_IS_TMC(U) + #if U_IS_TRINAMIC #if defined(U_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(U) #define U_SENSORLESS 1 #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(U) @@ -1673,7 +1673,7 @@ #endif #endif - #if AXIS_IS_TMC(V) + #if V_IS_TRINAMIC #if defined(V_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(V) #define V_SENSORLESS 1 #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(V) @@ -1694,7 +1694,7 @@ #endif #endif - #if AXIS_IS_TMC(W) + #if W_IS_TRINAMIC #if defined(W_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(W) #define W_SENSORLESS 1 #if ENABLED(SPI_ENDSTOPS) && AXIS_HAS_SPI(W) @@ -1715,7 +1715,7 @@ #endif #endif - #if AXIS_IS_TMC(E0) + #if E0_IS_TRINAMIC #if AXIS_HAS_STEALTHCHOP(E0) #define E0_HAS_STEALTHCHOP 1 #endif @@ -1729,7 +1729,7 @@ #define E0_SLAVE_ADDRESS 0 #endif #endif - #if AXIS_IS_TMC(E1) + #if E1_IS_TRINAMIC #if AXIS_HAS_STEALTHCHOP(E1) #define E1_HAS_STEALTHCHOP 1 #endif @@ -1743,7 +1743,7 @@ #define E1_SLAVE_ADDRESS 0 #endif #endif - #if AXIS_IS_TMC(E2) + #if E2_IS_TRINAMIC #if AXIS_HAS_STEALTHCHOP(E2) #define E2_HAS_STEALTHCHOP 1 #endif @@ -1757,7 +1757,7 @@ #define E2_SLAVE_ADDRESS 0 #endif #endif - #if AXIS_IS_TMC(E3) + #if E3_IS_TRINAMIC #if AXIS_HAS_STEALTHCHOP(E3) #define E3_HAS_STEALTHCHOP 1 #endif @@ -1771,7 +1771,7 @@ #define E3_SLAVE_ADDRESS 0 #endif #endif - #if AXIS_IS_TMC(E4) + #if E4_IS_TRINAMIC #if AXIS_HAS_STEALTHCHOP(E4) #define E4_HAS_STEALTHCHOP 1 #endif @@ -1785,7 +1785,7 @@ #define E4_SLAVE_ADDRESS 0 #endif #endif - #if AXIS_IS_TMC(E5) + #if E5_IS_TRINAMIC #if AXIS_HAS_STEALTHCHOP(E5) #define E5_HAS_STEALTHCHOP 1 #endif @@ -1799,7 +1799,7 @@ #define E5_SLAVE_ADDRESS 0 #endif #endif - #if AXIS_IS_TMC(E6) + #if E6_IS_TRINAMIC #if AXIS_HAS_STEALTHCHOP(E6) #define E6_HAS_STEALTHCHOP 1 #endif @@ -1813,7 +1813,7 @@ #define E6_SLAVE_ADDRESS 0 #endif #endif - #if AXIS_IS_TMC(E7) + #if E7_IS_TRINAMIC #if AXIS_HAS_STEALTHCHOP(E7) #define E7_HAS_STEALTHCHOP 1 #endif diff --git a/Marlin/src/inc/Conditionals-6-type.h b/Marlin/src/inc/Conditionals-6-type.h index e14c6d7ce5..bd8e3b78b4 100644 --- a/Marlin/src/inc/Conditionals-6-type.h +++ b/Marlin/src/inc/Conditionals-6-type.h @@ -38,10 +38,53 @@ #endif // If an axis's Homing Current differs from standard current... -#define HAS_CURRENT_HOME(N) (N##_CURRENT_HOME > 0 && N##_CURRENT_HOME != N##_CURRENT) +#define HAS_HOME_CURRENT(N) (N##_CURRENT_HOME > 0 && N##_CURRENT_HOME != N##_CURRENT) +#if HAS_HOME_CURRENT(X) + #define X_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(Y) + #define Y_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(Z) + #define Z_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(I) + #define I_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(J) + #define J_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(K) + #define K_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(U) + #define U_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(V) + #define V_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(W) + #define W_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(X2) + #define X2_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(Y2) + #define Y2_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(Z2) + #define Z2_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(Z3) + #define Z3_HAS_HOME_CURRENT 1 +#endif +#if HAS_HOME_CURRENT(Z4) + #define Z4_HAS_HOME_CURRENT 1 +#endif +#undef HAS_HOME_CURRENT // Does any axis have homing current? -#define _OR_HAS_CURR_HOME(N) HAS_CURRENT_HOME(N) || +#define _OR_HAS_CURR_HOME(N) N##_HAS_HOME_CURRENT || #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 diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 0029980ada..3c4cd44561 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1805,8 +1805,8 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i #undef _BAD_HOME_CURRENT #if ENABLED(PROBING_USE_CURRENT_HOME) - #if (defined(Z_CURRENT_HOME) && !HAS_CURRENT_HOME(Z)) || (defined(Z2_CURRENT_HOME) && !HAS_CURRENT_HOME(Z2)) \ - || (defined(Z3_CURRENT_HOME) && !HAS_CURRENT_HOME(Z3)) || (defined(Z4_CURRENT_HOME) && !HAS_CURRENT_HOME(Z4)) + #if (defined(Z_CURRENT_HOME) && !Z_HAS_HOME_CURRENT) || (defined(Z2_CURRENT_HOME) && !Z2_HAS_HOME_CURRENT) \ + || (defined(Z3_CURRENT_HOME) && !Z3_HAS_HOME_CURRENT) || (defined(Z4_CURRENT_HOME) && !Z4_HAS_HOME_CURRENT) #error "PROBING_USE_CURRENT_HOME requires a Z_CURRENT_HOME value that differs from Z_CURRENT." #endif #endif @@ -2452,28 +2452,28 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i #endif #endif -#if E_STEPPERS > 0 && !(PINS_EXIST(E0_STEP, E0_DIR) && HAS_E0_ENABLE) +#if E_STEPPERS > 0 && !ALL(HAS_E0_DIR, HAS_E0_STEP, HAS_E0_ENABLE) #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." #endif -#if E_STEPPERS > 1 && !(PINS_EXIST(E1_STEP, E1_DIR) && HAS_E1_ENABLE) +#if E_STEPPERS > 1 && !ALL(HAS_E1_DIR, HAS_E1_STEP, HAS_E1_ENABLE) #error "E1_STEP_PIN, E1_DIR_PIN, or E1_ENABLE_PIN not defined for this board." #endif -#if E_STEPPERS > 2 && !(PINS_EXIST(E2_STEP, E2_DIR) && HAS_E2_ENABLE) +#if E_STEPPERS > 2 && !ALL(HAS_E2_DIR, HAS_E2_STEP, HAS_E2_ENABLE) #error "E2_STEP_PIN, E2_DIR_PIN, or E2_ENABLE_PIN not defined for this board." #endif -#if E_STEPPERS > 3 && !(PINS_EXIST(E3_STEP, E3_DIR) && HAS_E3_ENABLE) +#if E_STEPPERS > 3 && !ALL(HAS_E3_DIR, HAS_E3_STEP, HAS_E3_ENABLE) #error "E3_STEP_PIN, E3_DIR_PIN, or E3_ENABLE_PIN not defined for this board." #endif -#if E_STEPPERS > 4 && !(PINS_EXIST(E4_STEP, E4_DIR) && HAS_E4_ENABLE) +#if E_STEPPERS > 4 && !ALL(HAS_E4_DIR, HAS_E4_STEP, HAS_E4_ENABLE) #error "E4_STEP_PIN, E4_DIR_PIN, or E4_ENABLE_PIN not defined for this board." #endif -#if E_STEPPERS > 5 && !(PINS_EXIST(E5_STEP, E5_DIR) && HAS_E5_ENABLE) +#if E_STEPPERS > 5 && !ALL(HAS_E5_DIR, HAS_E5_STEP, HAS_E5_ENABLE) #error "E5_STEP_PIN, E5_DIR_PIN, or E5_ENABLE_PIN not defined for this board." #endif -#if E_STEPPERS > 6 && !(PINS_EXIST(E6_STEP, E6_DIR) && HAS_E6_ENABLE) +#if E_STEPPERS > 6 && !ALL(HAS_E6_DIR, HAS_E6_STEP, HAS_E6_ENABLE) #error "E6_STEP_PIN, E6_DIR_PIN, or E6_ENABLE_PIN not defined for this board." #endif -#if E_STEPPERS > 7 && !(PINS_EXIST(E7_STEP, E7_DIR) && HAS_E7_ENABLE) +#if E_STEPPERS > 7 && !ALL(HAS_E7_DIR, HAS_E7_STEP, HAS_E7_ENABLE) #error "E7_STEP_PIN, E7_DIR_PIN, or E7_ENABLE_PIN not defined for this board." #endif @@ -3230,7 +3230,7 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i #undef INVALID_TMC_ADDRESS #define _TMC_MICROSTEP_IS_VALID(MS) (MS == 0 || MS == 2 || MS == 4 || MS == 8 || MS == 16 || MS == 32 || MS == 64 || MS == 128 || MS == 256) -#define TMC_MICROSTEP_IS_VALID(M) (!AXIS_IS_TMC(M) || _TMC_MICROSTEP_IS_VALID(M##_MICROSTEPS)) +#define TMC_MICROSTEP_IS_VALID(M) (!M##_IS_TRINAMIC || _TMC_MICROSTEP_IS_VALID(M##_MICROSTEPS)) #define INVALID_TMC_MS(ST) static_assert(0, "Invalid " STRINGIFY(ST) "_MICROSTEPS. Valid values are 0, 2, 4, 8, 16, 32, 64, 128, and 256.") #if !TMC_MICROSTEP_IS_VALID(X) diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index df2279a08b..7c107220af 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -742,24 +742,24 @@ #endif #if USE_SENSORLESS && DISABLED(NO_HOMING_CURRENT_WARNING) - #if ENABLED(X_SENSORLESS) && defined(X_CURRENT_HOME) && !HAS_CURRENT_HOME(X) - #warning "It's recommended to set X_CURRENT_HOME lower than X_CURRENT with SENSORLESS_HOMING. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" - #elif ENABLED(X2_SENSORLESS) && defined(X2_CURRENT_HOME) && !HAS_CURRENT_HOME(X2) - #warning "It's recommended to set X2_CURRENT_HOME lower than X2_CURRENT with SENSORLESS_HOMING. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" + #if ENABLED(X_SENSORLESS) && defined(X_CURRENT_HOME) && !X_HAS_HOME_CURRENT + #warning "With SENSORLESS_HOMING it is recommended to set X_CURRENT_HOME less than X_CURRENT. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" + #elif ENABLED(X2_SENSORLESS) && defined(X2_CURRENT_HOME) && !X2_HAS_HOME_CURRENT + #warning "With SENSORLESS_HOMING it is recommended to set X2_CURRENT_HOME less than X2_CURRENT. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" #endif - #if ENABLED(Y_SENSORLESS) && defined(Y_CURRENT_HOME) && !HAS_CURRENT_HOME(Y) - #warning "It's recommended to set Y_CURRENT_HOME lower than Y_CURRENT with SENSORLESS_HOMING. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" - #elif ENABLED(Y2_SENSORLESS) && defined(Y2_CURRENT_HOME) && !HAS_CURRENT_HOME(Y2) - #warning "It's recommended to set Y2_CURRENT_HOME lower than Y2_CURRENT with SENSORLESS_HOMING. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" + #if ENABLED(Y_SENSORLESS) && defined(Y_CURRENT_HOME) && !Y_HAS_HOME_CURRENT + #warning "With SENSORLESS_HOMING it is recommended to set Y_CURRENT_HOME less than Y_CURRENT. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" + #elif ENABLED(Y2_SENSORLESS) && defined(Y2_CURRENT_HOME) && !Y2_HAS_HOME_CURRENT + #warning "With SENSORLESS_HOMING it is recommended to set Y2_CURRENT_HOME less than Y2_CURRENT. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" #endif - #if ENABLED(Z_SENSORLESS) && defined(Z_CURRENT_HOME) && !HAS_CURRENT_HOME(Z) - #warning "It's recommended to set Z_CURRENT_HOME lower than Z_CURRENT with SENSORLESS_HOMING. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" - #elif ENABLED(Z2_SENSORLESS) && defined(Z2_CURRENT_HOME) && !HAS_CURRENT_HOME(Z2) - #warning "It's recommended to set Z2_CURRENT_HOME lower than Z2_CURRENT with SENSORLESS_HOMING. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" - #elif ENABLED(Z3_SENSORLESS) && defined(Z3_CURRENT_HOME) && !HAS_CURRENT_HOME(Z3) - #warning "It's recommended to set Z3_CURRENT_HOME lower than Z3_CURRENT with SENSORLESS_HOMING. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" - #elif ENABLED(Z4_SENSORLESS) && defined(Z4_CURRENT_HOME) && !HAS_CURRENT_HOME(Z4) - #warning "It's recommended to set Z4_CURRENT_HOME lower than Z4_CURRENT with SENSORLESS_HOMING. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" + #if ENABLED(Z_SENSORLESS) && defined(Z_CURRENT_HOME) && !Z_HAS_HOME_CURRENT + #warning "With SENSORLESS_HOMING it is recommended to set Z_CURRENT_HOME less than Z_CURRENT. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" + #elif ENABLED(Z2_SENSORLESS) && defined(Z2_CURRENT_HOME) && !Z2_HAS_HOME_CURRENT + #warning "With SENSORLESS_HOMING it is recommended to set Z2_CURRENT_HOME less than Z2_CURRENT. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" + #elif ENABLED(Z3_SENSORLESS) && defined(Z3_CURRENT_HOME) && !Z3_HAS_HOME_CURRENT + #warning "With SENSORLESS_HOMING it is recommended to set Z3_CURRENT_HOME less than Z3_CURRENT. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" + #elif ENABLED(Z4_SENSORLESS) && defined(Z4_CURRENT_HOME) && !Z4_HAS_HOME_CURRENT + #warning "With SENSORLESS_HOMING it is recommended to set Z4_CURRENT_HOME less than Z4_CURRENT. (Define NO_HOMING_CURRENT_WARNING to suppress this warning.)" #endif #endif diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 09100e5029..b9c637d722 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -3068,7 +3068,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenu(ID_Advanced, ADVANCED_TMC); break; - #if AXIS_IS_TMC(X) + #if X_IS_TRINAMIC case TMC_STEPPER_CURRENT_X: static float stepper_current_x; @@ -3084,7 +3084,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra break; #endif - #if AXIS_IS_TMC(Y) + #if Y_IS_TRINAMIC case TMC_STEPPER_CURRENT_Y: static float stepper_current_y; if (draw) { @@ -3098,7 +3098,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra break; #endif - #if AXIS_IS_TMC(Z) + #if Z_IS_TRINAMIC case TMC_STEPPER_CURRENT_Z: static float stepper_current_z; if (draw) { @@ -3112,7 +3112,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra break; #endif - #if AXIS_IS_TMC(E0) + #if E0_IS_TRINAMIC case TMC_STEPPER_CURRENT_E: static float stepper_current_e; if (draw) { diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index a775d2ae27..7428a4b254 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -3607,49 +3607,28 @@ void drawTuneMenu() { #endif #if HAS_TRINAMIC_CONFIG - #if AXIS_IS_TMC(X) + #if X_IS_TRINAMIC void setXTMCCurrent() { setPIntOnClick(MIN_TMC_CURRENT, MAX_TMC_CURRENT, []{ stepperX.refresh_stepper_current(); }); } #endif - #if AXIS_IS_TMC(Y) + #if Y_IS_TRINAMIC void setYTMCCurrent() { setPIntOnClick(MIN_TMC_CURRENT, MAX_TMC_CURRENT, []{ stepperY.refresh_stepper_current(); }); } #endif - #if AXIS_IS_TMC(Z) + #if Z_IS_TRINAMIC void setZTMCCurrent() { setPIntOnClick(MIN_TMC_CURRENT, MAX_TMC_CURRENT, []{ stepperZ.refresh_stepper_current(); }); } #endif - #if AXIS_IS_TMC(E0) + #if E0_IS_TRINAMIC void setETMCCurrent() { setPIntOnClick(MIN_TMC_CURRENT, MAX_TMC_CURRENT, []{ stepperE0.refresh_stepper_current(); }); } #endif void drawTrinamicConfigMenu() { - constexpr uint8_t items = (1 - #if AXIS_IS_TMC(X) - + 1 - #endif - #if AXIS_IS_TMC(Y) - + 1 - #endif - #if AXIS_IS_TMC(Z) - + 1 - #endif - #if AXIS_IS_TMC(E0) - + 1 - #endif - ); + constexpr uint8_t items = 1 + COUNT_ENABLED(X_IS_TRINAMIC, Y_IS_TRINAMIC, Z_IS_TRINAMIC, E0_IS_TRINAMIC); checkkey = ID_Menu; if (SET_MENU(trinamicConfigMenu, MSG_TMC_DRIVERS, items)) { BACK_ITEM(drawAdvancedSettingsMenu); - #if AXIS_IS_TMC(X) - EDIT_ITEM(ICON_TMCXSet, MSG_TMC_ACURRENT, onDrawPIntMenu, setXTMCCurrent, &stepperX.val_mA); - #endif - #if AXIS_IS_TMC(Y) - EDIT_ITEM(ICON_TMCYSet, MSG_TMC_BCURRENT, onDrawPIntMenu, setYTMCCurrent, &stepperY.val_mA); - #endif - #if AXIS_IS_TMC(Z) - EDIT_ITEM(ICON_TMCZSet, MSG_TMC_CCURRENT, onDrawPIntMenu, setZTMCCurrent, &stepperZ.val_mA); - #endif - #if AXIS_IS_TMC(E0) - EDIT_ITEM(ICON_TMCESet, MSG_TMC_ECURRENT, onDrawPIntMenu, setETMCCurrent, &stepperE0.val_mA); - #endif + TERN_(X_IS_TRINAMIC, EDIT_ITEM(ICON_TMCXSet, MSG_TMC_ACURRENT, onDrawPIntMenu, setXTMCCurrent, &stepperX.val_mA)); + TERN_(Y_IS_TRINAMIC, EDIT_ITEM(ICON_TMCYSet, MSG_TMC_BCURRENT, onDrawPIntMenu, setYTMCCurrent, &stepperY.val_mA)); + TERN_(Z_IS_TRINAMIC, EDIT_ITEM(ICON_TMCZSet, MSG_TMC_CCURRENT, onDrawPIntMenu, setZTMCCurrent, &stepperZ.val_mA)); + TERN_(E0_IS_TRINAMIC, EDIT_ITEM(ICON_TMCESet, MSG_TMC_ECURRENT, onDrawPIntMenu, setETMCCurrent, &stepperE0.val_mA)); } updateMenu(trinamicConfigMenu); } diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp index 4182c3f2ca..08eff9d41e 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp @@ -707,28 +707,28 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif #if HAS_TRINAMIC_CONFIG // TMC Current Setting - #if AXIS_IS_TMC(X) + #if X_IS_TRINAMIC VPHELPER(VP_TMC_X_Current, &stepperX.val_mA, screen.tmcChangeConfig, screen.sendWordValueToDisplay), #endif - #if AXIS_IS_TMC(Y) + #if Y_IS_TRINAMIC VPHELPER(VP_TMC_Y_Current, &stepperY.val_mA, screen.tmcChangeConfig, screen.sendWordValueToDisplay), #endif - #if AXIS_IS_TMC(Z) + #if Z_IS_TRINAMIC VPHELPER(VP_TMC_Z_Current, &stepperZ.val_mA, screen.tmcChangeConfig, screen.sendWordValueToDisplay), #endif - #if AXIS_IS_TMC(E0) + #if E0_IS_TRINAMIC VPHELPER(VP_TMC_E0_Current, &stepperE0.val_mA, screen.tmcChangeConfig, screen.sendWordValueToDisplay), #endif - #if AXIS_IS_TMC(E1) + #if E1_IS_TRINAMIC VPHELPER(VP_TMC_E1_Current, &stepperE1.val_mA, screen.tmcChangeConfig, screen.sendWordValueToDisplay), #endif - #if AXIS_IS_TMC(X2) + #if X2_IS_TRINAMIC VPHELPER(VP_TMC_X1_Current, &stepperX2.val_mA, screen.tmcChangeConfig, screen.sendWordValueToDisplay), #endif - #if AXIS_IS_TMC(Y2) + #if Y2_IS_TRINAMIC VPHELPER(VP_TMC_Y1_Current, &stepperY2.val_mA, screen.tmcChangeConfig, screen.sendWordValueToDisplay), #endif - #if AXIS_IS_TMC(Z2) + #if Z2_IS_TRINAMIC VPHELPER(VP_TMC_Z1_Current, &stepperZ2.val_mA, screen.tmcChangeConfig, screen.sendWordValueToDisplay), #endif #endif diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 1999518607..1761451da1 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -673,49 +673,49 @@ void DGUSScreenHandlerMKS::tmcChangeConfig(DGUS_VP_Variable &var, void *val_ptr) #endif break; case VP_TMC_X_Current: - #if AXIS_IS_TMC(X) + #if X_IS_TRINAMIC stepperX.rms_current(tmc_val); settings.save(); #endif break; case VP_TMC_X1_Current: - #if AXIS_IS_TMC(X2) + #if X2_IS_TRINAMIC stepperX2.rms_current(tmc_val); settings.save(); #endif break; case VP_TMC_Y_Current: - #if AXIS_IS_TMC(Y) + #if Y_IS_TRINAMIC stepperY.rms_current(tmc_val); settings.save(); #endif break; case VP_TMC_Y1_Current: - #if AXIS_IS_TMC(X2) + #if X2_IS_TRINAMIC stepperY2.rms_current(tmc_val); settings.save(); #endif break; case VP_TMC_Z_Current: - #if AXIS_IS_TMC(Z) + #if Z_IS_TRINAMIC stepperZ.rms_current(tmc_val); settings.save(); #endif break; case VP_TMC_Z1_Current: - #if AXIS_IS_TMC(Z2) + #if Z2_IS_TRINAMIC stepperZ2.rms_current(tmc_val); settings.save(); #endif break; case VP_TMC_E0_Current: - #if AXIS_IS_TMC(E0) + #if E0_IS_TRINAMIC stepperE0.rms_current(tmc_val); settings.save(); #endif break; case VP_TMC_E1_Current: - #if AXIS_IS_TMC(E1) + #if E1_IS_TRINAMIC stepperE1.rms_current(tmc_val); settings.save(); #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/stepper_current_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/stepper_current_screen.cpp index ddd273aa47..3511ce3719 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/stepper_current_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/stepper_current_screen.cpp @@ -33,86 +33,60 @@ void StepperCurrentScreen::onRedraw(draw_mode_t what) { widgets_t w(what); w.precision(0); w.units(GET_TEXT_F(MSG_UNITS_MILLIAMP)); - w.heading( GET_TEXT_F(MSG_TMC_CURRENT)); - #if AXIS_IS_TMC(X) - w.color(x_axis) .adjuster( 2, GET_TEXT_F(MSG_AXIS_X), getAxisCurrent_mA(X) ); - #endif - #if AXIS_IS_TMC(X2) - w.color(x_axis) .adjuster( 4, GET_TEXT_F(MSG_AXIS_X2), getAxisCurrent_mA(X2) ); - #endif - #if AXIS_IS_TMC(Y) - w.color(y_axis) .adjuster( 6, GET_TEXT_F(MSG_AXIS_Y), getAxisCurrent_mA(Y) ); - #endif - #if AXIS_IS_TMC(Y2) - w.color(x_axis) .adjuster( 8, GET_TEXT_F(MSG_AXIS_Y2), getAxisCurrent_mA(Y2) ); - #endif - #if AXIS_IS_TMC(Z) - w.color(z_axis) .adjuster(10, GET_TEXT_F(MSG_AXIS_Z), getAxisCurrent_mA(Z) ); - #endif - #if AXIS_IS_TMC(Z2) - w.color(z_axis) .adjuster(12, GET_TEXT_F(MSG_AXIS_Z2), getAxisCurrent_mA(Z2) ); - #endif - #if AXIS_IS_TMC(E0) - w.color(e_axis) .adjuster(14, GET_TEXT_F( - #if EXTRUDERS == 1 - MSG_AXIS_E - #else - MSG_AXIS_E1 - #endif - ), getAxisCurrent_mA(E0) ); - #endif - #if AXIS_IS_TMC(E1) - w.color(e_axis).adjuster(16, GET_TEXT_F(MSG_AXIS_E2), getAxisCurrent_mA(E1) ); - #endif - #if AXIS_IS_TMC(E2) - w.color(e_axis).adjuster(18, GET_TEXT_F(MSG_AXIS_E3), getAxisCurrent_mA(E2) ); - #endif - #if AXIS_IS_TMC(E3) - w.color(e_axis).adjuster(20, GET_TEXT_F(MSG_AXIS_E4), getAxisCurrent_mA(E3) ); - #endif + w.heading(GET_TEXT_F(MSG_TMC_CURRENT)); + TERN_(X_IS_TRINAMIC, w.color(x_axis) .adjuster( 2, GET_TEXT_F(MSG_AXIS_X), getAxisCurrent_mA(X) ) ); + TERN_(X2_IS_TRINAMIC, w.color(x_axis) .adjuster( 4, GET_TEXT_F(MSG_AXIS_X2), getAxisCurrent_mA(X2)) ); + TERN_(Y_IS_TRINAMIC, w.color(y_axis) .adjuster( 6, GET_TEXT_F(MSG_AXIS_Y), getAxisCurrent_mA(Y) ) ); + TERN_(Y2_IS_TRINAMIC, w.color(x_axis) .adjuster( 8, GET_TEXT_F(MSG_AXIS_Y2), getAxisCurrent_mA(Y2)) ); + TERN_(Z_IS_TRINAMIC, w.color(z_axis) .adjuster(10, GET_TEXT_F(MSG_AXIS_Z), getAxisCurrent_mA(Z) ) ); + TERN_(Z2_IS_TRINAMIC, w.color(z_axis) .adjuster(12, GET_TEXT_F(MSG_AXIS_Z2), getAxisCurrent_mA(Z2)) ); + TERN_(E0_IS_TRINAMIC, w.color(e_axis) .adjuster(14, GET_TEXT_F(TERN(HAS_MULTI_EXTRUDER, MSG_AXIS_E1, MSG_AXIS_E)), getAxisCurrent_mA(E0)) ); + TERN_(E1_IS_TRINAMIC, w.color(e_axis) .adjuster(16, GET_TEXT_F(MSG_AXIS_E2), getAxisCurrent_mA(E1)) ); + TERN_(E2_IS_TRINAMIC, w.color(e_axis) .adjuster(18, GET_TEXT_F(MSG_AXIS_E3), getAxisCurrent_mA(E2)) ); + TERN_(E3_IS_TRINAMIC, w.color(e_axis) .adjuster(20, GET_TEXT_F(MSG_AXIS_E4), getAxisCurrent_mA(E3)) ); w.increments(); } bool StepperCurrentScreen::onTouchHeld(uint8_t tag) { const float increment = getIncrement(); switch (tag) { - #if AXIS_IS_TMC(X) + #if X_IS_TRINAMIC case 2: UI_DECREMENT(AxisCurrent_mA, X ); break; case 3: UI_INCREMENT(AxisCurrent_mA, X ); break; #endif - #if AXIS_IS_TMC(X2) + #if X2_IS_TRINAMIC case 4: UI_DECREMENT(AxisCurrent_mA, X2 ); break; case 5: UI_INCREMENT(AxisCurrent_mA, X2 ); break; #endif - #if AXIS_IS_TMC(Y) + #if Y_IS_TRINAMIC case 6: UI_DECREMENT(AxisCurrent_mA, Y ); break; case 7: UI_INCREMENT(AxisCurrent_mA, Y ); break; #endif - #if AXIS_IS_TMC(Y2) + #if Y2_IS_TRINAMIC case 8: UI_DECREMENT(AxisCurrent_mA, Y2 ); break; case 9: UI_INCREMENT(AxisCurrent_mA, Y2 ); break; #endif - #if AXIS_IS_TMC(Z) + #if Z_IS_TRINAMIC case 10: UI_DECREMENT(AxisCurrent_mA, Z ); break; case 11: UI_INCREMENT(AxisCurrent_mA, Z ); break; #endif - #if AXIS_IS_TMC(Z2) + #if Z2_IS_TRINAMIC case 12: UI_DECREMENT(AxisCurrent_mA, Z2 ); break; case 13: UI_INCREMENT(AxisCurrent_mA, Z2 ); break; #endif - #if AXIS_IS_TMC(E0) + #if E0_IS_TRINAMIC case 14: UI_DECREMENT(AxisCurrent_mA, E0); break; case 15: UI_INCREMENT(AxisCurrent_mA, E0); break; #endif - #if AXIS_IS_TMC(E1) + #if E1_IS_TRINAMIC case 16: UI_DECREMENT(AxisCurrent_mA, E1); break; case 17: UI_INCREMENT(AxisCurrent_mA, E1); break; #endif - #if AXIS_IS_TMC(E2) + #if E2_IS_TRINAMIC case 18: UI_DECREMENT(AxisCurrent_mA, E2); break; case 19: UI_INCREMENT(AxisCurrent_mA, E2); break; #endif - #if AXIS_IS_TMC(E3) + #if E3_IS_TRINAMIC case 20: UI_DECREMENT(AxisCurrent_mA, E3); break; case 21: UI_INCREMENT(AxisCurrent_mA, E3); break; #endif diff --git a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp index 400b294701..c44cabd10a 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp @@ -102,13 +102,13 @@ static void disp_key_value() { #endif #if HAS_X_AXIS - case XMaxFeedRate: dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, public_buf_m); break; + case XMaxFeedRate: dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, public_buf_m); break; #endif #if HAS_Y_AXIS - case YMaxFeedRate: dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, public_buf_m); break; + case YMaxFeedRate: dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, public_buf_m); break; #endif #if HAS_Z_AXIS - case ZMaxFeedRate: dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, public_buf_m); break; + case ZMaxFeedRate: dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, public_buf_m); break; #endif #if HAS_EXTRUDERS case E0MaxFeedRate: dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS], 1, 1, public_buf_m); break; @@ -134,13 +134,13 @@ static void disp_key_value() { #if ENABLED(EDITABLE_STEPS_PER_UNIT) #if HAS_X_AXIS - case Xstep: dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, public_buf_m); break; + case Xstep: dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, public_buf_m); break; #endif #if HAS_Y_AXIS - case Ystep: dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, public_buf_m); break; + case Ystep: dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, public_buf_m); break; #endif #if HAS_Z_AXIS - case Zstep: dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, public_buf_m); break; + case Zstep: dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, public_buf_m); break; #endif #if HAS_EXTRUDERS case E0step: dtostrf(planner.settings.axis_steps_per_mm[E_AXIS], 1, 1, public_buf_m); break; @@ -150,21 +150,11 @@ static void disp_key_value() { #endif #endif - #if AXIS_IS_TMC(X) - case Xcurrent: dtostrf(stepperX.getMilliamps(), 1, 1, public_buf_m); break; - #endif - #if AXIS_IS_TMC(Y) - case Ycurrent: dtostrf(stepperY.getMilliamps(), 1, 1, public_buf_m); break; - #endif - #if AXIS_IS_TMC(Z) - case Zcurrent: dtostrf(stepperZ.getMilliamps(), 1, 1, public_buf_m); break; - #endif - #if AXIS_IS_TMC(E0) - case E0current: dtostrf(stepperE0.getMilliamps(), 1, 1, public_buf_m); break; - #endif - #if AXIS_IS_TMC(E1) - case E1current: dtostrf(stepperE1.getMilliamps(), 1, 1, public_buf_m); break; - #endif + case Xcurrent: TERN_(X_IS_TRINAMIC, dtostrf(stepperX.getMilliamps(), 1, 1, public_buf_m)); break; + case Ycurrent: TERN_(Y_IS_TRINAMIC, dtostrf(stepperY.getMilliamps(), 1, 1, public_buf_m)); break; + case Zcurrent: TERN_(Z_IS_TRINAMIC, dtostrf(stepperZ.getMilliamps(), 1, 1, public_buf_m)); break; + case E0current: TERN_(E0_IS_TRINAMIC, dtostrf(stepperE0.getMilliamps(), 1, 1, public_buf_m)); break; + case E1current: TERN_(E1_IS_TRINAMIC, dtostrf(stepperE1.getMilliamps(), 1, 1, public_buf_m)); break; case pause_pos_x: dtostrf(gCfgItems.pausePosX, 1, 1, public_buf_m); break; case pause_pos_y: dtostrf(gCfgItems.pausePosY, 1, 1, public_buf_m); break; @@ -275,21 +265,11 @@ static void set_value_confirm() { case E1step: planner.settings.axis_steps_per_mm[E_AXIS_N(1)] = atof(key_value); planner.refresh_positioning(); break; #endif - #if AXIS_IS_TMC(X) - case Xcurrent: stepperX.rms_current(atoi(key_value)); break; - #endif - #if AXIS_IS_TMC(Y) - case Ycurrent: stepperY.rms_current(atoi(key_value)); break; - #endif - #if AXIS_IS_TMC(Z) - case Zcurrent: stepperZ.rms_current(atoi(key_value)); break; - #endif - #if AXIS_IS_TMC(E0) - case E0current: stepperE0.rms_current(atoi(key_value)); break; - #endif - #if AXIS_IS_TMC(E1) - case E1current: stepperE1.rms_current(atoi(key_value)); break; - #endif + case Xcurrent: TERN_(X_IS_TRINAMIC, stepperX.rms_current(atoi(key_value))); break; + case Ycurrent: TERN_(Y_IS_TRINAMIC, stepperY.rms_current(atoi(key_value))); break; + case Zcurrent: TERN_(Z_IS_TRINAMIC, stepperZ.rms_current(atoi(key_value))); break; + case E0current: TERN_(E0_IS_TRINAMIC, stepperE0.rms_current(atoi(key_value))); break; + case E1current: TERN_(E1_IS_TRINAMIC, stepperE1.rms_current(atoi(key_value))); break; case pause_pos_x: gCfgItems.pausePosX = atof(key_value); update_spi_flash(); break; case pause_pos_y: gCfgItems.pausePosY = atof(key_value); update_spi_flash(); break; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_tmc_current_settings.cpp b/Marlin/src/lcd/extui/mks_ui/draw_tmc_current_settings.cpp index b243c88705..cbb2bc059f 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_tmc_current_settings.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_tmc_current_settings.cpp @@ -49,34 +49,16 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; lv_clear_tmc_current_settings(); switch (obj->mks_obj_id) { - case ID_TMC_CURRENT_RETURN: - uiCfg.para_ui_page = false; - draw_return_ui(); - return; - #if AXIS_IS_TMC(X) - case ID_TMC_CURRENT_X: value = Xcurrent; break; - #endif - #if AXIS_IS_TMC(Y) - case ID_TMC_CURRENT_Y: value = Ycurrent; break; - #endif - #if AXIS_IS_TMC(Z) - case ID_TMC_CURRENT_Z: value = Zcurrent; break; - #endif - #if AXIS_IS_TMC(E0) - case ID_TMC_CURRENT_E0: value = E0current; break; - #endif - #if AXIS_IS_TMC(E1) - case ID_TMC_CURRENT_E1: value = E1current; break; - #endif + case ID_TMC_CURRENT_RETURN: uiCfg.para_ui_page = false; draw_return_ui(); return; - case ID_TMC_CURRENT_UP: - uiCfg.para_ui_page = false; - lv_draw_tmc_current_settings(); - return; - case ID_TMC_CURRENT_DOWN: - uiCfg.para_ui_page = true; - lv_draw_tmc_current_settings(); - return; + case ID_TMC_CURRENT_X: TERN_(X_IS_TRINAMIC, value = Xcurrent); break; + case ID_TMC_CURRENT_Y: TERN_(Y_IS_TRINAMIC, value = Ycurrent); break; + case ID_TMC_CURRENT_Z: TERN_(Z_IS_TRINAMIC, value = Zcurrent); break; + case ID_TMC_CURRENT_E0: TERN_(E0_IS_TRINAMIC, value = E0current); break; + case ID_TMC_CURRENT_E1: TERN_(E1_IS_TRINAMIC, value = E1current); break; + + case ID_TMC_CURRENT_UP: uiCfg.para_ui_page = false; lv_draw_tmc_current_settings(); return; + case ID_TMC_CURRENT_DOWN: uiCfg.para_ui_page = true; lv_draw_tmc_current_settings(); return; } lv_draw_number_key(); @@ -87,46 +69,26 @@ void lv_draw_tmc_current_settings() { float milliamps; if (!uiCfg.para_ui_page) { - #if AXIS_IS_TMC(X) - milliamps = stepperX.getMilliamps(); - #else - milliamps = -1; - #endif + milliamps = TERN(X_IS_TRINAMIC, stepperX.getMilliamps(), -1); dtostrf(milliamps, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.X_Current, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_CURRENT_X, 0, public_buf_l); - #if AXIS_IS_TMC(Y) - milliamps = stepperY.getMilliamps(); - #else - milliamps = -1; - #endif + milliamps = TERN(Y_IS_TRINAMIC, stepperY.getMilliamps(), -1); dtostrf(milliamps, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.Y_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_TMC_CURRENT_Y, 1, public_buf_l); - #if AXIS_IS_TMC(Z) - milliamps = stepperZ.getMilliamps(); - #else - milliamps = -1; - #endif + milliamps = TERN(Z_IS_TRINAMIC, stepperZ.getMilliamps(), -1); dtostrf(milliamps, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.Z_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_TMC_CURRENT_Z, 2, public_buf_l); - #if AXIS_IS_TMC(E0) - milliamps = stepperE0.getMilliamps(); - #else - milliamps = -1; - #endif + milliamps = TERN(E0_IS_TRINAMIC, stepperE0.getMilliamps(), -1); dtostrf(milliamps, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.E0_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_TMC_CURRENT_E0, 3, public_buf_l); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_CURRENT_DOWN, true); } else { - #if AXIS_IS_TMC(E1) - milliamps = stepperE1.getMilliamps(); - #else - milliamps = -1; - #endif + milliamps = TERN(E1_IS_TRINAMIC, stepperE1.getMilliamps(), -1); dtostrf(milliamps, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.E1_Current, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_CURRENT_E1, 0, public_buf_l); @@ -137,9 +99,8 @@ void lv_draw_tmc_current_settings() { } void lv_clear_tmc_current_settings() { - #if HAS_ROTARY_ENCODER - if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); - #endif + if (TERN0(HAS_ROTARY_ENCODER, gCfgItems.encoder_enable)) + lv_group_remove_all_objs(g); lv_obj_del(scr); } diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 5b6caf378a..b88df6ee9d 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -438,156 +438,68 @@ namespace ExtUI { #if HAS_TRINAMIC_CONFIG float getAxisCurrent_mA(const axis_t axis) { switch (axis) { - #if AXIS_IS_TMC(X) - case X: return stepperX.getMilliamps(); - #endif - #if AXIS_IS_TMC(Y) - case Y: return stepperY.getMilliamps(); - #endif - #if AXIS_IS_TMC(Z) - case Z: return stepperZ.getMilliamps(); - #endif - #if AXIS_IS_TMC(I) - case I: return stepperI.getMilliamps(); - #endif - #if AXIS_IS_TMC(J) - case J: return stepperJ.getMilliamps(); - #endif - #if AXIS_IS_TMC(K) - case K: return stepperK.getMilliamps(); - #endif - #if AXIS_IS_TMC(U) - case U: return stepperU.getMilliamps(); - #endif - #if AXIS_IS_TMC(V) - case V: return stepperV.getMilliamps(); - #endif - #if AXIS_IS_TMC(W) - case W: return stepperW.getMilliamps(); - #endif - #if AXIS_IS_TMC(X2) - case X2: return stepperX2.getMilliamps(); - #endif - #if AXIS_IS_TMC(Y2) - case Y2: return stepperY2.getMilliamps(); - #endif - #if AXIS_IS_TMC(Z2) - case Z2: return stepperZ2.getMilliamps(); - #endif - #if AXIS_IS_TMC(Z3) - case Z3: return stepperZ3.getMilliamps(); - #endif - #if AXIS_IS_TMC(Z4) - case Z4: return stepperZ4.getMilliamps(); - #endif + OPTCODE(X_IS_TRINAMIC, case X: return stepperX.getMilliamps()) + OPTCODE(Y_IS_TRINAMIC, case Y: return stepperY.getMilliamps()) + OPTCODE(Z_IS_TRINAMIC, case Z: return stepperZ.getMilliamps()) + OPTCODE(I_IS_TRINAMIC, case I: return stepperI.getMilliamps()) + OPTCODE(J_IS_TRINAMIC, case J: return stepperJ.getMilliamps()) + OPTCODE(K_IS_TRINAMIC, case K: return stepperK.getMilliamps()) + OPTCODE(U_IS_TRINAMIC, case U: return stepperU.getMilliamps()) + OPTCODE(V_IS_TRINAMIC, case V: return stepperV.getMilliamps()) + OPTCODE(W_IS_TRINAMIC, case W: return stepperW.getMilliamps()) + OPTCODE(X2_IS_TRINAMIC, case X2: return stepperX2.getMilliamps()) + OPTCODE(Y2_IS_TRINAMIC, case Y2: return stepperY2.getMilliamps()) + OPTCODE(Z2_IS_TRINAMIC, case Z2: return stepperZ2.getMilliamps()) + OPTCODE(Z3_IS_TRINAMIC, case Z3: return stepperZ3.getMilliamps()) + OPTCODE(Z4_IS_TRINAMIC, case Z4: return stepperZ4.getMilliamps()) default: return NAN; }; } float getAxisCurrent_mA(const extruder_t extruder) { switch (extruder) { - #if AXIS_IS_TMC(E0) - case E0: return stepperE0.getMilliamps(); - #endif - #if AXIS_IS_TMC(E1) - case E1: return stepperE1.getMilliamps(); - #endif - #if AXIS_IS_TMC(E2) - case E2: return stepperE2.getMilliamps(); - #endif - #if AXIS_IS_TMC(E3) - case E3: return stepperE3.getMilliamps(); - #endif - #if AXIS_IS_TMC(E4) - case E4: return stepperE4.getMilliamps(); - #endif - #if AXIS_IS_TMC(E5) - case E5: return stepperE5.getMilliamps(); - #endif - #if AXIS_IS_TMC(E6) - case E6: return stepperE6.getMilliamps(); - #endif - #if AXIS_IS_TMC(E7) - case E7: return stepperE7.getMilliamps(); - #endif + OPTCODE(E0_IS_TRINAMIC, case E0: return stepperE0.getMilliamps()) + OPTCODE(E1_IS_TRINAMIC, case E1: return stepperE1.getMilliamps()) + OPTCODE(E2_IS_TRINAMIC, case E2: return stepperE2.getMilliamps()) + OPTCODE(E3_IS_TRINAMIC, case E3: return stepperE3.getMilliamps()) + OPTCODE(E4_IS_TRINAMIC, case E4: return stepperE4.getMilliamps()) + OPTCODE(E5_IS_TRINAMIC, case E5: return stepperE5.getMilliamps()) + OPTCODE(E6_IS_TRINAMIC, case E6: return stepperE6.getMilliamps()) + OPTCODE(E7_IS_TRINAMIC, case E7: return stepperE7.getMilliamps()) default: return NAN; }; } void setAxisCurrent_mA(const_float_t mA, const axis_t axis) { switch (axis) { - #if AXIS_IS_TMC(X) - case X: stepperX.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(Y) - case Y: stepperY.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(Z) - case Z: stepperZ.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(I) - case I: stepperI.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(J) - case J: stepperJ.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(K) - case K: stepperK.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(U) - case U: stepperU.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(V) - case V: stepperV.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(W) - case W: stepperW.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(X2) - case X2: stepperX2.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(Y2) - case Y2: stepperY2.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(Z2) - case Z2: stepperZ2.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(Z3) - case Z3: stepperZ3.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(Z4) - case Z4: stepperZ4.rms_current(constrain(mA, 400, 1500)); break; - #endif + case X: TERN_(X_IS_TRINAMIC, stepperX.rms_current(constrain(mA, 400, 1500))); break; + case Y: TERN_(Y_IS_TRINAMIC, stepperY.rms_current(constrain(mA, 400, 1500))); break; + case Z: TERN_(Z_IS_TRINAMIC, stepperZ.rms_current(constrain(mA, 400, 1500))); break; + case I: TERN_(I_IS_TRINAMIC, stepperI.rms_current(constrain(mA, 400, 1500))); break; + case J: TERN_(J_IS_TRINAMIC, stepperJ.rms_current(constrain(mA, 400, 1500))); break; + case K: TERN_(K_IS_TRINAMIC, stepperK.rms_current(constrain(mA, 400, 1500))); break; + case U: TERN_(U_IS_TRINAMIC, stepperU.rms_current(constrain(mA, 400, 1500))); break; + case V: TERN_(V_IS_TRINAMIC, stepperV.rms_current(constrain(mA, 400, 1500))); break; + case W: TERN_(W_IS_TRINAMIC, stepperW.rms_current(constrain(mA, 400, 1500))); break; + case X2: TERN_(X2_IS_TRINAMIC, stepperX2.rms_current(constrain(mA, 400, 1500))); break; + case Y2: TERN_(Y2_IS_TRINAMIC, stepperY2.rms_current(constrain(mA, 400, 1500))); break; + case Z2: TERN_(Z2_IS_TRINAMIC, stepperZ2.rms_current(constrain(mA, 400, 1500))); break; + case Z3: TERN_(Z3_IS_TRINAMIC, stepperZ3.rms_current(constrain(mA, 400, 1500))); break; + case Z4: TERN_(Z4_IS_TRINAMIC, stepperZ4.rms_current(constrain(mA, 400, 1500))); break; default: break; }; } void setAxisCurrent_mA(const_float_t mA, const extruder_t extruder) { switch (extruder) { - #if AXIS_IS_TMC(E0) - case E0: stepperE0.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(E1) - case E1: stepperE1.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(E2) - case E2: stepperE2.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(E3) - case E3: stepperE3.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(E4) - case E4: stepperE4.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(E5) - case E5: stepperE5.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(E6) - case E6: stepperE6.rms_current(constrain(mA, 400, 1500)); break; - #endif - #if AXIS_IS_TMC(E7) - case E7: stepperE7.rms_current(constrain(mA, 400, 1500)); break; - #endif + case E0: TERN_(E0_IS_TRINAMIC, stepperE0.rms_current(constrain(mA, 400, 1500))); break; + case E1: TERN_(E1_IS_TRINAMIC, stepperE1.rms_current(constrain(mA, 400, 1500))); break; + case E2: TERN_(E2_IS_TRINAMIC, stepperE2.rms_current(constrain(mA, 400, 1500))); break; + case E3: TERN_(E3_IS_TRINAMIC, stepperE3.rms_current(constrain(mA, 400, 1500))); break; + case E4: TERN_(E4_IS_TRINAMIC, stepperE4.rms_current(constrain(mA, 400, 1500))); break; + case E5: TERN_(E5_IS_TRINAMIC, stepperE5.rms_current(constrain(mA, 400, 1500))); break; + case E6: TERN_(E6_IS_TRINAMIC, stepperE6.rms_current(constrain(mA, 400, 1500))); break; + case E7: TERN_(E7_IS_TRINAMIC, stepperE7.rms_current(constrain(mA, 400, 1500))); break; default: break; }; } @@ -614,48 +526,20 @@ namespace ExtUI { void setTMCBumpSensitivity(const_float_t value, const axis_t axis) { switch (axis) { - #if X_SENSORLESS - case X: stepperX.homing_threshold(value); break; - #endif - #if Y_SENSORLESS - case Y: stepperY.homing_threshold(value); break; - #endif - #if Z_SENSORLESS - case Z: stepperZ.homing_threshold(value); break; - #endif - #if I_SENSORLESS - case I: stepperI.homing_threshold(value); break; - #endif - #if J_SENSORLESS - case J: stepperJ.homing_threshold(value); break; - #endif - #if K_SENSORLESS - case K: stepperK.homing_threshold(value); break; - #endif - #if U_SENSORLESS - case U: stepperU.homing_threshold(value); break; - #endif - #if V_SENSORLESS - case V: stepperV.homing_threshold(value); break; - #endif - #if W_SENSORLESS - case W: stepperW.homing_threshold(value); break; - #endif - #if X2_SENSORLESS - case X2: stepperX2.homing_threshold(value); break; - #endif - #if Y2_SENSORLESS - case Y2: stepperY2.homing_threshold(value); break; - #endif - #if Z2_SENSORLESS - case Z2: stepperZ2.homing_threshold(value); break; - #endif - #if Z3_SENSORLESS - case Z3: stepperZ3.homing_threshold(value); break; - #endif - #if Z4_SENSORLESS - case Z4: stepperZ4.homing_threshold(value); break; - #endif + case X: TERN_(X_SENSORLESS, stepperX.homing_threshold(value)); break; + case Y: TERN_(Y_SENSORLESS, stepperY.homing_threshold(value)); break; + case Z: TERN_(Z_SENSORLESS, stepperZ.homing_threshold(value)); break; + case I: TERN_(I_SENSORLESS, stepperI.homing_threshold(value)); break; + case J: TERN_(J_SENSORLESS, stepperJ.homing_threshold(value)); break; + case K: TERN_(K_SENSORLESS, stepperK.homing_threshold(value)); break; + case U: TERN_(U_SENSORLESS, stepperU.homing_threshold(value)); break; + case V: TERN_(V_SENSORLESS, stepperV.homing_threshold(value)); break; + case W: TERN_(W_SENSORLESS, stepperW.homing_threshold(value)); break; + case X2: TERN_(X2_SENSORLESS, stepperX2.homing_threshold(value)); break; + case Y2: TERN_(Y2_SENSORLESS, stepperY2.homing_threshold(value)); break; + case Z2: TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(value)); break; + case Z3: TERN_(Z3_SENSORLESS, stepperZ3.homing_threshold(value)); break; + case Z4: TERN_(Z4_SENSORLESS, stepperZ4.homing_threshold(value)); break; default: break; } UNUSED(value); diff --git a/Marlin/src/lcd/menu/menu_tmc.cpp b/Marlin/src/lcd/menu/menu_tmc.cpp index c708bb5fa2..f73dd971df 100644 --- a/Marlin/src/lcd/menu/menu_tmc.cpp +++ b/Marlin/src/lcd/menu/menu_tmc.cpp @@ -32,74 +32,42 @@ #include "../../module/stepper/indirection.h" #include "../../feature/tmc_util.h" -#define TMC_EDIT_STORED_I_RMS(ST,STR) EDIT_ITEM_F(uint16_4, F(STR), &stepper##ST.val_mA, 100, 3000, []{ stepper##ST.refresh_stepper_current(); }) +#define TMC_EDIT_STORED_I_RMS(ST,STR) EDIT_ITEM_FAST_F(uint16_4, F(STR), &stepper##ST.val_mA, 100, 3000, []{ stepper##ST.refresh_stepper_current(); }) void menu_tmc_current() { START_MENU(); BACK_ITEM(MSG_TMC_DRIVERS); - #if AXIS_IS_TMC(X) - TMC_EDIT_STORED_I_RMS(X, STR_A); - #endif - #if AXIS_IS_TMC(Y) - TMC_EDIT_STORED_I_RMS(Y, STR_B); - #endif - #if AXIS_IS_TMC(Z) - TMC_EDIT_STORED_I_RMS(Z, STR_C); - #endif - #if AXIS_IS_TMC(X2) - TMC_EDIT_STORED_I_RMS(X2, STR_X2); - #endif - #if AXIS_IS_TMC(Y2) - TMC_EDIT_STORED_I_RMS(Y2, STR_Y2); - #endif - #if AXIS_IS_TMC(Z2) - TMC_EDIT_STORED_I_RMS(Z2, STR_Z2); - #endif - #if AXIS_IS_TMC(Z3) - TMC_EDIT_STORED_I_RMS(Z3, STR_Z3); - #endif - #if AXIS_IS_TMC(Z4) - TMC_EDIT_STORED_I_RMS(Z4, STR_Z4); - #endif - #if AXIS_IS_TMC(E0) - TMC_EDIT_STORED_I_RMS(E0, STR_E0); - #endif - #if AXIS_IS_TMC(E1) - TMC_EDIT_STORED_I_RMS(E1, STR_E1); - #endif - #if AXIS_IS_TMC(E2) - TMC_EDIT_STORED_I_RMS(E2, STR_E2); - #endif - #if AXIS_IS_TMC(E3) - TMC_EDIT_STORED_I_RMS(E3, STR_E3); - #endif - #if AXIS_IS_TMC(E4) - TMC_EDIT_STORED_I_RMS(E4, STR_E4); - #endif - #if AXIS_IS_TMC(E5) - TMC_EDIT_STORED_I_RMS(E5, STR_E5); - #endif - #if AXIS_IS_TMC(E6) - TMC_EDIT_STORED_I_RMS(E6, STR_E6); - #endif - #if AXIS_IS_TMC(E7) - TMC_EDIT_STORED_I_RMS(E7, STR_E7); - #endif + TERN_(X_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(X, STR_A)); + TERN_(X2_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(X2, STR_X2)); + TERN_(Y_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(Y, STR_B)); + TERN_(Y2_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(Y2, STR_Y2)); + TERN_(Z_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(Z, STR_C)); + TERN_(Z2_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(Z2, STR_Z2)); + TERN_(Z3_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(Z3, STR_Z3)); + TERN_(Z4_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(Z4, STR_Z4)); + TERN_(E0_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(E0, STR_E0)); + TERN_(E1_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(E1, STR_E1)); + TERN_(E2_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(E2, STR_E2)); + TERN_(E3_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(E3, STR_E3)); + TERN_(E4_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(E4, STR_E4)); + TERN_(E5_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(E5, STR_E5)); + TERN_(E6_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(E6, STR_E6)); + TERN_(E7_IS_TRINAMIC, TMC_EDIT_STORED_I_RMS(E7, STR_E7)); END_MENU(); } #if ENABLED(HYBRID_THRESHOLD) - #define TMC_EDIT_STORED_HYBRID_THRS(ST, STR) EDIT_ITEM_F(uint16_3, F(STR), &stepper##ST.stored.hybrid_thrs, 0, STEPPER_MAX_THRS(ST), []{ stepper##ST.refresh_hybrid_thrs(); }); + #define TMC_EDIT_STORED_HYBRID_THRS(ST, STR) EDIT_ITEM_FAST_F(uint16_3, F(STR), &stepper##ST.stored.hybrid_thrs, 0, STEPPER_MAX_THRS(ST), []{ stepper##ST.refresh_hybrid_thrs(); }); void menu_tmc_hybrid_thrs() { START_MENU(); BACK_ITEM(MSG_TMC_DRIVERS); - TERN_(X_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(X, STR_X)); - TERN_(Y_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Y, STR_Y)); - TERN_(Z_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z, STR_Z)); + TERN_( X_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(X, STR_X)); TERN_(X2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(X2, STR_X2)); + TERN_( Y_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Y, STR_Y)); TERN_(Y2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Y2, STR_Y2)); + TERN_( Z_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z, STR_Z)); TERN_(Z2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z2, STR_Z2)); TERN_(Z3_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z3, STR_Z3)); TERN_(Z4_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z4, STR_Z4)); @@ -114,7 +82,7 @@ void menu_tmc_current() { END_MENU(); } -#endif +#endif // HYBRID_THRESHOLD #if ENABLED(SENSORLESS_HOMING) @@ -140,7 +108,7 @@ void menu_tmc_current() { END_MENU(); } -#endif +#endif // SENSORLESS_HOMING #if HAS_STEALTHCHOP @@ -169,7 +137,7 @@ void menu_tmc_current() { END_MENU(); } -#endif +#endif // HAS_STEALTHCHOP void menu_tmc() { START_MENU(); diff --git a/Marlin/src/lcd/sovol_rts/sovol_rts.cpp b/Marlin/src/lcd/sovol_rts/sovol_rts.cpp index 1f3322ded7..c92850494b 100644 --- a/Marlin/src/lcd/sovol_rts/sovol_rts.cpp +++ b/Marlin/src/lcd/sovol_rts/sovol_rts.cpp @@ -122,7 +122,6 @@ bool card_insert_st; bool sd_printing; int16_t fan_speed; -char cmd[MAX_CMD_SIZE + 16]; inline void RTS_line_to_current(const AxisEnum axis) { if (!planner.is_full()) @@ -1398,18 +1397,10 @@ void RTS::handleData() { case TMCDriver: switch (recdat.data[0]) { case 1: // Current - #if AXIS_IS_TMC(X) - sendData(stepperX.getMilliamps(), Current_X_VP); - #endif - #if AXIS_IS_TMC(Y) - sendData(stepperY.getMilliamps(), Current_Y_VP); - #endif - #if AXIS_IS_TMC(Z) - sendData(stepperZ.getMilliamps(), Current_Z_VP); - #endif - #if AXIS_IS_TMC(E0) - sendData(stepperE0.getMilliamps(), Current_E_VP); - #endif + TERN_(X_IS_TRINAMIC, sendData(stepperX.getMilliamps(), Current_X_VP)); + TERN_(Y_IS_TRINAMIC, sendData(stepperY.getMilliamps(), Current_Y_VP)); + TERN_(Z_IS_TRINAMIC, sendData(stepperZ.getMilliamps(), Current_Z_VP)); + TERN_(E0_IS_TRINAMIC, sendData(stepperE0.getMilliamps(), Current_E_VP)); gotoPage(ID_DriverA_L, ID_DriverA_D); break; @@ -1434,39 +1425,19 @@ void RTS::handleData() { } break; - #if AXIS_IS_TMC(X) - case Current_X: sprintf_P(cmd, PSTR("M906 X%i"), recdat.data[0]); queue.inject(cmd); break; - #endif - #if X_HAS_STEALTHCHOP - case Threshold_X: sprintf_P(cmd, PSTR("M913 X%i"), recdat.data[0]); queue.inject(cmd); break; - #endif - #if X_SENSORLESS - case Sensorless_X: sprintf_P(cmd, PSTR("M914 X%i"), recdat.data[0]); queue.inject(cmd); break; - #endif + case Current_X: TERN_(X_IS_TRINAMIC, queue.inject(TS(F("M906X"), int(recdat.data[0])))); break; + case Threshold_X: TERN_(X_HAS_STEALTHCHOP, queue.inject(TS(F("M913X"), int(recdat.data[0])))); break; + case Sensorless_X: TERN_(X_SENSORLESS, queue.inject(TS(F("M914X"), int(recdat.data[0])))); break; - #if AXIS_IS_TMC(Y) - case Current_Y: sprintf_P(cmd, PSTR("M906 Y%i"), recdat.data[0]); queue.inject(cmd); break; - #endif - #if Y_HAS_STEALTHCHOP - case Threshold_Y: sprintf_P(cmd, PSTR("M913 Y%i"), recdat.data[0]); queue.inject(cmd); break; - #endif - #if Y_SENSORLESS - case Sensorless_Y: sprintf_P(cmd, PSTR("M914 Y%i"), recdat.data[0]); queue.inject(cmd); break; - #endif + case Current_Y: TERN_(X_IS_TRINAMIC, queue.inject(TS(F("M906Y"), int(recdat.data[0])))); break; + case Threshold_Y: TERN_(Y_HAS_STEALTHCHOP, queue.inject(TS(F("M913Y"), int(recdat.data[0])))); break; + case Sensorless_Y: TERN_(Y_SENSORLESS, queue.inject(TS(F("M914Y"), int(recdat.data[0])))); break; - #if AXIS_IS_TMC(Z) - case Current_Z: sprintf_P(cmd, PSTR("M906 Z%i"), recdat.data[0]); queue.inject(cmd); break; - #endif - #if Z_HAS_STEALTHCHOP - case Threshold_Z: sprintf_P(cmd, PSTR("M913 Z%i"), recdat.data[0]); queue.inject(cmd); break; - #endif + case Current_Z: TERN_(Z_IS_TRINAMIC, queue.inject(TS(F("M906Z"), int(recdat.data[0])))); break; + case Threshold_Z: TERN_(Z_HAS_STEALTHCHOP, queue.inject(TS(F("M913Z"), int(recdat.data[0])))); break; - #if AXIS_IS_TMC(E0) - case Current_E: sprintf_P(cmd, PSTR("M906 E%i"), recdat.data[0]); queue.inject(cmd); break; - #endif - #if E0_HAS_STEALTHCHOP - case Threshold_E: sprintf_P(cmd, PSTR("M913 E%i"), recdat.data[0]); queue.inject(cmd); break; - #endif + case Current_E: TERN_(AXIS_IS_TMC_E, queue.inject(TS(F("M906E"), int(recdat.data[0])))); break; + case Threshold_E: TERN_(E_HAS_STEALTHCHOP, queue.inject(TS(F("M913E"), int(recdat.data[0])))); break; #endif // HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 6a039c8ab9..386d46665d 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -271,46 +271,46 @@ void report_current_position_projected() { #define debug_current(...) #endif - #if HAS_CURRENT_HOME(X) + #if HAS_CURRENT_HOME_X int16_t saved_current_X; #endif - #if HAS_CURRENT_HOME(Y) + #if HAS_CURRENT_HOME_Y int16_t saved_current_Y; #endif - #if HAS_CURRENT_HOME(Z) + #if HAS_CURRENT_HOME_Z int16_t saved_current_Z; #endif - #if HAS_CURRENT_HOME(X2) + #if HAS_CURRENT_HOME_X2 int16_t saved_current_X2; #endif - #if HAS_CURRENT_HOME(Y2) + #if HAS_CURRENT_HOME_Y2 int16_t saved_current_Y2; #endif - #if HAS_CURRENT_HOME(Z2) + #if HAS_CURRENT_HOME_Z2 int16_t saved_current_Z2; #endif - #if HAS_CURRENT_HOME(Z3) + #if HAS_CURRENT_HOME_Z3 int16_t saved_current_Z3; #endif - #if HAS_CURRENT_HOME(Z4) + #if HAS_CURRENT_HOME_Z4 int16_t saved_current_Z4; #endif - #if HAS_CURRENT_HOME(I) + #if HAS_CURRENT_HOME_I int16_t saved_current_I; #endif - #if HAS_CURRENT_HOME(J) + #if HAS_CURRENT_HOME_J int16_t saved_current_J; #endif - #if HAS_CURRENT_HOME(K) + #if HAS_CURRENT_HOME_K int16_t saved_current_K; #endif - #if HAS_CURRENT_HOME(U) + #if HAS_CURRENT_HOME_U int16_t saved_current_U; #endif - #if HAS_CURRENT_HOME(V) + #if HAS_CURRENT_HOME_V int16_t saved_current_V; #endif - #if HAS_CURRENT_HOME(W) + #if HAS_CURRENT_HOME_W int16_t saved_current_W; #endif @@ -326,6 +326,8 @@ void report_current_position_projected() { stepper##A.rms_current(A##_CURRENT_HOME); \ debug_current(F(STR_##A), saved_current_##A, A##_CURRENT_HOME) + #define _MAP_SAVE_SET(A) OPTCODE(A##_HAS_HOME_CURRENT, _SAVE_SET_CURRENT(A)) + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Setting homing driver current"); #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) @@ -333,34 +335,8 @@ void report_current_position_projected() { // CORE and Markforged kinematics switch (axis) { default: break; - case X_AXIS: case Y_AXIS: - #if HAS_CURRENT_HOME(X) - _SAVE_SET_CURRENT(X); - #endif - #if HAS_CURRENT_HOME(X2) - _SAVE_SET_CURRENT(X2); - #endif - #if HAS_CURRENT_HOME(Y) - _SAVE_SET_CURRENT(Y); - #endif - #if HAS_CURRENT_HOME(Y2) - _SAVE_SET_CURRENT(Y2); - #endif - break; - case Z_AXIS: - #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 - break; + case X_AXIS: case Y_AXIS: MAP(_MAP_SAVE_SET, X, X2, Y, Y2); break; + case Z_AXIS: MAP(_MAP_SAVE_SET, Z, Z2, Z3, Z4); break; } #elif CORE_IS_XZ @@ -368,22 +344,8 @@ void report_current_position_projected() { // CORE XZ / ZX switch (axis) { default: break; - case X_AXIS: case Z_AXIS: - #if HAS_CURRENT_HOME(X) - _SAVE_SET_CURRENT(X); - #endif - #if HAS_CURRENT_HOME(Z) - _SAVE_SET_CURRENT(Z); - #endif - break; - case Y_AXIS: - #if HAS_CURRENT_HOME(Y) - _SAVE_SET_CURRENT(Y); - #endif - #if HAS_CURRENT_HOME(Y2) - _SAVE_SET_CURRENT(Y2); - #endif - break; + case X_AXIS: case Z_AXIS: MAP(_MAP_SAVE_SET, X, Z); break; + case Y_AXIS: MAP(_MAP_SAVE_SET, Y, Y2); break; } #elif CORE_IS_YZ @@ -391,22 +353,8 @@ void report_current_position_projected() { // CORE YZ / ZY switch (axis) { default: break; - case X_AXIS: - #if HAS_CURRENT_HOME(X) - _SAVE_SET_CURRENT(X); - #endif - #if HAS_CURRENT_HOME(X2) - _SAVE_SET_CURRENT(X2); - #endif - break; - case Y_AXIS: case Z_AXIS: - #if HAS_CURRENT_HOME(Y) - _SAVE_SET_CURRENT(Y); - #endif - #if HAS_CURRENT_HOME(Z) - _SAVE_SET_CURRENT(Z); - #endif - break; + case X_AXIS: MAP(_MAP_SAVE_SET, X, X2); break; + case Y_AXIS: case Z_AXIS: MAP(_MAP_SAVE_SET, Y, Z); break; } #elif IS_SCARA @@ -414,13 +362,13 @@ void report_current_position_projected() { // SCARA kinematics switch (axis) { default: break; - #if HAS_CURRENT_HOME(X) + #if X_HAS_HOME_CURRENT case A_AXIS: _SAVE_SET_CURRENT(X); break; #endif - #if HAS_CURRENT_HOME(Y) + #if Y_HAS_HOME_CURRENT case B_AXIS: _SAVE_SET_CURRENT(Y); break; #endif - #if HAS_CURRENT_HOME(Z) + #if Z_HAS_HOME_CURRENT case C_AXIS: _SAVE_SET_CURRENT(Z); break; #endif } @@ -429,13 +377,13 @@ void report_current_position_projected() { // TPARA or DELTA kinematics. // Z_AXIS is a special mode to apply homing current to all axes. - #if HAS_CURRENT_HOME(X) + #if X_HAS_HOME_CURRENT if (axis == A_AXIS || axis == Z_AXIS) _SAVE_SET_CURRENT(X); #endif - #if HAS_CURRENT_HOME(Y) + #if Y_HAS_HOME_CURRENT if (axis == B_AXIS || axis == Z_AXIS) _SAVE_SET_CURRENT(Y); #endif - #if HAS_CURRENT_HOME(Z) + #if Z_HAS_HOME_CURRENT if (axis == C_AXIS) _SAVE_SET_CURRENT(Z); #endif @@ -444,13 +392,13 @@ void report_current_position_projected() { // POLAR kinematics switch (axis) { default: break; - #if HAS_CURRENT_HOME(X) + #if X_HAS_HOME_CURRENT case A_AXIS: _SAVE_SET_CURRENT(X); break; #endif - #if HAS_CURRENT_HOME(Y) + #if Y_HAS_HOME_CURRENT case B_AXIS: _SAVE_SET_CURRENT(Y); break; #endif - #if HAS_CURRENT_HOME(Z) + #if Z_HAS_HOME_CURRENT case C_AXIS: _SAVE_SET_CURRENT(Z); break; #endif } @@ -461,13 +409,13 @@ void report_current_position_projected() { // Useful? switch (axis) { default: break; - #if HAS_CURRENT_HOME(X) + #if X_HAS_HOME_CURRENT case A_AXIS: _SAVE_SET_CURRENT(X); break; #endif - #if HAS_CURRENT_HOME(Y) + #if Y_HAS_HOME_CURRENT case B_AXIS: _SAVE_SET_CURRENT(Y); break; #endif - #if HAS_CURRENT_HOME(Z) + #if Z_HAS_HOME_CURRENT case C_AXIS: _SAVE_SET_CURRENT(Z); break; #endif } @@ -477,27 +425,9 @@ void report_current_position_projected() { // Foam cutter switch (axis) { default: break; - case X_AXIS: case I_AXIS: - #if HAS_CURRENT_HOME(X) - _SAVE_SET_CURRENT(X); - #endif - #if HAS_CURRENT_HOME(I) - _SAVE_SET_CURRENT(I); - #endif - break; - case Y_AXIS: case J_AXIS: - #if HAS_CURRENT_HOME(Y) - _SAVE_SET_CURRENT(Y); - #endif - #if HAS_CURRENT_HOME(J) - _SAVE_SET_CURRENT(J); - #endif - break; - case Z_AXIS: - #if HAS_CURRENT_HOME(Z) - _SAVE_SET_CURRENT(Z); - #endif - break; + case X_AXIS: case I_AXIS: MAP(_MAP_SAVE_SET, X, I); break; + case Y_AXIS: case J_AXIS: MAP(_MAP_SAVE_SET, Y, J); break; + case Z_AXIS: MAP(_MAP_SAVE_SET, Z); break; } #else @@ -505,58 +435,31 @@ void report_current_position_projected() { // Cartesian kinematics switch (axis) { default: break; - case X_AXIS: - #if HAS_CURRENT_HOME(X) - _SAVE_SET_CURRENT(X); - #endif - #if HAS_CURRENT_HOME(X2) - _SAVE_SET_CURRENT(X2); - #endif - break; - case Y_AXIS: - #if HAS_CURRENT_HOME(Y) - _SAVE_SET_CURRENT(Y); - #endif - #if HAS_CURRENT_HOME(Y2) - _SAVE_SET_CURRENT(Y2); - #endif - break; - case Z_AXIS: - #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 - break; + case X_AXIS: MAP(_MAP_SAVE_SET, X, X2); break; + case Y_AXIS: MAP(_MAP_SAVE_SET, Y, Y2); break; + case Z_AXIS: MAP(_MAP_SAVE_SET, Z, Z2, Z3, Z4); break; } #endif // kinematics switch (axis) { default: break; - #if HAS_CURRENT_HOME(I) && DISABLED(FOAMCUTTER_XYUV) + #if I_HAS_HOME_CURRENT && DISABLED(FOAMCUTTER_XYUV) case I_AXIS: _SAVE_SET_CURRENT(I); break; #endif - #if HAS_CURRENT_HOME(J) && DISABLED(FOAMCUTTER_XYUV) + #if J_HAS_HOME_CURRENT && DISABLED(FOAMCUTTER_XYUV) case J_AXIS: _SAVE_SET_CURRENT(J); break; #endif - #if HAS_CURRENT_HOME(K) + #if K_HAS_HOME_CURRENT case K_AXIS: _SAVE_SET_CURRENT(K); break; #endif - #if HAS_CURRENT_HOME(U) + #if U_HAS_HOME_CURRENT case U_AXIS: _SAVE_SET_CURRENT(U); break; #endif - #if HAS_CURRENT_HOME(V) + #if V_HAS_HOME_CURRENT case V_AXIS: _SAVE_SET_CURRENT(V); break; #endif - #if HAS_CURRENT_HOME(W) + #if W_HAS_HOME_CURRENT case W_AXIS: _SAVE_SET_CURRENT(W); break; #endif } @@ -578,6 +481,8 @@ void report_current_position_projected() { stepper##A.rms_current(saved_current_##A); \ debug_current(F(STR_##A), A##_CURRENT_HOME, saved_current_##A) + #define _MAP_RESTORE(A) OPTCODE(A##_HAS_HOME_CURRENT, _RESTORE_CURRENT(A)) + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Restore driver current"); #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) @@ -585,28 +490,8 @@ void report_current_position_projected() { // CORE and Markforged kinematics switch (axis) { default: break; - case X_AXIS: case Y_AXIS: - #if HAS_CURRENT_HOME(X) - _RESTORE_CURRENT(X); - #endif - #if HAS_CURRENT_HOME(Y) - _RESTORE_CURRENT(Y); - #endif - break; - case Z_AXIS: - #if HAS_CURRENT_HOME(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 - break; + case X_AXIS: case Y_AXIS: MAP(_MAP_RESTORE, X, Y); break; + case Z_AXIS: MAP(_MAP_RESTORE, Z, Z2, Z3, Z4); break; } #elif CORE_IS_XZ @@ -614,22 +499,8 @@ void report_current_position_projected() { // CORE XZ / ZX switch (axis) { default: break; - case X_AXIS: case Z_AXIS: - #if HAS_CURRENT_HOME(X) - _RESTORE_CURRENT(X); - #endif - #if HAS_CURRENT_HOME(Z) - _RESTORE_CURRENT(Z); - #endif - break; - case Y_AXIS: - #if HAS_CURRENT_HOME(Y) - _RESTORE_CURRENT(Y); - #endif - #if HAS_CURRENT_HOME(Y2) - _RESTORE_CURRENT(Y2); - #endif - break; + case X_AXIS: case Z_AXIS: MAP(_MAP_RESTORE, X, Z); break; + case Y_AXIS: MAP(_MAP_RESTORE, Y, Y2); break; } #elif CORE_IS_YZ @@ -637,22 +508,8 @@ void report_current_position_projected() { // CORE YZ / ZY switch (axis) { default: break; - case X_AXIS: - #if HAS_CURRENT_HOME(X) - _RESTORE_CURRENT(X); - #endif - #if HAS_CURRENT_HOME(X2) - _RESTORE_CURRENT(X2); - #endif - break; - case Y_AXIS: case Z_AXIS: - #if HAS_CURRENT_HOME(Y) - _RESTORE_CURRENT(Y); - #endif - #if HAS_CURRENT_HOME(Z) - _RESTORE_CURRENT(Z); - #endif - break; + case X_AXIS: MAP(_MAP_RESTORE, X, X2); break; + case Y_AXIS: case Z_AXIS: MAP(_MAP_RESTORE, Y, Z); break; } #elif IS_SCARA // Unsupported for now? @@ -660,13 +517,13 @@ void report_current_position_projected() { // SCARA kinematics switch (axis) { default: break; - #if HAS_CURRENT_HOME(X) + #if X_HAS_HOME_CURRENT case A_AXIS: _RESTORE_CURRENT(X); break; #endif - #if HAS_CURRENT_HOME(Y) + #if Y_HAS_HOME_CURRENT case B_AXIS: _RESTORE_CURRENT(Y); break; #endif - #if HAS_CURRENT_HOME(Z) + #if Z_HAS_HOME_CURRENT case C_AXIS: _RESTORE_CURRENT(Z); break; #endif } @@ -675,13 +532,13 @@ void report_current_position_projected() { // TPARA or DELTA kinematics // Z_AXIS is a special mode to set homing current to all axes - #if HAS_CURRENT_HOME(X) + #if X_HAS_HOME_CURRENT if (axis == A_AXIS || axis == Z_AXIS) _RESTORE_CURRENT(X); #endif - #if HAS_CURRENT_HOME(Y) + #if Y_HAS_HOME_CURRENT if (axis == B_AXIS || axis == Z_AXIS) _RESTORE_CURRENT(Y); #endif - #if HAS_CURRENT_HOME(Z) + #if Z_HAS_HOME_CURRENT if (axis == C_AXIS) _RESTORE_CURRENT(Z); #endif @@ -690,13 +547,13 @@ void report_current_position_projected() { // POLAR kinematics switch (axis) { default: break; - #if HAS_CURRENT_HOME(X) + #if X_HAS_HOME_CURRENT case A_AXIS: _RESTORE_CURRENT(X); break; #endif - #if HAS_CURRENT_HOME(Y) + #if Y_HAS_HOME_CURRENT case B_AXIS: _RESTORE_CURRENT(Y); break; #endif - #if HAS_CURRENT_HOME(Z) + #if Z_HAS_HOME_CURRENT case C_AXIS: _RESTORE_CURRENT(Z); break; #endif } @@ -707,13 +564,13 @@ void report_current_position_projected() { // Useful? switch (axis) { default: break; - #if HAS_CURRENT_HOME(X) + #if X_HAS_HOME_CURRENT case A_AXIS: _RESTORE_CURRENT(X); break; #endif - #if HAS_CURRENT_HOME(Y) + #if Y_HAS_HOME_CURRENT case B_AXIS: _RESTORE_CURRENT(Y); break; #endif - #if HAS_CURRENT_HOME(Z) + #if Z_HAS_HOME_CURRENT case C_AXIS: _RESTORE_CURRENT(Z); break; #endif } @@ -723,27 +580,9 @@ void report_current_position_projected() { // Foam cutter switch (axis) { default: break; - case X_AXIS: case I_AXIS: - #if HAS_CURRENT_HOME(X) - _RESTORE_CURRENT(X); - #endif - #if HAS_CURRENT_HOME(I) - _RESTORE_CURRENT(I); - #endif - break; - case Y_AXIS: case J_AXIS: - #if HAS_CURRENT_HOME(Y) - _RESTORE_CURRENT(Y); - #endif - #if HAS_CURRENT_HOME(J) - _RESTORE_CURRENT(J); - #endif - break; - case Z_AXIS: - #if HAS_CURRENT_HOME(Z) - _RESTORE_CURRENT(Z); - #endif - break; + case X_AXIS: case I_AXIS: MAP(_MAP_RESTORE, X, I); break; + case Y_AXIS: case J_AXIS: MAP(_MAP_RESTORE, Y, J); break; + case Z_AXIS: MAP(_MAP_RESTORE, Z); break; } #else @@ -751,58 +590,31 @@ void report_current_position_projected() { // Cartesian kinematics switch (axis) { default: break; - case X_AXIS: - #if HAS_CURRENT_HOME(X) - _RESTORE_CURRENT(X); - #endif - #if HAS_CURRENT_HOME(X2) - _RESTORE_CURRENT(X2); - #endif - break; - case Y_AXIS: - #if HAS_CURRENT_HOME(Y) - _RESTORE_CURRENT(Y); - #endif - #if HAS_CURRENT_HOME(Y2) - _RESTORE_CURRENT(Y2); - #endif - break; - case Z_AXIS: - #if HAS_CURRENT_HOME(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 - break; + case X_AXIS: MAP(_MAP_RESTORE, X, X2); break; + case Y_AXIS: MAP(_MAP_RESTORE, Y, Y2); break; + case Z_AXIS: MAP(_MAP_RESTORE, Z, Z2, Z3, Z4); break; } #endif // kinematics switch (axis) { default: break; - #if HAS_CURRENT_HOME(I) && DISABLED(FOAMCUTTER_XYUV) + #if I_HAS_HOME_CURRENT && DISABLED(FOAMCUTTER_XYUV) case I_AXIS: _RESTORE_CURRENT(I); break; #endif - #if HAS_CURRENT_HOME(J) && DISABLED(FOAMCUTTER_XYUV) + #if J_HAS_HOME_CURRENT && DISABLED(FOAMCUTTER_XYUV) case J_AXIS: _RESTORE_CURRENT(J); break; #endif - #if HAS_CURRENT_HOME(K) + #if K_HAS_HOME_CURRENT case K_AXIS: _RESTORE_CURRENT(K); break; #endif - #if HAS_CURRENT_HOME(U) + #if U_HAS_HOME_CURRENT case U_AXIS: _RESTORE_CURRENT(U); break; #endif - #if HAS_CURRENT_HOME(V) + #if V_HAS_HOME_CURRENT case V_AXIS: _RESTORE_CURRENT(V); break; #endif - #if HAS_CURRENT_HOME(W) + #if W_HAS_HOME_CURRENT case W_AXIS: _RESTORE_CURRENT(W); break; #endif } diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 6d3bfaed0d..18376cf773 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -636,6 +636,9 @@ void home_if_needed(const bool keeplev=false); void set_home_offset(const AxisEnum axis, const_float_t v); #endif +// +// Trinamic Stepper Drivers +// #if USE_SENSORLESS struct sensorless_t; sensorless_t start_sensorless_homing_per_axis(const AxisEnum axis); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 8c33e73f00..a7e791951b 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1393,72 +1393,28 @@ void MarlinSettings::postprocess() { per_stepper_uint16_t tmc_stepper_current{0}; #if HAS_TRINAMIC_CONFIG - #if AXIS_IS_TMC(X) - tmc_stepper_current.X = stepperX.getMilliamps(); - #endif - #if AXIS_IS_TMC(Y) - tmc_stepper_current.Y = stepperY.getMilliamps(); - #endif - #if AXIS_IS_TMC(Z) - tmc_stepper_current.Z = stepperZ.getMilliamps(); - #endif - #if AXIS_IS_TMC(I) - tmc_stepper_current.I = stepperI.getMilliamps(); - #endif - #if AXIS_IS_TMC(J) - tmc_stepper_current.J = stepperJ.getMilliamps(); - #endif - #if AXIS_IS_TMC(K) - tmc_stepper_current.K = stepperK.getMilliamps(); - #endif - #if AXIS_IS_TMC(U) - tmc_stepper_current.U = stepperU.getMilliamps(); - #endif - #if AXIS_IS_TMC(V) - tmc_stepper_current.V = stepperV.getMilliamps(); - #endif - #if AXIS_IS_TMC(W) - tmc_stepper_current.W = stepperW.getMilliamps(); - #endif - #if AXIS_IS_TMC(X2) - tmc_stepper_current.X2 = stepperX2.getMilliamps(); - #endif - #if AXIS_IS_TMC(Y2) - tmc_stepper_current.Y2 = stepperY2.getMilliamps(); - #endif - #if AXIS_IS_TMC(Z2) - tmc_stepper_current.Z2 = stepperZ2.getMilliamps(); - #endif - #if AXIS_IS_TMC(Z3) - tmc_stepper_current.Z3 = stepperZ3.getMilliamps(); - #endif - #if AXIS_IS_TMC(Z4) - tmc_stepper_current.Z4 = stepperZ4.getMilliamps(); - #endif - #if AXIS_IS_TMC(E0) - tmc_stepper_current.E0 = stepperE0.getMilliamps(); - #endif - #if AXIS_IS_TMC(E1) - tmc_stepper_current.E1 = stepperE1.getMilliamps(); - #endif - #if AXIS_IS_TMC(E2) - tmc_stepper_current.E2 = stepperE2.getMilliamps(); - #endif - #if AXIS_IS_TMC(E3) - tmc_stepper_current.E3 = stepperE3.getMilliamps(); - #endif - #if AXIS_IS_TMC(E4) - tmc_stepper_current.E4 = stepperE4.getMilliamps(); - #endif - #if AXIS_IS_TMC(E5) - tmc_stepper_current.E5 = stepperE5.getMilliamps(); - #endif - #if AXIS_IS_TMC(E6) - tmc_stepper_current.E6 = stepperE6.getMilliamps(); - #endif - #if AXIS_IS_TMC(E7) - tmc_stepper_current.E7 = stepperE7.getMilliamps(); - #endif + TERN_(X_IS_TRINAMIC, tmc_stepper_current.X = stepperX.getMilliamps()); + TERN_(Y_IS_TRINAMIC, tmc_stepper_current.Y = stepperY.getMilliamps()); + TERN_(Z_IS_TRINAMIC, tmc_stepper_current.Z = stepperZ.getMilliamps()); + TERN_(I_IS_TRINAMIC, tmc_stepper_current.I = stepperI.getMilliamps()); + TERN_(J_IS_TRINAMIC, tmc_stepper_current.J = stepperJ.getMilliamps()); + TERN_(K_IS_TRINAMIC, tmc_stepper_current.K = stepperK.getMilliamps()); + TERN_(U_IS_TRINAMIC, tmc_stepper_current.U = stepperU.getMilliamps()); + TERN_(V_IS_TRINAMIC, tmc_stepper_current.V = stepperV.getMilliamps()); + TERN_(W_IS_TRINAMIC, tmc_stepper_current.W = stepperW.getMilliamps()); + TERN_(X2_IS_TRINAMIC, tmc_stepper_current.X2 = stepperX2.getMilliamps()); + TERN_(Y2_IS_TRINAMIC, tmc_stepper_current.Y2 = stepperY2.getMilliamps()); + TERN_(Z2_IS_TRINAMIC, tmc_stepper_current.Z2 = stepperZ2.getMilliamps()); + TERN_(Z3_IS_TRINAMIC, tmc_stepper_current.Z3 = stepperZ3.getMilliamps()); + TERN_(Z4_IS_TRINAMIC, tmc_stepper_current.Z4 = stepperZ4.getMilliamps()); + TERN_(E0_IS_TRINAMIC, tmc_stepper_current.E0 = stepperE0.getMilliamps()); + TERN_(E1_IS_TRINAMIC, tmc_stepper_current.E1 = stepperE1.getMilliamps()); + TERN_(E2_IS_TRINAMIC, tmc_stepper_current.E2 = stepperE2.getMilliamps()); + TERN_(E3_IS_TRINAMIC, tmc_stepper_current.E3 = stepperE3.getMilliamps()); + TERN_(E4_IS_TRINAMIC, tmc_stepper_current.E4 = stepperE4.getMilliamps()); + TERN_(E5_IS_TRINAMIC, tmc_stepper_current.E5 = stepperE5.getMilliamps()); + TERN_(E6_IS_TRINAMIC, tmc_stepper_current.E6 = stepperE6.getMilliamps()); + TERN_(E7_IS_TRINAMIC, tmc_stepper_current.E7 = stepperE7.getMilliamps()); #endif EEPROM_WRITE(tmc_stepper_current); } @@ -2499,72 +2455,28 @@ void MarlinSettings::postprocess() { #define SET_CURR(Q) stepper##Q.rms_current(currents.Q ? currents.Q : Q##_CURRENT) if (!validating) { - #if AXIS_IS_TMC(X) - SET_CURR(X); - #endif - #if AXIS_IS_TMC(Y) - SET_CURR(Y); - #endif - #if AXIS_IS_TMC(Z) - SET_CURR(Z); - #endif - #if AXIS_IS_TMC(X2) - SET_CURR(X2); - #endif - #if AXIS_IS_TMC(Y2) - SET_CURR(Y2); - #endif - #if AXIS_IS_TMC(Z2) - SET_CURR(Z2); - #endif - #if AXIS_IS_TMC(Z3) - SET_CURR(Z3); - #endif - #if AXIS_IS_TMC(Z4) - SET_CURR(Z4); - #endif - #if AXIS_IS_TMC(I) - SET_CURR(I); - #endif - #if AXIS_IS_TMC(J) - SET_CURR(J); - #endif - #if AXIS_IS_TMC(K) - SET_CURR(K); - #endif - #if AXIS_IS_TMC(U) - SET_CURR(U); - #endif - #if AXIS_IS_TMC(V) - SET_CURR(V); - #endif - #if AXIS_IS_TMC(W) - SET_CURR(W); - #endif - #if AXIS_IS_TMC(E0) - SET_CURR(E0); - #endif - #if AXIS_IS_TMC(E1) - SET_CURR(E1); - #endif - #if AXIS_IS_TMC(E2) - SET_CURR(E2); - #endif - #if AXIS_IS_TMC(E3) - SET_CURR(E3); - #endif - #if AXIS_IS_TMC(E4) - SET_CURR(E4); - #endif - #if AXIS_IS_TMC(E5) - SET_CURR(E5); - #endif - #if AXIS_IS_TMC(E6) - SET_CURR(E6); - #endif - #if AXIS_IS_TMC(E7) - SET_CURR(E7); - #endif + TERN_(X_IS_TRINAMIC, SET_CURR(X)); + TERN_(Y_IS_TRINAMIC, SET_CURR(Y)); + TERN_(Z_IS_TRINAMIC, SET_CURR(Z)); + TERN_(I_IS_TRINAMIC, SET_CURR(I)); + TERN_(J_IS_TRINAMIC, SET_CURR(J)); + TERN_(K_IS_TRINAMIC, SET_CURR(K)); + TERN_(U_IS_TRINAMIC, SET_CURR(U)); + TERN_(V_IS_TRINAMIC, SET_CURR(V)); + TERN_(W_IS_TRINAMIC, SET_CURR(W)); + TERN_(X2_IS_TRINAMIC, SET_CURR(X2)); + TERN_(Y2_IS_TRINAMIC, SET_CURR(Y2)); + TERN_(Z2_IS_TRINAMIC, SET_CURR(Z2)); + TERN_(Z3_IS_TRINAMIC, SET_CURR(Z3)); + TERN_(Z4_IS_TRINAMIC, SET_CURR(Z4)); + TERN_(E0_IS_TRINAMIC, SET_CURR(E0)); + TERN_(E1_IS_TRINAMIC, SET_CURR(E1)); + TERN_(E2_IS_TRINAMIC, SET_CURR(E2)); + TERN_(E3_IS_TRINAMIC, SET_CURR(E3)); + TERN_(E4_IS_TRINAMIC, SET_CURR(E4)); + TERN_(E5_IS_TRINAMIC, SET_CURR(E5)); + TERN_(E6_IS_TRINAMIC, SET_CURR(E6)); + TERN_(E7_IS_TRINAMIC, SET_CURR(E7)); } #endif } diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 69c6f66fbc..1ec82ba340 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2949,54 +2949,20 @@ void Stepper::init() { TERN_(HAS_MICROSTEPS, microstep_init()); // Init Dir Pins - TERN_(HAS_X_DIR, X_DIR_INIT()); + TERN_(HAS_X_DIR, X_DIR_INIT()); TERN_(HAS_X2_DIR, X2_DIR_INIT()); - #if HAS_Y_DIR - Y_DIR_INIT(); - #if ALL(HAS_Y2_STEPPER, HAS_Y2_DIR) - Y2_DIR_INIT(); - #endif - #endif - #if HAS_Z_DIR - Z_DIR_INIT(); - #if NUM_Z_STEPPERS >= 2 && HAS_Z2_DIR - Z2_DIR_INIT(); - #endif - #if NUM_Z_STEPPERS >= 3 && HAS_Z3_DIR - Z3_DIR_INIT(); - #endif - #if NUM_Z_STEPPERS >= 4 && HAS_Z4_DIR - Z4_DIR_INIT(); - #endif - #endif - SECONDARY_AXIS_CODE( - I_DIR_INIT(), J_DIR_INIT(), K_DIR_INIT(), - U_DIR_INIT(), V_DIR_INIT(), W_DIR_INIT() - ); - #if HAS_E0_DIR - E0_DIR_INIT(); - #endif - #if HAS_E1_DIR - E1_DIR_INIT(); - #endif - #if HAS_E2_DIR - E2_DIR_INIT(); - #endif - #if HAS_E3_DIR - E3_DIR_INIT(); - #endif - #if HAS_E4_DIR - E4_DIR_INIT(); - #endif - #if HAS_E5_DIR - E5_DIR_INIT(); - #endif - #if HAS_E6_DIR - E6_DIR_INIT(); - #endif - #if HAS_E7_DIR - E7_DIR_INIT(); - #endif + TERN_(HAS_Y_DIR, Y_DIR_INIT()); + TERN_(HAS_Y2_DIR, Y2_DIR_INIT()); + TERN_(HAS_Z_DIR, Z_DIR_INIT()); + TERN_(HAS_Z2_DIR, Z2_DIR_INIT()); + TERN_(HAS_Z3_DIR, Z3_DIR_INIT()); + TERN_(HAS_Z4_DIR, Z4_DIR_INIT()); + TERN_(HAS_I_DIR, I_DIR_INIT()); + TERN_(HAS_K_DIR, K_DIR_INIT()); + TERN_(HAS_K_DIR, K_DIR_INIT()); + TERN_(HAS_U_DIR, U_DIR_INIT()); + TERN_(HAS_V_DIR, V_DIR_INIT()); + TERN_(HAS_W_DIR, W_DIR_INIT()); // Init Enable Pins - steppers default to disabled. #if HAS_X_ENABLE @@ -3027,15 +2993,15 @@ void Stepper::init() { #endif Z_ENABLE_INIT(); if (Z_ENABLE_INIT_STATE) Z_ENABLE_WRITE(Z_ENABLE_INIT_STATE); - #if NUM_Z_STEPPERS >= 2 && HAS_Z2_ENABLE + #if HAS_Z2_ENABLE Z2_ENABLE_INIT(); if (Z_ENABLE_INIT_STATE) Z2_ENABLE_WRITE(Z_ENABLE_INIT_STATE); #endif - #if NUM_Z_STEPPERS >= 3 && HAS_Z3_ENABLE + #if HAS_Z3_ENABLE Z3_ENABLE_INIT(); if (Z_ENABLE_INIT_STATE) Z3_ENABLE_WRITE(Z_ENABLE_INIT_STATE); #endif - #if NUM_Z_STEPPERS >= 4 && HAS_Z4_ENABLE + #if HAS_Z4_ENABLE Z4_ENABLE_INIT(); if (Z_ENABLE_INIT_STATE) Z4_ENABLE_WRITE(Z_ENABLE_INIT_STATE); #endif @@ -3133,7 +3099,7 @@ void Stepper::init() { _WRITE_STEP(AXIS, !_STEP_STATE(PIN)); \ _DISABLE_AXIS(AXIS) - #define E_AXIS_INIT(NUM) AXIS_INIT(E## NUM, E) + #define E_AXIS_INIT(NUM) DEFER(AXIS_INIT)(E##NUM, E) // Init Step Pins #if HAS_X_STEP @@ -3167,49 +3133,21 @@ void Stepper::init() { #endif AXIS_INIT(Z, Z); #endif - #if HAS_I_STEP - AXIS_INIT(I, I); - #endif - #if HAS_J_STEP - AXIS_INIT(J, J); - #endif - #if HAS_K_STEP - AXIS_INIT(K, K); - #endif - #if HAS_U_STEP - AXIS_INIT(U, U); - #endif - #if HAS_V_STEP - AXIS_INIT(V, V); - #endif - #if HAS_W_STEP - AXIS_INIT(W, W); - #endif + TERN_(HAS_I_STEP, AXIS_INIT(I, I)); + TERN_(HAS_J_STEP, AXIS_INIT(J, J)); + TERN_(HAS_K_STEP, AXIS_INIT(K, K)); + TERN_(HAS_U_STEP, AXIS_INIT(U, U)); + TERN_(HAS_V_STEP, AXIS_INIT(V, V)); + TERN_(HAS_W_STEP, AXIS_INIT(W, W)); - #if E_STEPPERS && HAS_E0_STEP - E_AXIS_INIT(0); - #endif - #if (E_STEPPERS > 1 || ENABLED(E_DUAL_STEPPER_DRIVERS)) && HAS_E1_STEP - E_AXIS_INIT(1); - #endif - #if E_STEPPERS > 2 && HAS_E2_STEP - E_AXIS_INIT(2); - #endif - #if E_STEPPERS > 3 && HAS_E3_STEP - E_AXIS_INIT(3); - #endif - #if E_STEPPERS > 4 && HAS_E4_STEP - E_AXIS_INIT(4); - #endif - #if E_STEPPERS > 5 && HAS_E5_STEP - E_AXIS_INIT(5); - #endif - #if E_STEPPERS > 6 && HAS_E6_STEP - E_AXIS_INIT(6); - #endif - #if E_STEPPERS > 7 && HAS_E7_STEP - E_AXIS_INIT(7); - #endif + TERN_(HAS_E0_STEP, E_AXIS_INIT(0)); + TERN_(HAS_E1_STEP, E_AXIS_INIT(1)); + TERN_(HAS_E2_STEP, E_AXIS_INIT(2)); + TERN_(HAS_E3_STEP, E_AXIS_INIT(3)); + TERN_(HAS_E4_STEP, E_AXIS_INIT(4)); + TERN_(HAS_E5_STEP, E_AXIS_INIT(5)); + TERN_(HAS_E6_STEP, E_AXIS_INIT(6)); + TERN_(HAS_E7_STEP, E_AXIS_INIT(7)); #if DISABLED(I2S_STEPPER_STREAM) HAL_timer_start(MF_TIMER_STEP, 122); // Init Stepper ISR to 122 Hz for quick starting diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index 4c83cbd6a6..d18fe830cc 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -810,48 +810,24 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #endif #ifndef ENABLE_STEPPER_U - #if HAS_U_ENABLE - #define ENABLE_STEPPER_U() U_ENABLE_WRITE( U_ENABLE_ON) - #else - #define ENABLE_STEPPER_U() NOOP - #endif + #define ENABLE_STEPPER_U() TERN(HAS_U_ENABLE, U_ENABLE_WRITE( U_ENABLE_ON), NOOP) #endif #ifndef DISABLE_STEPPER_U - #if HAS_U_ENABLE - #define DISABLE_STEPPER_U() U_ENABLE_WRITE(!U_ENABLE_ON) - #else - #define DISABLE_STEPPER_U() NOOP - #endif + #define DISABLE_STEPPER_U() TERN(HAS_U_ENABLE, U_ENABLE_WRITE(!U_ENABLE_ON), NOOP) #endif #ifndef ENABLE_STEPPER_V - #if HAS_V_ENABLE - #define ENABLE_STEPPER_V() V_ENABLE_WRITE( V_ENABLE_ON) - #else - #define ENABLE_STEPPER_V() NOOP - #endif + #define ENABLE_STEPPER_V() TERN(HAS_V_ENABLE, V_ENABLE_WRITE( V_ENABLE_ON), NOOP) #endif #ifndef DISABLE_STEPPER_V - #if HAS_V_ENABLE - #define DISABLE_STEPPER_V() V_ENABLE_WRITE(!V_ENABLE_ON) - #else - #define DISABLE_STEPPER_V() NOOP - #endif + #define DISABLE_STEPPER_V() TERN(HAS_V_ENABLE, V_ENABLE_WRITE(!V_ENABLE_ON), NOOP) #endif #ifndef ENABLE_STEPPER_W - #if HAS_W_ENABLE - #define ENABLE_STEPPER_W() W_ENABLE_WRITE( W_ENABLE_ON) - #else - #define ENABLE_STEPPER_W() NOOP - #endif + #define ENABLE_STEPPER_W() TERN(HAS_W_ENABLE, W_ENABLE_WRITE( W_ENABLE_ON), NOOP) #endif #ifndef DISABLE_STEPPER_W - #if HAS_W_ENABLE - #define DISABLE_STEPPER_W() W_ENABLE_WRITE(!W_ENABLE_ON) - #else - #define DISABLE_STEPPER_W() NOOP - #endif + #define DISABLE_STEPPER_W() TERN(HAS_W_ENABLE, W_ENABLE_WRITE(!W_ENABLE_ON), NOOP) #endif #ifndef ENABLE_STEPPER_E0 @@ -877,93 +853,45 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #endif #ifndef ENABLE_STEPPER_E2 - #if E_STEPPERS > 2 && HAS_E2_ENABLE - #define ENABLE_STEPPER_E2() E2_ENABLE_WRITE( E_ENABLE_ON) - #else - #define ENABLE_STEPPER_E2() NOOP - #endif + #define ENABLE_STEPPER_E2() TERN(HAS_E2_ENABLE, E2_ENABLE_WRITE( E_ENABLE_ON), NOOP) #endif #ifndef DISABLE_STEPPER_E2 - #if E_STEPPERS > 2 && HAS_E2_ENABLE - #define DISABLE_STEPPER_E2() E2_ENABLE_WRITE(!E_ENABLE_ON) - #else - #define DISABLE_STEPPER_E2() NOOP - #endif + #define DISABLE_STEPPER_E2() TERN(HAS_E2_ENABLE, E2_ENABLE_WRITE(!E_ENABLE_ON), NOOP) #endif #ifndef ENABLE_STEPPER_E3 - #if E_STEPPERS > 3 && HAS_E3_ENABLE - #define ENABLE_STEPPER_E3() E3_ENABLE_WRITE( E_ENABLE_ON) - #else - #define ENABLE_STEPPER_E3() NOOP - #endif + #define ENABLE_STEPPER_E3() TERN(HAS_E3_ENABLE, E3_ENABLE_WRITE( E_ENABLE_ON), NOOP) #endif #ifndef DISABLE_STEPPER_E3 - #if E_STEPPERS > 3 && HAS_E3_ENABLE - #define DISABLE_STEPPER_E3() E3_ENABLE_WRITE(!E_ENABLE_ON) - #else - #define DISABLE_STEPPER_E3() NOOP - #endif + #define DISABLE_STEPPER_E3() TERN(HAS_E3_ENABLE, E3_ENABLE_WRITE(!E_ENABLE_ON), NOOP) #endif #ifndef ENABLE_STEPPER_E4 - #if E_STEPPERS > 4 && HAS_E4_ENABLE - #define ENABLE_STEPPER_E4() E4_ENABLE_WRITE( E_ENABLE_ON) - #else - #define ENABLE_STEPPER_E4() NOOP - #endif + #define ENABLE_STEPPER_E4() TERN(HAS_E4_ENABLE, E4_ENABLE_WRITE( E_ENABLE_ON), NOOP) #endif #ifndef DISABLE_STEPPER_E4 - #if E_STEPPERS > 4 && HAS_E4_ENABLE - #define DISABLE_STEPPER_E4() E4_ENABLE_WRITE(!E_ENABLE_ON) - #else - #define DISABLE_STEPPER_E4() NOOP - #endif + #define DISABLE_STEPPER_E4() TERN(HAS_E4_ENABLE, E4_ENABLE_WRITE(!E_ENABLE_ON), NOOP) #endif #ifndef ENABLE_STEPPER_E5 - #if E_STEPPERS > 5 && HAS_E5_ENABLE - #define ENABLE_STEPPER_E5() E5_ENABLE_WRITE( E_ENABLE_ON) - #else - #define ENABLE_STEPPER_E5() NOOP - #endif + #define ENABLE_STEPPER_E5() TERN(HAS_E5_ENABLE, E5_ENABLE_WRITE( E_ENABLE_ON), NOOP) #endif #ifndef DISABLE_STEPPER_E5 - #if E_STEPPERS > 5 && HAS_E5_ENABLE - #define DISABLE_STEPPER_E5() E5_ENABLE_WRITE(!E_ENABLE_ON) - #else - #define DISABLE_STEPPER_E5() NOOP - #endif + #define DISABLE_STEPPER_E5() TERN(HAS_E5_ENABLE, E5_ENABLE_WRITE(!E_ENABLE_ON), NOOP) #endif #ifndef ENABLE_STEPPER_E6 - #if E_STEPPERS > 6 && HAS_E6_ENABLE - #define ENABLE_STEPPER_E6() E6_ENABLE_WRITE( E_ENABLE_ON) - #else - #define ENABLE_STEPPER_E6() NOOP - #endif + #define ENABLE_STEPPER_E6() TERN(HAS_E6_ENABLE, E6_ENABLE_WRITE( E_ENABLE_ON), NOOP) #endif #ifndef DISABLE_STEPPER_E6 - #if E_STEPPERS > 6 && HAS_E6_ENABLE - #define DISABLE_STEPPER_E6() E6_ENABLE_WRITE(!E_ENABLE_ON) - #else - #define DISABLE_STEPPER_E6() NOOP - #endif + #define DISABLE_STEPPER_E6() TERN(HAS_E6_ENABLE, E6_ENABLE_WRITE(!E_ENABLE_ON), NOOP) #endif #ifndef ENABLE_STEPPER_E7 - #if E_STEPPERS > 7 && HAS_E7_ENABLE - #define ENABLE_STEPPER_E7() E7_ENABLE_WRITE( E_ENABLE_ON) - #else - #define ENABLE_STEPPER_E7() NOOP - #endif + #define ENABLE_STEPPER_E7() TERN(HAS_E7_ENABLE, E7_ENABLE_WRITE( E_ENABLE_ON), NOOP) #endif #ifndef DISABLE_STEPPER_E7 - #if E_STEPPERS > 7 && HAS_E7_ENABLE - #define DISABLE_STEPPER_E7() E7_ENABLE_WRITE(!E_ENABLE_ON) - #else - #define DISABLE_STEPPER_E7() NOOP - #endif + #define DISABLE_STEPPER_E7() TERN(HAS_E7_ENABLE, E7_ENABLE_WRITE(!E_ENABLE_ON), NOOP) #endif // @@ -1077,121 +1005,57 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #endif #ifndef ENABLE_AXIS_E0 - #if E_STEPPERS && HAS_E0_ENABLE - #define ENABLE_AXIS_E0() ENABLE_STEPPER_E0() - #else - #define ENABLE_AXIS_E0() NOOP - #endif + #define ENABLE_AXIS_E0() TERN(HAS_E0_ENABLE, ENABLE_STEPPER_E0(), NOOP) #endif #ifndef DISABLE_AXIS_E0 - #if E_STEPPERS && HAS_E0_ENABLE - #define DISABLE_AXIS_E0() DISABLE_STEPPER_E0() - #else - #define DISABLE_AXIS_E0() NOOP - #endif + #define DISABLE_AXIS_E0() TERN(HAS_E0_ENABLE, DISABLE_STEPPER_E0(), NOOP) #endif #ifndef ENABLE_AXIS_E1 - #if E_STEPPERS > 1 && HAS_E1_ENABLE - #define ENABLE_AXIS_E1() ENABLE_STEPPER_E1() - #else - #define ENABLE_AXIS_E1() NOOP - #endif + #define ENABLE_AXIS_E1() TERN(HAS_E1_ENABLE, ENABLE_STEPPER_E1(), NOOP) #endif #ifndef DISABLE_AXIS_E1 - #if E_STEPPERS > 1 && HAS_E1_ENABLE - #define DISABLE_AXIS_E1() DISABLE_STEPPER_E1() - #else - #define DISABLE_AXIS_E1() NOOP - #endif + #define DISABLE_AXIS_E1() TERN(HAS_E1_ENABLE, DISABLE_STEPPER_E1(), NOOP) #endif #ifndef ENABLE_AXIS_E2 - #if E_STEPPERS > 2 && HAS_E2_ENABLE - #define ENABLE_AXIS_E2() ENABLE_STEPPER_E2() - #else - #define ENABLE_AXIS_E2() NOOP - #endif + #define ENABLE_AXIS_E2() TERN(HAS_E2_ENABLE, ENABLE_STEPPER_E2(), NOOP) #endif #ifndef DISABLE_AXIS_E2 - #if E_STEPPERS > 2 && HAS_E2_ENABLE - #define DISABLE_AXIS_E2() DISABLE_STEPPER_E2() - #else - #define DISABLE_AXIS_E2() NOOP - #endif + #define DISABLE_AXIS_E2() TERN(HAS_E2_ENABLE, DISABLE_STEPPER_E2(), NOOP) #endif #ifndef ENABLE_AXIS_E3 - #if E_STEPPERS > 3 && HAS_E3_ENABLE - #define ENABLE_AXIS_E3() ENABLE_STEPPER_E3() - #else - #define ENABLE_AXIS_E3() NOOP - #endif + #define ENABLE_AXIS_E3() TERN(HAS_E3_ENABLE, ENABLE_STEPPER_E3(), NOOP) #endif #ifndef DISABLE_AXIS_E3 - #if E_STEPPERS > 3 && HAS_E3_ENABLE - #define DISABLE_AXIS_E3() DISABLE_STEPPER_E3() - #else - #define DISABLE_AXIS_E3() NOOP - #endif + #define DISABLE_AXIS_E3() TERN(HAS_E3_ENABLE, DISABLE_STEPPER_E3(), NOOP) #endif #ifndef ENABLE_AXIS_E4 - #if E_STEPPERS > 4 && HAS_E4_ENABLE - #define ENABLE_AXIS_E4() ENABLE_STEPPER_E4() - #else - #define ENABLE_AXIS_E4() NOOP - #endif + #define ENABLE_AXIS_E4() TERN(HAS_E4_ENABLE, ENABLE_STEPPER_E4(), NOOP) #endif #ifndef DISABLE_AXIS_E4 - #if E_STEPPERS > 4 && HAS_E4_ENABLE - #define DISABLE_AXIS_E4() DISABLE_STEPPER_E4() - #else - #define DISABLE_AXIS_E4() NOOP - #endif + #define DISABLE_AXIS_E4() TERN(HAS_E4_ENABLE, DISABLE_STEPPER_E4(), NOOP) #endif #ifndef ENABLE_AXIS_E5 - #if E_STEPPERS > 5 && HAS_E5_ENABLE - #define ENABLE_AXIS_E5() ENABLE_STEPPER_E5() - #else - #define ENABLE_AXIS_E5() NOOP - #endif + #define ENABLE_AXIS_E5() TERN(HAS_E5_ENABLE, ENABLE_STEPPER_E5(), NOOP) #endif #ifndef DISABLE_AXIS_E5 - #if E_STEPPERS > 5 && HAS_E5_ENABLE - #define DISABLE_AXIS_E5() DISABLE_STEPPER_E5() - #else - #define DISABLE_AXIS_E5() NOOP - #endif + #define DISABLE_AXIS_E5() TERN(HAS_E5_ENABLE, DISABLE_STEPPER_E5(), NOOP) #endif #ifndef ENABLE_AXIS_E6 - #if E_STEPPERS > 6 && HAS_E6_ENABLE - #define ENABLE_AXIS_E6() ENABLE_STEPPER_E6() - #else - #define ENABLE_AXIS_E6() NOOP - #endif + #define ENABLE_AXIS_E6() TERN(HAS_E6_ENABLE, ENABLE_STEPPER_E6(), NOOP) #endif #ifndef DISABLE_AXIS_E6 - #if E_STEPPERS > 6 && HAS_E6_ENABLE - #define DISABLE_AXIS_E6() DISABLE_STEPPER_E6() - #else - #define DISABLE_AXIS_E6() NOOP - #endif + #define DISABLE_AXIS_E6() TERN(HAS_E6_ENABLE, DISABLE_STEPPER_E6(), NOOP) #endif #ifndef ENABLE_AXIS_E7 - #if E_STEPPERS > 7 && HAS_E7_ENABLE - #define ENABLE_AXIS_E7() ENABLE_STEPPER_E7() - #else - #define ENABLE_AXIS_E7() NOOP - #endif + #define ENABLE_AXIS_E7() TERN(HAS_E7_ENABLE, ENABLE_STEPPER_E7(), NOOP) #endif #ifndef DISABLE_AXIS_E7 - #if E_STEPPERS > 7 && HAS_E7_ENABLE - #define DISABLE_AXIS_E7() DISABLE_STEPPER_E7() - #else - #define DISABLE_AXIS_E7() NOOP - #endif + #define DISABLE_AXIS_E7() TERN(HAS_E7_ENABLE, DISABLE_STEPPER_E7(), NOOP) #endif diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index c0fb083d61..3ec8ff4325 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -847,72 +847,28 @@ enum StealthIndex : uint8_t { #endif // TMC5160 void restore_trinamic_drivers() { - #if AXIS_IS_TMC(X) - stepperX.push(); - #endif - #if AXIS_IS_TMC(X2) - stepperX2.push(); - #endif - #if AXIS_IS_TMC(Y) - stepperY.push(); - #endif - #if AXIS_IS_TMC(Y2) - stepperY2.push(); - #endif - #if AXIS_IS_TMC(Z) - stepperZ.push(); - #endif - #if AXIS_IS_TMC(Z2) - stepperZ2.push(); - #endif - #if AXIS_IS_TMC(Z3) - stepperZ3.push(); - #endif - #if AXIS_IS_TMC(Z4) - stepperZ4.push(); - #endif - #if AXIS_IS_TMC(I) - stepperI.push(); - #endif - #if AXIS_IS_TMC(J) - stepperJ.push(); - #endif - #if AXIS_IS_TMC(K) - stepperK.push(); - #endif - #if AXIS_IS_TMC(U) - stepperU.push(); - #endif - #if AXIS_IS_TMC(V) - stepperV.push(); - #endif - #if AXIS_IS_TMC(W) - stepperW.push(); - #endif - #if AXIS_IS_TMC(E0) - stepperE0.push(); - #endif - #if AXIS_IS_TMC(E1) - stepperE1.push(); - #endif - #if AXIS_IS_TMC(E2) - stepperE2.push(); - #endif - #if AXIS_IS_TMC(E3) - stepperE3.push(); - #endif - #if AXIS_IS_TMC(E4) - stepperE4.push(); - #endif - #if AXIS_IS_TMC(E5) - stepperE5.push(); - #endif - #if AXIS_IS_TMC(E6) - stepperE6.push(); - #endif - #if AXIS_IS_TMC(E7) - stepperE7.push(); - #endif + TERN_(X_IS_TRINAMIC, stepperX.push()); + TERN_(X2_IS_TRINAMIC, stepperX2.push()); + TERN_(Y_IS_TRINAMIC, stepperY.push()); + TERN_(Y2_IS_TRINAMIC, stepperY2.push()); + TERN_(Z_IS_TRINAMIC, stepperZ.push()); + TERN_(Z2_IS_TRINAMIC, stepperZ2.push()); + TERN_(Z3_IS_TRINAMIC, stepperZ3.push()); + TERN_(Z4_IS_TRINAMIC, stepperZ4.push()); + TERN_(I_IS_TRINAMIC, stepperI.push()); + TERN_(J_IS_TRINAMIC, stepperJ.push()); + TERN_(K_IS_TRINAMIC, stepperK.push()); + TERN_(U_IS_TRINAMIC, stepperU.push()); + TERN_(V_IS_TRINAMIC, stepperV.push()); + TERN_(W_IS_TRINAMIC, stepperW.push()); + TERN_(E0_IS_TRINAMIC, stepperE0.push()); + TERN_(E1_IS_TRINAMIC, stepperE1.push()); + TERN_(E2_IS_TRINAMIC, stepperE2.push()); + TERN_(E3_IS_TRINAMIC, stepperE3.push()); + TERN_(E4_IS_TRINAMIC, stepperE4.push()); + TERN_(E5_IS_TRINAMIC, stepperE5.push()); + TERN_(E6_IS_TRINAMIC, stepperE6.push()); + TERN_(E7_IS_TRINAMIC, stepperE7.push()); } void reset_trinamic_drivers() { @@ -923,88 +879,44 @@ void reset_trinamic_drivers() { ENABLED(STEALTHCHOP_U), ENABLED(STEALTHCHOP_V), ENABLED(STEALTHCHOP_W) ); - #if AXIS_IS_TMC(X) - TMC_INIT(X, STEALTH_AXIS_X); - #endif - #if AXIS_IS_TMC(X2) - TMC_INIT(X2, STEALTH_AXIS_X); - #endif - #if AXIS_IS_TMC(Y) - TMC_INIT(Y, STEALTH_AXIS_Y); - #endif - #if AXIS_IS_TMC(Y2) - TMC_INIT(Y2, STEALTH_AXIS_Y); - #endif - #if AXIS_IS_TMC(Z) - TMC_INIT(Z, STEALTH_AXIS_Z); - #endif - #if AXIS_IS_TMC(Z2) - TMC_INIT(Z2, STEALTH_AXIS_Z); - #endif - #if AXIS_IS_TMC(Z3) - TMC_INIT(Z3, STEALTH_AXIS_Z); - #endif - #if AXIS_IS_TMC(Z4) - TMC_INIT(Z4, STEALTH_AXIS_Z); - #endif - #if AXIS_IS_TMC(I) - TMC_INIT(I, STEALTH_AXIS_I); - #endif - #if AXIS_IS_TMC(J) - TMC_INIT(J, STEALTH_AXIS_J); - #endif - #if AXIS_IS_TMC(K) - TMC_INIT(K, STEALTH_AXIS_K); - #endif - #if AXIS_IS_TMC(U) - TMC_INIT(U, STEALTH_AXIS_U); - #endif - #if AXIS_IS_TMC(V) - TMC_INIT(V, STEALTH_AXIS_V); - #endif - #if AXIS_IS_TMC(W) - TMC_INIT(W, STEALTH_AXIS_W); - #endif - #if AXIS_IS_TMC(E0) - TMC_INIT(E0, STEALTH_AXIS_E); - #endif - #if AXIS_IS_TMC(E1) - TMC_INIT(E1, STEALTH_AXIS_E); - #endif - #if AXIS_IS_TMC(E2) - TMC_INIT(E2, STEALTH_AXIS_E); - #endif - #if AXIS_IS_TMC(E3) - TMC_INIT(E3, STEALTH_AXIS_E); - #endif - #if AXIS_IS_TMC(E4) - TMC_INIT(E4, STEALTH_AXIS_E); - #endif - #if AXIS_IS_TMC(E5) - TMC_INIT(E5, STEALTH_AXIS_E); - #endif - #if AXIS_IS_TMC(E6) - TMC_INIT(E6, STEALTH_AXIS_E); - #endif - #if AXIS_IS_TMC(E7) - TMC_INIT(E7, STEALTH_AXIS_E); - #endif + TERN_(X_IS_TRINAMIC, TMC_INIT(X, STEALTH_AXIS_X)); + TERN_(X2_IS_TRINAMIC, TMC_INIT(X2, STEALTH_AXIS_X)); + TERN_(Y_IS_TRINAMIC, TMC_INIT(Y, STEALTH_AXIS_Y)); + TERN_(Y2_IS_TRINAMIC, TMC_INIT(Y2, STEALTH_AXIS_Y)); + TERN_(Z_IS_TRINAMIC, TMC_INIT(Z, STEALTH_AXIS_Z)); + TERN_(Z2_IS_TRINAMIC, TMC_INIT(Z2, STEALTH_AXIS_Z)); + TERN_(Z3_IS_TRINAMIC, TMC_INIT(Z3, STEALTH_AXIS_Z)); + TERN_(Z4_IS_TRINAMIC, TMC_INIT(Z4, STEALTH_AXIS_Z)); + TERN_(I_IS_TRINAMIC, TMC_INIT(I, STEALTH_AXIS_I)); + TERN_(J_IS_TRINAMIC, TMC_INIT(J, STEALTH_AXIS_J)); + TERN_(K_IS_TRINAMIC, TMC_INIT(K, STEALTH_AXIS_K)); + TERN_(U_IS_TRINAMIC, TMC_INIT(U, STEALTH_AXIS_U)); + TERN_(V_IS_TRINAMIC, TMC_INIT(V, STEALTH_AXIS_V)); + TERN_(W_IS_TRINAMIC, TMC_INIT(W, STEALTH_AXIS_W)); + TERN_(E0_IS_TRINAMIC, TMC_INIT(E0, STEALTH_AXIS_E)); + TERN_(E1_IS_TRINAMIC, TMC_INIT(E1, STEALTH_AXIS_E)); + TERN_(E2_IS_TRINAMIC, TMC_INIT(E2, STEALTH_AXIS_E)); + TERN_(E3_IS_TRINAMIC, TMC_INIT(E3, STEALTH_AXIS_E)); + TERN_(E4_IS_TRINAMIC, TMC_INIT(E4, STEALTH_AXIS_E)); + TERN_(E5_IS_TRINAMIC, TMC_INIT(E5, STEALTH_AXIS_E)); + TERN_(E6_IS_TRINAMIC, TMC_INIT(E6, STEALTH_AXIS_E)); + TERN_(E7_IS_TRINAMIC, TMC_INIT(E7, STEALTH_AXIS_E)); #if USE_SENSORLESS - TERN_(X_SENSORLESS, stepperX.homing_threshold(X_STALL_SENSITIVITY)); + TERN_(X_SENSORLESS, stepperX.homing_threshold(X_STALL_SENSITIVITY)); TERN_(X2_SENSORLESS, stepperX2.homing_threshold(X2_STALL_SENSITIVITY)); - TERN_(Y_SENSORLESS, stepperY.homing_threshold(Y_STALL_SENSITIVITY)); + TERN_(Y_SENSORLESS, stepperY.homing_threshold(Y_STALL_SENSITIVITY)); TERN_(Y2_SENSORLESS, stepperY2.homing_threshold(Y2_STALL_SENSITIVITY)); - TERN_(Z_SENSORLESS, stepperZ.homing_threshold(Z_STALL_SENSITIVITY)); + TERN_(Z_SENSORLESS, stepperZ.homing_threshold(Z_STALL_SENSITIVITY)); TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(Z2_STALL_SENSITIVITY)); TERN_(Z3_SENSORLESS, stepperZ3.homing_threshold(Z3_STALL_SENSITIVITY)); TERN_(Z4_SENSORLESS, stepperZ4.homing_threshold(Z4_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)); - TERN_(U_SENSORLESS, stepperU.homing_threshold(U_STALL_SENSITIVITY)); - TERN_(V_SENSORLESS, stepperV.homing_threshold(V_STALL_SENSITIVITY)); - TERN_(W_SENSORLESS, stepperW.homing_threshold(W_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)); + TERN_(U_SENSORLESS, stepperU.homing_threshold(U_STALL_SENSITIVITY)); + TERN_(V_SENSORLESS, stepperV.homing_threshold(V_STALL_SENSITIVITY)); + TERN_(W_SENSORLESS, stepperW.homing_threshold(W_STALL_SENSITIVITY)); #endif #ifdef TMC_ADV diff --git a/Marlin/src/module/stepper/trinamic.h b/Marlin/src/module/stepper/trinamic.h index bf7eaf7f95..0fd48f18cb 100644 --- a/Marlin/src/module/stepper/trinamic.h +++ b/Marlin/src/module/stepper/trinamic.h @@ -116,7 +116,7 @@ void restore_trinamic_drivers(); void reset_trinamic_drivers(); // X Stepper -#if AXIS_IS_TMC(X) +#if X_IS_TRINAMIC extern TMC_CLASS(X, X) stepperX; static constexpr chopper_timing_t chopper_timing_X = CHOPPER_TIMING_X; #if ENABLED(SOFTWARE_DRIVER_ENABLE) @@ -130,7 +130,7 @@ void reset_trinamic_drivers(); #endif // Y Stepper -#if AXIS_IS_TMC(Y) +#if Y_IS_TRINAMIC extern TMC_CLASS(Y, Y) stepperY; static constexpr chopper_timing_t chopper_timing_Y = CHOPPER_TIMING_Y; #if ENABLED(SOFTWARE_DRIVER_ENABLE) @@ -144,7 +144,7 @@ void reset_trinamic_drivers(); #endif // Z Stepper -#if AXIS_IS_TMC(Z) +#if Z_IS_TRINAMIC extern TMC_CLASS(Z, Z) stepperZ; static constexpr chopper_timing_t chopper_timing_Z = CHOPPER_TIMING_Z; #if ENABLED(SOFTWARE_DRIVER_ENABLE) @@ -158,7 +158,7 @@ void reset_trinamic_drivers(); #endif // X2 Stepper -#if HAS_X2_ENABLE && AXIS_IS_TMC(X2) +#if X2_IS_TRINAMIC extern TMC_CLASS(X2, X) stepperX2; #ifndef CHOPPER_TIMING_X2 #define CHOPPER_TIMING_X2 CHOPPER_TIMING_X @@ -175,7 +175,7 @@ void reset_trinamic_drivers(); #endif // Y2 Stepper -#if HAS_Y2_ENABLE && AXIS_IS_TMC(Y2) +#if Y2_IS_TRINAMIC extern TMC_CLASS(Y2, Y) stepperY2; #ifndef CHOPPER_TIMING_Y2 #define CHOPPER_TIMING_Y2 CHOPPER_TIMING_Y @@ -192,7 +192,7 @@ void reset_trinamic_drivers(); #endif // Z2 Stepper -#if HAS_Z2_ENABLE && AXIS_IS_TMC(Z2) +#if Z2_IS_TRINAMIC extern TMC_CLASS(Z2, Z) stepperZ2; #ifndef CHOPPER_TIMING_Z2 #define CHOPPER_TIMING_Z2 CHOPPER_TIMING_Z @@ -209,7 +209,7 @@ void reset_trinamic_drivers(); #endif // Z3 Stepper -#if HAS_Z3_ENABLE && AXIS_IS_TMC(Z3) +#if Z3_IS_TRINAMIC extern TMC_CLASS(Z3, Z) stepperZ3; #ifndef CHOPPER_TIMING_Z3 #define CHOPPER_TIMING_Z3 CHOPPER_TIMING_Z @@ -226,7 +226,7 @@ void reset_trinamic_drivers(); #endif // Z4 Stepper -#if HAS_Z4_ENABLE && AXIS_IS_TMC(Z4) +#if Z4_IS_TRINAMIC extern TMC_CLASS(Z4, Z) stepperZ4; #ifndef CHOPPER_TIMING_Z4 #define CHOPPER_TIMING_Z4 CHOPPER_TIMING_Z @@ -243,7 +243,7 @@ void reset_trinamic_drivers(); #endif // I Stepper -#if AXIS_IS_TMC(I) +#if I_IS_TRINAMIC extern TMC_CLASS(I, I) stepperI; static constexpr chopper_timing_t chopper_timing_I = CHOPPER_TIMING_I; #if ENABLED(SOFTWARE_DRIVER_ENABLE) @@ -257,7 +257,7 @@ void reset_trinamic_drivers(); #endif // J Stepper -#if AXIS_IS_TMC(J) +#if J_IS_TRINAMIC extern TMC_CLASS(J, J) stepperJ; static constexpr chopper_timing_t chopper_timing_J = CHOPPER_TIMING_J; #if ENABLED(SOFTWARE_DRIVER_ENABLE) @@ -271,7 +271,7 @@ void reset_trinamic_drivers(); #endif // K Stepper -#if AXIS_IS_TMC(K) +#if K_IS_TRINAMIC extern TMC_CLASS(K, K) stepperK; static constexpr chopper_timing_t chopper_timing_K = CHOPPER_TIMING_K; #if ENABLED(SOFTWARE_DRIVER_ENABLE) @@ -285,7 +285,7 @@ void reset_trinamic_drivers(); #endif // U Stepper -#if AXIS_IS_TMC(U) +#if U_IS_TRINAMIC extern TMC_CLASS(U, U) stepperU; static constexpr chopper_timing_t chopper_timing_U = CHOPPER_TIMING_U; #if ENABLED(SOFTWARE_DRIVER_ENABLE) @@ -299,7 +299,7 @@ void reset_trinamic_drivers(); #endif // V Stepper -#if AXIS_IS_TMC(V) +#if V_IS_TRINAMIC extern TMC_CLASS(V, V) stepperV; static constexpr chopper_timing_t chopper_timing_V = CHOPPER_TIMING_V; #if ENABLED(SOFTWARE_DRIVER_ENABLE) @@ -313,7 +313,7 @@ void reset_trinamic_drivers(); #endif // W Stepper -#if AXIS_IS_TMC(W) +#if W_IS_TRINAMIC extern TMC_CLASS(W, W) stepperW; static constexpr chopper_timing_t chopper_timing_W = CHOPPER_TIMING_W; #if ENABLED(SOFTWARE_DRIVER_ENABLE) @@ -327,7 +327,7 @@ void reset_trinamic_drivers(); #endif // E0 Stepper -#if AXIS_IS_TMC(E0) +#if E0_IS_TRINAMIC extern TMC_CLASS_E(0) stepperE0; #ifndef CHOPPER_TIMING_E0 #define CHOPPER_TIMING_E0 CHOPPER_TIMING_E @@ -344,7 +344,7 @@ void reset_trinamic_drivers(); #endif // E1 Stepper -#if AXIS_IS_TMC(E1) +#if E1_IS_TRINAMIC extern TMC_CLASS_E(1) stepperE1; #ifndef CHOPPER_TIMING_E1 #define CHOPPER_TIMING_E1 CHOPPER_TIMING_E @@ -361,7 +361,7 @@ void reset_trinamic_drivers(); #endif // E2 Stepper -#if AXIS_IS_TMC(E2) +#if E2_IS_TRINAMIC extern TMC_CLASS_E(2) stepperE2; #ifndef CHOPPER_TIMING_E2 #define CHOPPER_TIMING_E2 CHOPPER_TIMING_E @@ -378,7 +378,7 @@ void reset_trinamic_drivers(); #endif // E3 Stepper -#if AXIS_IS_TMC(E3) +#if E3_IS_TRINAMIC extern TMC_CLASS_E(3) stepperE3; #ifndef CHOPPER_TIMING_E3 #define CHOPPER_TIMING_E3 CHOPPER_TIMING_E @@ -395,7 +395,7 @@ void reset_trinamic_drivers(); #endif // E4 Stepper -#if AXIS_IS_TMC(E4) +#if E4_IS_TRINAMIC extern TMC_CLASS_E(4) stepperE4; #ifndef CHOPPER_TIMING_E4 #define CHOPPER_TIMING_E4 CHOPPER_TIMING_E @@ -412,7 +412,7 @@ void reset_trinamic_drivers(); #endif // E5 Stepper -#if AXIS_IS_TMC(E5) +#if E5_IS_TRINAMIC extern TMC_CLASS_E(5) stepperE5; #ifndef CHOPPER_TIMING_E5 #define CHOPPER_TIMING_E5 CHOPPER_TIMING_E @@ -429,7 +429,7 @@ void reset_trinamic_drivers(); #endif // E6 Stepper -#if AXIS_IS_TMC(E6) +#if E6_IS_TRINAMIC extern TMC_CLASS_E(6) stepperE6; #ifndef CHOPPER_TIMING_E6 #define CHOPPER_TIMING_E6 CHOPPER_TIMING_E @@ -446,7 +446,7 @@ void reset_trinamic_drivers(); #endif // E7 Stepper -#if AXIS_IS_TMC(E7) +#if E7_IS_TRINAMIC extern TMC_CLASS_E(7) stepperE7; #ifndef CHOPPER_TIMING_E7 #define CHOPPER_TIMING_E7 CHOPPER_TIMING_E