Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion VarSpeedServo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ VarSpeedServo::VarSpeedServo()
{
if( ServoCount < MAX_SERVOS) {
this->servoIndex = ServoCount++; // assign a servo index to this instance
servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - 12 Aug 2009
servos[this->servoIndex].ticks = 0; // store default values - 12 Aug 2009
this->curSeqPosition = 0;
this->curSequence = initSeq;
}
Expand All @@ -315,8 +315,14 @@ uint8_t VarSpeedServo::attach(int pin)
}

uint8_t VarSpeedServo::attach(int pin, int min, int max)
{
return this->attach(pin, min, max, DEFAULT_PULSE_WIDTH);
}

uint8_t VarSpeedServo::attach(int pin, int min, int max, int initialPulseWidth)
{
if(this->servoIndex < MAX_SERVOS ) {
servos[this->servoIndex].ticks = usToTicks(initialPulseWidth);
pinMode( pin, OUTPUT) ; // set servo pin to output
servos[this->servoIndex].Pin.nbr = pin;
// todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128
Expand Down
2 changes: 2 additions & 0 deletions VarSpeedServo.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class VarSpeedServo
VarSpeedServo();
uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure
uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
uint8_t attach(int pin, int min, int max, int initialPulseWidth); // as above but also sets initial pulse width.
// If you set 0, servo dose not move from initial position.
void detach();
void write(int value); // if value is < 544 its treated as an angle, otherwise as pulse width in microseconds
void write(int value, uint8_t speed); // Move to given position at reduced speed.
Expand Down