mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-28 22:54:20 +01:00
Moving Servo min and max parameters to the attach() function from the constructor.
This commit is contained in:
parent
191bb02f00
commit
44d4a4ff8a
@ -53,13 +53,20 @@ void Servo::releaseTimer1() {}
|
|||||||
|
|
||||||
#define NO_ANGLE (0xff)
|
#define NO_ANGLE (0xff)
|
||||||
|
|
||||||
Servo::Servo() : pin(0), angle(NO_ANGLE), min16(34), max16(150) {}
|
Servo::Servo() : pin(0), angle(NO_ANGLE) {}
|
||||||
Servo::Servo(int min, int max) : pin(0), angle(NO_ANGLE), min16(min / 16), max16(max / 16) {}
|
|
||||||
|
|
||||||
uint8_t Servo::attach(int pinArg)
|
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;
|
if (pinArg != 9 && pinArg != 10) return 0;
|
||||||
|
|
||||||
|
min16 = min / 16;
|
||||||
|
max16 = max / 16;
|
||||||
|
|
||||||
pin = pinArg;
|
pin = pinArg;
|
||||||
angle = NO_ANGLE;
|
angle = NO_ANGLE;
|
||||||
digitalWrite(pin, LOW);
|
digitalWrite(pin, LOW);
|
||||||
|
@ -36,9 +36,11 @@ class Servo
|
|||||||
static uint8_t attached10;
|
static uint8_t attached10;
|
||||||
public:
|
public:
|
||||||
Servo();
|
Servo();
|
||||||
Servo(int, int); // pulse length for 0 degrees in microseconds, 540uS default
|
uint8_t attach(int);
|
||||||
// pulse length for 180 degrees in microseconds, 2400uS default
|
// pulse length for 0 degrees in microseconds, 544uS default
|
||||||
uint8_t attach(int); // attach to a pin, sets pinMode, returns 0 on failure, won't
|
// 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
|
// position the servo until a subsequent write() happens
|
||||||
// Only works for 9 and 10.
|
// Only works for 9 and 10.
|
||||||
void detach();
|
void detach();
|
||||||
|
4
todo.txt
4
todo.txt
@ -8,8 +8,8 @@ Improve shiftOut() performance: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=
|
|||||||
Add String library.
|
Add String library.
|
||||||
Comment LiquidCrystal examples.
|
Comment LiquidCrystal examples.
|
||||||
Write LiquidCrystal documentation.
|
Write LiquidCrystal documentation.
|
||||||
Add Arduino Nano to boards menu.
|
[done] Add Arduino Nano to boards menu.
|
||||||
Add Arduino Pro to boards menu.
|
[done] Add Arduino Pro to boards menu.
|
||||||
[done] Per-board upload.using preference.
|
[done] Per-board upload.using preference.
|
||||||
[done] Update version of avr-gcc, etc. to support ATmega644, ATmega328, etc.
|
[done] Update version of avr-gcc, etc. to support ATmega644, ATmega328, etc.
|
||||||
[done] Move #include <WProgram.h> after other #include's? (prevent it from interfering with standard libraries)
|
[done] Move #include <WProgram.h> after other #include's? (prevent it from interfering with standard libraries)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user