From 2ed2ee36e7c51f63ecf1391bf62fcd65ad35caa5 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Thu, 21 Aug 2008 23:48:38 +0000 Subject: Moving Servo min and max parameters to the attach() function from the constructor. --- libraries/Servo/Servo.cpp | 11 +++++++++-- libraries/Servo/Servo.h | 8 +++++--- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'libraries/Servo') diff --git a/libraries/Servo/Servo.cpp b/libraries/Servo/Servo.cpp index 248a215..ac654c3 100755 --- a/libraries/Servo/Servo.cpp +++ b/libraries/Servo/Servo.cpp @@ -53,12 +53,19 @@ void Servo::releaseTimer1() {} #define NO_ANGLE (0xff) -Servo::Servo() : pin(0), angle(NO_ANGLE), min16(34), max16(150) {} -Servo::Servo(int min, int max) : pin(0), angle(NO_ANGLE), min16(min / 16), max16(max / 16) {} +Servo::Servo() : pin(0), angle(NO_ANGLE) {} uint8_t Servo::attach(int pinArg) +{ + return attach(pinArg, 544, 2400); +} + +uint8_t Servo::attach(int pinArg, int min, int max) { if (pinArg != 9 && pinArg != 10) return 0; + + min16 = min / 16; + max16 = max / 16; pin = pinArg; angle = NO_ANGLE; diff --git a/libraries/Servo/Servo.h b/libraries/Servo/Servo.h index 59f04d9..0b0e8db 100755 --- a/libraries/Servo/Servo.h +++ b/libraries/Servo/Servo.h @@ -36,9 +36,11 @@ class Servo static uint8_t attached10; public: Servo(); - Servo(int, int); // pulse length for 0 degrees in microseconds, 540uS default - // pulse length for 180 degrees in microseconds, 2400uS default - uint8_t attach(int); // attach to a pin, sets pinMode, returns 0 on failure, won't + uint8_t attach(int); + // pulse length for 0 degrees in microseconds, 544uS default + // pulse length for 180 degrees in microseconds, 2400uS default + uint8_t attach(int, int, int); + // attach to a pin, sets pinMode, returns 0 on failure, won't // position the servo until a subsequent write() happens // Only works for 9 and 10. void detach(); -- cgit v1.2.3-18-g5258