From 8b876241bd87475251ace370bbdfd463777e20af Mon Sep 17 00:00:00 2001 From: AnHardt Date: Fri, 24 Jul 2015 11:26:05 +0200 Subject: [PATCH] Some more servo code tweaks Just set up the pin. Don't move to a random position. Simplify servo::move() * servo::move() does not need the pin parameter - The pin is set during servo_init() with attach(). * servo::move() does not need a return value. SERVO_LEVELING is the wrong condition to deactivate the servos. Remove some temporary (Servo *) variables. SanityCheck for the servo indexes. --- Marlin/Conditionals.h | 16 ++++++++++++++ Marlin/Configuration.h | 6 ++++-- Marlin/SanityCheck.h | 17 ++++++++++++--- Marlin/configurator/config/Configuration.h | 6 ++++-- .../Felix/Configuration.h | 6 ++++-- .../Felix/Configuration_DUAL.h | 21 ++++++++++++++----- .../Hephestos/Configuration.h | 6 ++++-- .../K8200/Configuration.h | 6 ++++-- .../RepRapWorld/Megatronics/Configuration.h | 6 ++++-- .../RigidBot/Configuration.h | 6 ++++-- .../SCARA/Configuration.h | 6 ++++-- .../WITBOX/Configuration.h | 6 ++++-- .../adafruit/ST7565/Configuration.h | 6 ++++-- .../delta/biv2.5/Configuration.h | 6 ++++-- .../delta/generic/Configuration.h | 6 ++++-- .../delta/kossel_mini/Configuration.h | 6 ++++-- .../delta/kossel_pro/Configuration.h | 6 ++++-- .../makibox/Configuration.h | 6 ++++-- .../tvrrug/Round2/Configuration.h | 6 ++++-- Marlin/servo.cpp | 13 +++--------- Marlin/servo.h | 16 +++++++------- 21 files changed, 121 insertions(+), 58 deletions(-) diff --git a/Marlin/Conditionals.h b/Marlin/Conditionals.h index d769b89da..b14ea2ad6 100644 --- a/Marlin/Conditionals.h +++ b/Marlin/Conditionals.h @@ -511,5 +511,21 @@ #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 + #endif + #ifndef Y_ENDSTOP_SERVO_NR + #define Y_ENDSTOP_SERVO_NR -1 + #endif + #ifndef Z_ENDSTOP_SERVO_NR + #define Z_ENDSTOP_SERVO_NR -1 + #endif + #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} + #endif + #endif + #endif //CONFIGURATION_LCD #endif //CONDITIONALS_H diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 161e2eb64..ea6055828 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -530,7 +530,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -780,7 +780,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 96bc39b17..6c4c77ab5 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -83,12 +83,23 @@ #if NUM_SERVOS > 4 #error The maximum number of SERVOS in Marlin is 4. #endif + #if defined(NUM_SERVOS) && NUM_SERVOS > 0 + #if X_ENDSTOP_SERVO_NR >= 0 || Y_ENDSTOP_SERVO_NR >= 0 || Z_ENDSTOP_SERVO_NR >= 0 + #if X_ENDSTOP_SERVO_NR >= NUM_SERVOS + #error X_ENDSTOP_SERVO_NR must be smaller than NUM_SERVOS. + #elif Y_ENDSTOP_SERVO_NR >= NUM_SERVOS + #error Y_ENDSTOP_SERVO_NR must be smaller than NUM_SERVOS. + #elif Z_ENDSTOP_SERVO_NR >= NUM_SERVOS + #error Z_ENDSTOP_SERVO_NR must be smaller than NUM_SERVOS. + #endif + #endif + #endif /** * Servo deactivation depends on servo endstops */ #if defined(DEACTIVATE_SERVOS_AFTER_MOVE) && !defined(SERVO_ENDSTOPS) - #error SERVO_ENDSTOPS is required for DEACTIVATE_SERVOS_AFTER_MOVE. + #error At least one of the ?_ENDSTOP_SERVO_NR is required for DEACTIVATE_SERVOS_AFTER_MOVE. #endif /** @@ -148,8 +159,8 @@ // #if defined(NUM_SERVOS) && NUM_SERVOS < 1 // #error You must have at least 1 servo defined for NUM_SERVOS to use Z_PROBE_ENDSTOP. // #endif -// #ifndef SERVO_ENDSTOPS -// #error You must have SERVO_ENDSTOPS defined and have the Z index set to at least 0 or above to use Z_PROBE_ENDSTOP. +// #if Z_ENDSTOP_SERVO_NR < 0 +// #error You must have Z_ENDSTOP_SERVO_NR set to at least 0 or above to use Z_PROBE_ENDSTOP. // #endif // #ifndef SERVO_ENDSTOP_ANGLES // #error You must have SERVO_ENDSTOP_ANGLES defined for Z Extend and Retract to use Z_PROBE_ENDSTOP. diff --git a/Marlin/configurator/config/Configuration.h b/Marlin/configurator/config/Configuration.h index 2d4644417..f5749972a 100644 --- a/Marlin/configurator/config/Configuration.h +++ b/Marlin/configurator/config/Configuration.h @@ -530,7 +530,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -780,7 +780,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index 9ddd7afc7..dcf5c8d47 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -512,7 +512,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -763,7 +763,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/Felix/Configuration_DUAL.h b/Marlin/example_configurations/Felix/Configuration_DUAL.h index 066cac73e..36aff9013 100644 --- a/Marlin/example_configurations/Felix/Configuration_DUAL.h +++ b/Marlin/example_configurations/Felix/Configuration_DUAL.h @@ -449,9 +449,6 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //If defined, the Probe servo will be turned on only during movement and then turned off to avoid jerk //The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it. - // You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile. - -// #define PROBE_SERVO_DEACTIVATION_DELAY 300 //If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing, @@ -476,7 +473,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -718,9 +715,23 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles +// Servo deactivation +// +// With this option servos are powered only during movement, then turned off to prevent jitter. +//#define DEACTIVATE_SERVOS_AFTER_MOVE + +#ifdef DEACTIVATE_SERVOS_AFTER_MOVE + // Delay (in microseconds) before turning the servo off. This depends on the servo speed. + // 300ms is a good value but you can try less delay. + // If the servo can't reach the requested position, increase it. + #define SERVO_DEACTIVATION_DELAY 300 +#endif + /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 764ed6201..4d4e040f6 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -522,7 +522,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -772,7 +772,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index 051a54a28..110548641 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -518,7 +518,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -768,7 +768,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h index 868270cb8..5f222e85c 100644 --- a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h +++ b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h @@ -530,7 +530,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -780,7 +780,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/RigidBot/Configuration.h b/Marlin/example_configurations/RigidBot/Configuration.h index 6baf0c04f..a34e50bf2 100644 --- a/Marlin/example_configurations/RigidBot/Configuration.h +++ b/Marlin/example_configurations/RigidBot/Configuration.h @@ -510,7 +510,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -763,7 +763,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 2f5aa56e1..619b852af 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -538,7 +538,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -788,7 +788,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index a17de0926..fa0e7cd49 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -522,7 +522,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -772,7 +772,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/adafruit/ST7565/Configuration.h b/Marlin/example_configurations/adafruit/ST7565/Configuration.h index eb3f61a41..d43f08ad4 100644 --- a/Marlin/example_configurations/adafruit/ST7565/Configuration.h +++ b/Marlin/example_configurations/adafruit/ST7565/Configuration.h @@ -530,7 +530,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -780,7 +780,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration.h b/Marlin/example_configurations/delta/biv2.5/Configuration.h index a64641e3a..72d520c5b 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration.h @@ -650,7 +650,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -903,7 +903,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index 651e6ce9b..3cd57a81d 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -650,7 +650,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -907,7 +907,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index 643da2f71..0063249db 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -654,7 +654,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -907,7 +907,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index 112a6e77c..be69c669f 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -639,7 +639,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -902,7 +902,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index 4dc55cb88..f8f3610b1 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -533,7 +533,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -783,7 +783,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 8e1ad6fd5..2aa9202bc 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -520,7 +520,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic // If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28. // WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print. // To use a separate Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board. - // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. + // If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOPS_ANGLES in the R/C Servo below. // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32 // for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed. // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. @@ -774,7 +774,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes. // Use M851 to set the z-probe vertical offset from the nozzle. Store that setting with M500. // -//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1 +//#define X_ENDSTOP_SERVO_NR 1 +//#define Y_ENDSTOP_SERVO_NR 2 +//#define Z_ENDSTOP_SERVO_NR 0 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles // Servo deactivation diff --git a/Marlin/servo.cpp b/Marlin/servo.cpp index 242db5c01..718ae388f 100644 --- a/Marlin/servo.cpp +++ b/Marlin/servo.cpp @@ -304,21 +304,14 @@ int Servo::readMicroseconds() { bool Servo::attached() { return servo_info[this->servoIndex].Pin.isActive; } -int8_t Servo::move(int pin, int value) { - int8_t ret; - #if defined(DEACTIVATE_SERVOS_AFTER_MOVE) && (SERVO_DEACTIVATION_DELAY > 0) - ret = this->attach(pin); - #else - ret = this->servoIndex; - #endif - if (ret >= 0) { +void Servo::move(int value) { + if (this->attach(0) >= 0) { this->write(value); - #if defined(DEACTIVATE_SERVOS_AFTER_MOVE) && (SERVO_DEACTIVATION_DELAY > 0) + #ifdef DEACTIVATE_SERVOS_AFTER_MOVE delay(SERVO_DEACTIVATION_DELAY); this->detach(); #endif } - return ret; } #endif diff --git a/Marlin/servo.h b/Marlin/servo.h index b0b5ce5b1..850e2c232 100644 --- a/Marlin/servo.h +++ b/Marlin/servo.h @@ -37,11 +37,11 @@ write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) writeMicroseconds() - Sets the servo pulse width in microseconds read() - Gets the last written servo pulse width as an angle between 0 and 180. - readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) + readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) attached() - Returns true if there is a servo attached. detach() - Stops an attached servos from pulsing its i/o pin. - move(pin, angel) - Sequence of attach(pin), write(angel), - With DEACTIVATE_SERVOS_AFTER_MOVE it waits SERVO_DEACTIVATION_DELAY and detaches. + move(angle) - Sequence of attach(0), write(angle), + With DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DEACTIVATION_DELAY and detach. */ #ifndef servo_h @@ -117,14 +117,14 @@ typedef struct { class Servo { public: Servo(); - int8_t attach(int pin); // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail) + int8_t attach(int pin); // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail) int8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes. void detach(); void write(int value); // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds - void writeMicroseconds(int value); // Write pulse width in microseconds - int8_t move(int pin, int value); // attach the given pin to the next free channel, set pinMode, return channel number (-1 if attach fails) - // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds. - // if DEACTIVATE_SERVOS_AFTER_MOVE is defined waits SERVO_DEACTIVATION_DELAY, than detaches. + void writeMicroseconds(int value); // write pulse width in microseconds + void move(int value); // attach the servo, then move to value + // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds + // if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DEACTIVATION_DELAY, then detach int read(); // returns current pulse width as an angle between 0 and 180 degrees int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release) bool attached(); // return true if this servo is attached, otherwise false