From 96ae53cf41fc0f6f6003fc1a5e2a2ddac4f3ac4f Mon Sep 17 00:00:00 2001 From: Scott Lahteine <github@thinkyhead.com> Date: Mon, 14 Aug 2017 23:52:23 -0500 Subject: [PATCH 1/2] Use MOVE_SERVO macro where possible --- Marlin/Marlin_main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index f9db4f49baa..04e5716b2a0 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2102,7 +2102,7 @@ static void clean_up_after_endstop_or_probe_move() { #if ENABLED(BLTOUCH) void bltouch_command(int angle) { - servo[Z_ENDSTOP_SERVO_NR].move(angle); // Give the BL-Touch the command and wait + MOVE_SERVO(Z_ENDSTOP_SERVO_NR, angle); // Give the BL-Touch the command and wait safe_delay(BLTOUCH_DELAY); } @@ -2206,7 +2206,7 @@ static void clean_up_after_endstop_or_probe_move() { #elif HAS_Z_SERVO_ENDSTOP && DISABLED(BLTOUCH) - servo[Z_ENDSTOP_SERVO_NR].move(z_servo_angle[deploy ? 0 : 1]); + MOVE_SERVO(Z_ENDSTOP_SERVO_NR, z_servo_angle[deploy ? 0 : 1]); #elif ENABLED(Z_PROBE_ALLEN_KEY) @@ -6663,7 +6663,7 @@ inline void gcode_M42() { SERIAL_ERROR_START(); SERIAL_ERRORLNPGM("Z_ENDSTOP_SERVO_NR not setup"); - #else + #else // HAS_Z_SERVO_ENDSTOP const uint8_t probe_index = parser.byteval('P', Z_ENDSTOP_SERVO_NR); @@ -6711,10 +6711,10 @@ inline void gcode_M42() { SET_INPUT_PULLUP(PROBE_TEST_PIN); bool deploy_state, stow_state; for (uint8_t i = 0; i < 4; i++) { - servo[probe_index].move(z_servo_angle[0]); //deploy + MOVE_SERVO(probe_index, z_servo_angle[0]); //deploy safe_delay(500); deploy_state = READ(PROBE_TEST_PIN); - servo[probe_index].move(z_servo_angle[1]); //stow + MOVE_SERVO(probe_index, z_servo_angle[1]); //stow safe_delay(500); stow_state = READ(PROBE_TEST_PIN); } @@ -6738,7 +6738,7 @@ inline void gcode_M42() { } else { // measure active signal length - servo[probe_index].move(z_servo_angle[0]); // deploy + MOVE_SERVO(probe_index, z_servo_angle[0]); // deploy safe_delay(500); SERIAL_PROTOCOLLNPGM("please trigger probe"); uint16_t probe_counter = 0; @@ -6763,7 +6763,7 @@ inline void gcode_M42() { else SERIAL_PROTOCOLLNPGM("noise detected - please re-run test"); // less than 2mS pulse - servo[probe_index].move(z_servo_angle[1]); //stow + MOVE_SERVO(probe_index, z_servo_angle[1]); //stow } // pulse detected From e9c72978c71c92c996842d93683c895c3dc11787 Mon Sep 17 00:00:00 2001 From: GMagician <GMagician@users.noreply.github.com> Date: Fri, 11 Aug 2017 23:21:39 +0200 Subject: [PATCH 2/2] Implement SERVO_DELAY as array This modify give SERVO_DELAY x servo basis --- .travis.yml | 1 + Marlin/Conditionals_LCD.h | 2 +- Marlin/Configuration.h | 2 +- .../example_configurations/AlephObjects/TAZ4/Configuration.h | 2 +- .../example_configurations/AliExpress/CL-260/Configuration.h | 2 +- Marlin/example_configurations/Anet/A6/Configuration.h | 2 +- Marlin/example_configurations/Anet/A8/Configuration.h | 2 +- Marlin/example_configurations/BQ/Hephestos/Configuration.h | 2 +- Marlin/example_configurations/BQ/Hephestos_2/Configuration.h | 2 +- Marlin/example_configurations/BQ/WITBOX/Configuration.h | 2 +- Marlin/example_configurations/Cartesio/Configuration.h | 2 +- Marlin/example_configurations/Creality/CR-10/Configuration.h | 2 +- Marlin/example_configurations/Felix/Configuration.h | 2 +- Marlin/example_configurations/Felix/DUAL/Configuration.h | 2 +- Marlin/example_configurations/Geeetech/GT2560/Configuration.h | 2 +- .../Geeetech/I3_Pro_X-GT2560/Configuration.h | 2 +- .../example_configurations/Infitary/i3-M508/Configuration.h | 2 +- Marlin/example_configurations/Malyan/M150/Configuration.h | 2 +- .../RepRapWorld/Megatronics/Configuration.h | 2 +- Marlin/example_configurations/RigidBot/Configuration.h | 2 +- Marlin/example_configurations/SCARA/Configuration.h | 2 +- Marlin/example_configurations/TinyBoy2/Configuration.h | 2 +- Marlin/example_configurations/Velleman/K8200/Configuration.h | 2 +- Marlin/example_configurations/Velleman/K8400/Configuration.h | 2 +- .../Velleman/K8400/Dual-head/Configuration.h | 2 +- Marlin/example_configurations/adafruit/ST7565/Configuration.h | 2 +- .../delta/FLSUN/auto_calibrate/Configuration.h | 2 +- .../delta/FLSUN/kossel_mini/Configuration.h | 2 +- Marlin/example_configurations/delta/generic/Configuration.h | 2 +- .../example_configurations/delta/kossel_mini/Configuration.h | 2 +- .../example_configurations/delta/kossel_pro/Configuration.h | 2 +- Marlin/example_configurations/delta/kossel_xl/Configuration.h | 2 +- .../example_configurations/gCreate/gMax1.5+/Configuration.h | 2 +- Marlin/example_configurations/makibox/Configuration.h | 2 +- Marlin/example_configurations/tvrrug/Round2/Configuration.h | 2 +- Marlin/example_configurations/wt150/Configuration.h | 2 +- Marlin/servo.cpp | 4 +++- 37 files changed, 39 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2b1a1a77340..b3461a932d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -114,6 +114,7 @@ script: # - restore_configs - opt_enable NUM_SERVOS Z_ENDSTOP_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE + - opt_set NUM_SERVOS 1 - opt_enable AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS EEPROM_CHITCHAT - opt_enable_adv EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES AUTOTEMP G38_PROBE_TARGET - build_marlin diff --git a/Marlin/Conditionals_LCD.h b/Marlin/Conditionals_LCD.h index 914ef51a6c8..d3693166246 100644 --- a/Marlin/Conditionals_LCD.h +++ b/Marlin/Conditionals_LCD.h @@ -377,7 +377,7 @@ #endif #undef DEACTIVATE_SERVOS_AFTER_MOVE #undef SERVO_DELAY - #define SERVO_DELAY 50 + #define SERVO_DELAY { 50 } #ifndef BLTOUCH_DELAY #define BLTOUCH_DELAY 375 #endif diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 12d394fc3b8..f061b9c0ff0 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1595,7 +1595,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/AlephObjects/TAZ4/Configuration.h b/Marlin/example_configurations/AlephObjects/TAZ4/Configuration.h index ce9250eb9e2..52f64e98406 100644 --- a/Marlin/example_configurations/AlephObjects/TAZ4/Configuration.h +++ b/Marlin/example_configurations/AlephObjects/TAZ4/Configuration.h @@ -1615,7 +1615,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/AliExpress/CL-260/Configuration.h b/Marlin/example_configurations/AliExpress/CL-260/Configuration.h index 5cbd95adf36..a81224d9aa0 100644 --- a/Marlin/example_configurations/AliExpress/CL-260/Configuration.h +++ b/Marlin/example_configurations/AliExpress/CL-260/Configuration.h @@ -1595,7 +1595,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Anet/A6/Configuration.h b/Marlin/example_configurations/Anet/A6/Configuration.h index 3198263934c..f090b8392cb 100644 --- a/Marlin/example_configurations/Anet/A6/Configuration.h +++ b/Marlin/example_configurations/Anet/A6/Configuration.h @@ -1754,7 +1754,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Anet/A8/Configuration.h b/Marlin/example_configurations/Anet/A8/Configuration.h index 537a90468a7..cd8ce118a85 100644 --- a/Marlin/example_configurations/Anet/A8/Configuration.h +++ b/Marlin/example_configurations/Anet/A8/Configuration.h @@ -1603,7 +1603,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/BQ/Hephestos/Configuration.h b/Marlin/example_configurations/BQ/Hephestos/Configuration.h index fd956dcdfdd..c4998aeffd8 100644 --- a/Marlin/example_configurations/BQ/Hephestos/Configuration.h +++ b/Marlin/example_configurations/BQ/Hephestos/Configuration.h @@ -1586,7 +1586,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/BQ/Hephestos_2/Configuration.h b/Marlin/example_configurations/BQ/Hephestos_2/Configuration.h index fdba13b2493..dacdfcf0591 100644 --- a/Marlin/example_configurations/BQ/Hephestos_2/Configuration.h +++ b/Marlin/example_configurations/BQ/Hephestos_2/Configuration.h @@ -1596,7 +1596,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/BQ/WITBOX/Configuration.h b/Marlin/example_configurations/BQ/WITBOX/Configuration.h index b8fbc1266fc..0b814b17ab7 100644 --- a/Marlin/example_configurations/BQ/WITBOX/Configuration.h +++ b/Marlin/example_configurations/BQ/WITBOX/Configuration.h @@ -1586,7 +1586,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Cartesio/Configuration.h b/Marlin/example_configurations/Cartesio/Configuration.h index 9360232d631..3b4e6c52107 100644 --- a/Marlin/example_configurations/Cartesio/Configuration.h +++ b/Marlin/example_configurations/Cartesio/Configuration.h @@ -1594,7 +1594,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Creality/CR-10/Configuration.h b/Marlin/example_configurations/Creality/CR-10/Configuration.h index 53e703b8115..efd28a8b28e 100644 --- a/Marlin/example_configurations/Creality/CR-10/Configuration.h +++ b/Marlin/example_configurations/Creality/CR-10/Configuration.h @@ -1607,7 +1607,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index 5b99d6dbacf..49af65921fd 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -1577,7 +1577,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Felix/DUAL/Configuration.h b/Marlin/example_configurations/Felix/DUAL/Configuration.h index eeaaf0e7f9c..ae36182bf24 100644 --- a/Marlin/example_configurations/Felix/DUAL/Configuration.h +++ b/Marlin/example_configurations/Felix/DUAL/Configuration.h @@ -1577,7 +1577,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Geeetech/GT2560/Configuration.h b/Marlin/example_configurations/Geeetech/GT2560/Configuration.h index 6cbc46bc06b..2d95f5221fa 100644 --- a/Marlin/example_configurations/Geeetech/GT2560/Configuration.h +++ b/Marlin/example_configurations/Geeetech/GT2560/Configuration.h @@ -1610,7 +1610,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Geeetech/I3_Pro_X-GT2560/Configuration.h b/Marlin/example_configurations/Geeetech/I3_Pro_X-GT2560/Configuration.h index d7e024dcecd..86731fee9bb 100644 --- a/Marlin/example_configurations/Geeetech/I3_Pro_X-GT2560/Configuration.h +++ b/Marlin/example_configurations/Geeetech/I3_Pro_X-GT2560/Configuration.h @@ -1595,7 +1595,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Infitary/i3-M508/Configuration.h b/Marlin/example_configurations/Infitary/i3-M508/Configuration.h index 872870a765b..de23a4ca739 100644 --- a/Marlin/example_configurations/Infitary/i3-M508/Configuration.h +++ b/Marlin/example_configurations/Infitary/i3-M508/Configuration.h @@ -1599,7 +1599,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Malyan/M150/Configuration.h b/Marlin/example_configurations/Malyan/M150/Configuration.h index 50173826697..23162888f78 100644 --- a/Marlin/example_configurations/Malyan/M150/Configuration.h +++ b/Marlin/example_configurations/Malyan/M150/Configuration.h @@ -1623,7 +1623,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h index 0f575a8fcea..b4b895f6481 100644 --- a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h +++ b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h @@ -1595,7 +1595,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/RigidBot/Configuration.h b/Marlin/example_configurations/RigidBot/Configuration.h index ea744e8e82c..152cf61aa87 100644 --- a/Marlin/example_configurations/RigidBot/Configuration.h +++ b/Marlin/example_configurations/RigidBot/Configuration.h @@ -1595,7 +1595,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index aa5dcdac6ee..a457c2d35fb 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -1607,7 +1607,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/TinyBoy2/Configuration.h b/Marlin/example_configurations/TinyBoy2/Configuration.h index 480ba0a7a2d..1453e06560d 100644 --- a/Marlin/example_configurations/TinyBoy2/Configuration.h +++ b/Marlin/example_configurations/TinyBoy2/Configuration.h @@ -1651,7 +1651,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Velleman/K8200/Configuration.h b/Marlin/example_configurations/Velleman/K8200/Configuration.h index 959713d3dd1..cd39af033bd 100644 --- a/Marlin/example_configurations/Velleman/K8200/Configuration.h +++ b/Marlin/example_configurations/Velleman/K8200/Configuration.h @@ -1629,7 +1629,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Velleman/K8400/Configuration.h b/Marlin/example_configurations/Velleman/K8400/Configuration.h index 48ed7f53fc1..33914e41ddd 100644 --- a/Marlin/example_configurations/Velleman/K8400/Configuration.h +++ b/Marlin/example_configurations/Velleman/K8400/Configuration.h @@ -1595,7 +1595,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/Velleman/K8400/Dual-head/Configuration.h b/Marlin/example_configurations/Velleman/K8400/Dual-head/Configuration.h index 1c24b721711..94bca1fc01c 100644 --- a/Marlin/example_configurations/Velleman/K8400/Dual-head/Configuration.h +++ b/Marlin/example_configurations/Velleman/K8400/Dual-head/Configuration.h @@ -1595,7 +1595,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/adafruit/ST7565/Configuration.h b/Marlin/example_configurations/adafruit/ST7565/Configuration.h index 4c99ee2f1a2..9a4a60a4268 100644 --- a/Marlin/example_configurations/adafruit/ST7565/Configuration.h +++ b/Marlin/example_configurations/adafruit/ST7565/Configuration.h @@ -1595,7 +1595,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h index 643d2e2eec8..8c2947a2521 100644 --- a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h +++ b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h @@ -1723,7 +1723,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration.h index 82de18e31f9..c0718640aa2 100644 --- a/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration.h @@ -1716,7 +1716,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index ce2b8ceec09..63d53eec11e 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -1711,7 +1711,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index 75c03f697cb..f1d39ef7264 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -1714,7 +1714,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index 259c923d063..95a8be32456 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -1714,7 +1714,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration.h b/Marlin/example_configurations/delta/kossel_xl/Configuration.h index 4231be0682b..2bda92c264c 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration.h @@ -1723,7 +1723,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/gCreate/gMax1.5+/Configuration.h b/Marlin/example_configurations/gCreate/gMax1.5+/Configuration.h index a870e8da8f4..ed98ed508ef 100644 --- a/Marlin/example_configurations/gCreate/gMax1.5+/Configuration.h +++ b/Marlin/example_configurations/gCreate/gMax1.5+/Configuration.h @@ -1609,7 +1609,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index 02f33df031a..a552a7727e6 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -1598,7 +1598,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 8212beb072c..26a59a2059b 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -1590,7 +1590,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/example_configurations/wt150/Configuration.h b/Marlin/example_configurations/wt150/Configuration.h index 2c468a94207..db6dac6cf82 100644 --- a/Marlin/example_configurations/wt150/Configuration.h +++ b/Marlin/example_configurations/wt150/Configuration.h @@ -1600,7 +1600,7 @@ // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY 300 +#define SERVO_DELAY { 300 } // Servo deactivation // diff --git a/Marlin/servo.cpp b/Marlin/servo.cpp index 74feb5c6142..d6b7b700f96 100644 --- a/Marlin/servo.cpp +++ b/Marlin/servo.cpp @@ -308,9 +308,11 @@ int Servo::readMicroseconds() { bool Servo::attached() { return servo_info[this->servoIndex].Pin.isActive; } void Servo::move(int value) { + constexpr uint16_t servo_delay[] = SERVO_DELAY; + static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long."); if (this->attach(0) >= 0) { this->write(value); - delay(SERVO_DELAY); + delay(servo_delay[this->servoIndex]); #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) this->detach(); #endif