Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Servo: re-attach to same value (position) #8753

Merged
merged 2 commits into from
Dec 14, 2022
Merged
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
3 changes: 1 addition & 2 deletions libraries/Servo/src/Servo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Servo::~Servo() {

uint8_t Servo::attach(int pin)
{
return attach(pin, DEFAULT_MIN_PULSE_WIDTH, DEFAULT_MAX_PULSE_WIDTH);
return attach(pin, _minUs, _maxUs);
}

uint8_t Servo::attach(int pin, uint16_t minUs, uint16_t maxUs)
Expand Down Expand Up @@ -94,7 +94,6 @@ void Servo::detach()
delay(REFRESH_INTERVAL / 1000); // long enough to complete active period under all circumstances.
stopWaveform(_pin);
_attached = false;
_valueUs = DEFAULT_NEUTRAL_PULSE_WIDTH;
}
}

Expand Down
3 changes: 2 additions & 1 deletion libraries/Servo/src/Servo.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
//
// attach(pin) - Attaches a servo motor to an i/o pin.
// attach(pin, min, max) - Attaches to a pin setting min and max values in microseconds
// default min is 1000, max is 2000
// attach(pin, min, max, value) - Attaches to a pin setting min, max, and current values in microseconds
// default min is 1000, max is 2000, and value is 1500.
//
// 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
Expand Down