diff --git a/Marlin/Conditionals.h b/Marlin/Conditionals.h index 464ead540c..3598dab2da 100644 --- a/Marlin/Conditionals.h +++ b/Marlin/Conditionals.h @@ -513,7 +513,6 @@ #define HAS_BUZZER ((defined(BEEPER) && BEEPER >= 0) || defined(LCD_USE_I2C_BUZZER)) - #if defined( NUM_SERVOS ) && (NUM_SERVOS > 0) #ifndef X_ENDSTOP_SERVO_NR #define X_ENDSTOP_SERVO_NR -1 @@ -527,6 +526,7 @@ #if (X_ENDSTOP_SERVO_NR >= 0) || (Y_ENDSTOP_SERVO_NR >= 0) || (Z_ENDSTOP_SERVO_NR >= 0) #define SERVO_ENDSTOPS {X_ENDSTOP_SERVO_NR, Y_ENDSTOP_SERVO_NR, Z_ENDSTOP_SERVO_NR} #define HAS_SERVO_ENDSTOPS true + #define SERVO_ENDSTOP_IDS { X_ENDSTOP_SERVO_NR, Y_ENDSTOP_SERVO_NR, Z_ENDSTOP_SERVO_NR } #endif #endif diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index ef439efd8a..8282429717 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -314,8 +314,8 @@ bool target_direction; }; #endif - const int servo_endstops[] = SERVO_ENDSTOPS; #if HAS_SERVO_ENDSTOPS + const int servo_endstop_id[] = SERVO_ENDSTOP_IDS; const int servo_endstop_angles[][2] = SERVO_ENDSTOP_ANGLES; #endif @@ -580,8 +580,8 @@ void servo_init() { // Set position of Servo Endstops that are defined #if HAS_SERVO_ENDSTOPS for (int i = 0; i < 3; i++) - if (servo_endstops[i] >= 0) - servo[servo_endstops[i]].move(servo_endstop_angles[i][1]); + if (servo_endstop_id[i] >= 0) + servo[servo_endstop_id[i]].move(servo_endstop_angles[i][1]); #endif } @@ -1325,7 +1325,7 @@ static void setup_for_endstop_move() { #if HAS_SERVO_ENDSTOPS // Engage Z Servo endstop if enabled - if (servo_endstops[Z_AXIS] >= 0) servo[servo_endstops[Z_AXIS]].move(servo_endstop_angles[Z_AXIS][0]); + if (servo_endstop_id[Z_AXIS] >= 0) servo[servo_endstop_id[Z_AXIS]].move(servo_endstop_angles[Z_AXIS][0]); #elif defined(Z_PROBE_ALLEN_KEY) feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE; @@ -1415,7 +1415,7 @@ static void setup_for_endstop_move() { #if HAS_SERVO_ENDSTOPS // Retract Z Servo endstop if enabled - if (servo_endstops[Z_AXIS] >= 0) { + if (servo_endstop_id[Z_AXIS] >= 0) { #if Z_RAISE_AFTER_PROBING > 0 if (doRaise) { @@ -1425,7 +1425,7 @@ static void setup_for_endstop_move() { #endif // Change the Z servo angle - servo[servo_endstops[Z_AXIS]].move(servo_endstop_angles[Z_AXIS][1]); + servo[servo_endstop_id[Z_AXIS]].move(servo_endstop_angles[Z_AXIS][1]); } #elif defined(Z_PROBE_ALLEN_KEY) @@ -1678,8 +1678,8 @@ static void homeaxis(AxisEnum axis) { #if HAS_SERVO_ENDSTOPS // Engage Servo endstop if enabled - if (axis != Z_AXIS && servo_endstops[axis] >= 0) - servo[servo_endstops[axis]].move(servo_endstop_angles[axis][0]); + if (axis != Z_AXIS && servo_endstop_id[axis] >= 0) + servo[servo_endstop_id[axis]].move(servo_endstop_angles[axis][0]); #endif // Set a flag for Z motor locking @@ -1780,8 +1780,8 @@ static void homeaxis(AxisEnum axis) { { #if HAS_SERVO_ENDSTOPS // Retract Servo endstop if enabled - if (servo_endstops[axis] >= 0) - servo[servo_endstops[axis]].move(servo_endstop_angles[axis][1]); + if (servo_endstop_id[axis] >= 0) + servo[servo_endstop_id[axis]].move(servo_endstop_angles[axis][1]); #endif }