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.
This commit is contained in:
committed by
Richard Wackerbarth
parent
b116c096bd
commit
8b876241bd
@ -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
|
||||
|
Reference in New Issue
Block a user