diff --git a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp index 800915ff69..5cf86f147c 100644 --- a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp +++ b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp @@ -61,7 +61,7 @@ #else #define G2_PWM_Z 0 #endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_E) +#if HAS_MOTOR_CURRENT_PWM_E #define G2_PWM_E 1 #else #define G2_PWM_E 0 diff --git a/Marlin/src/gcode/feature/digipot/M907-M910.cpp b/Marlin/src/gcode/feature/digipot/M907-M910.cpp index e36cf76e88..ab1c316705 100644 --- a/Marlin/src/gcode/feature/digipot/M907-M910.cpp +++ b/Marlin/src/gcode/feature/digipot/M907-M910.cpp @@ -68,7 +68,7 @@ void GcodeSuite::M907() { #define HAS_X_Y_XY_I_J_K_U_V_W 1 #endif - #if HAS_X_Y_XY_I_J_K_U_V_W || ANY_PIN(MOTOR_CURRENT_PWM_E, MOTOR_CURRENT_PWM_Z) + #if HAS_X_Y_XY_I_J_K_U_V_W || HAS_MOTOR_CURRENT_PWM_E || PIN_EXISTS(MOTOR_CURRENT_PWM_Z) if (!parser.seen("S" #if HAS_X_Y_XY_I_J_K_U_V_W @@ -77,7 +77,7 @@ void GcodeSuite::M907() { #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) "Z" #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + #if HAS_MOTOR_CURRENT_PWM_E "E" #endif )) return M907_report(); @@ -94,7 +94,7 @@ void GcodeSuite::M907() { #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) if (parser.seenval('Z')) stepper.set_digipot_current(1, parser.value_int()); #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + #if HAS_MOTOR_CURRENT_PWM_E if (parser.seenval('E')) stepper.set_digipot_current(2, parser.value_int()); #endif @@ -133,7 +133,7 @@ void GcodeSuite::M907() { SERIAL_ECHOLNPGM_P( // PWM-based has 3 values: PSTR(" M907 X"), stepper.motor_current_setting[0] // X, Y, (I, J, K, U, V, W) , SP_Z_STR, stepper.motor_current_setting[1] // Z - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + #if HAS_MOTOR_CURRENT_PWM_E , SP_E_STR, stepper.motor_current_setting[2] // E #endif ); diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 64c95fa6c4..8446a1acf0 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2814,7 +2814,7 @@ #if PIN_EXISTS(DIGIPOTSS) #define HAS_MOTOR_CURRENT_SPI 1 #endif -#if HAS_EXTRUDERS && PIN_EXISTS(MOTOR_CURRENT_PWM_E) +#if ANY_PIN(MOTOR_CURRENT_PWM_E, MOTOR_CURRENT_PWM_E0, MOTOR_CURRENT_PWM_E1) #define HAS_MOTOR_CURRENT_PWM_E 1 #endif #if HAS_MOTOR_CURRENT_PWM_E || ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z, MOTOR_CURRENT_PWM_I, MOTOR_CURRENT_PWM_J, MOTOR_CURRENT_PWM_K, MOTOR_CURRENT_PWM_U, MOTOR_CURRENT_PWM_V, MOTOR_CURRENT_PWM_W) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 22c0823f26..38d56bf912 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -91,7 +91,7 @@ void menu_backlash(); #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) EDIT_CURRENT_PWM(STR_C, 1); #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + #if HAS_MOTOR_CURRENT_PWM_E EDIT_CURRENT_PWM(STR_E, 2); #endif END_MENU(); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 252bf5526b..3416cda3c0 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -3906,7 +3906,7 @@ void Stepper::report_positions() { #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) case 1: #endif - #if ANY_PIN(MOTOR_CURRENT_PWM_E, MOTOR_CURRENT_PWM_E0, MOTOR_CURRENT_PWM_E1) + #if HAS_MOTOR_CURRENT_PWM_E case 2: #endif set_digipot_current(i, motor_current_setting[i]); @@ -3973,7 +3973,7 @@ void Stepper::report_positions() { #endif break; case 2: - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + #if HAS_MOTOR_CURRENT_PWM_E _WRITE_CURRENT_PWM(E); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) @@ -4036,7 +4036,7 @@ void Stepper::report_positions() { #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) INIT_CURRENT_PWM(Z); #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + #if HAS_MOTOR_CURRENT_PWM_E INIT_CURRENT_PWM(E); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index ac81eb3f25..891076b2db 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -1736,3 +1736,43 @@ #define NEOPIXEL_PIN BOARD_NEOPIXEL_PIN #endif #endif + +// Undefine motor PWM pins for nonexistent axes since the existence of a MOTOR_CURRENT_PWM_*_PIN implies its standard use. +// TODO: Allow remapping (e.g., E => Z2). Spec G-codes to use logical axis with index (e.g., to set Z2: Mxxx Z P1 Snnn). +#if !HAS_X_AXIS + #undef MOTOR_CURRENT_PWM_X_PIN +#endif +#if !HAS_Y_AXIS + #undef MOTOR_CURRENT_PWM_Y_PIN +#endif +#if !HAS_X_AXIS && !HAS_Y_AXIS + #undef MOTOR_CURRENT_PWM_XY_PIN +#endif +#if !HAS_Z_AXIS + #undef MOTOR_CURRENT_PWM_Z_PIN +#endif +#if !HAS_I_AXIS + #undef MOTOR_CURRENT_PWM_I_PIN +#endif +#if !HAS_J_AXIS + #undef MOTOR_CURRENT_PWM_J_PIN +#endif +#if !HAS_K_AXIS + #undef MOTOR_CURRENT_PWM_K_PIN +#endif +#if !HAS_U_AXIS + #undef MOTOR_CURRENT_PWM_U_PIN +#endif +#if !HAS_V_AXIS + #undef MOTOR_CURRENT_PWM_V_PIN +#endif +#if !HAS_W_AXIS + #undef MOTOR_CURRENT_PWM_W_PIN +#endif +#if !HAS_EXTRUDERS + #undef MOTOR_CURRENT_PWM_E_PIN + #undef MOTOR_CURRENT_PWM_E0_PIN // Archim 1.0 + #undef MOTOR_CURRENT_PWM_E1_PIN // Kept in sync with E0 +#elif !HAS_MULTI_EXTRUDER + #undef MOTOR_CURRENT_PWM_E1_PIN +#endif