mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-01-23 01:58:59 +00:00
🔧 Undef motor current PWM for unused axes
This commit is contained in:
parent
dabcea991f
commit
08fe8a3076
6 changed files with 50 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue