Update servo.* for parity with 2.0.x
This commit is contained in:
@@ -236,7 +236,6 @@ static bool isTimerActive(timer16_Sequence_t timer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/****************** end of static functions ******************************/
|
||||
|
||||
Servo::Servo() {
|
||||
@@ -248,11 +247,11 @@ Servo::Servo() {
|
||||
this->servoIndex = INVALID_SERVO; // too many servos
|
||||
}
|
||||
|
||||
int8_t Servo::attach(int pin) {
|
||||
int8_t Servo::attach(const int pin) {
|
||||
return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
|
||||
}
|
||||
|
||||
int8_t Servo::attach(int pin, int min, int max) {
|
||||
int8_t Servo::attach(const int pin, const int min, const int max) {
|
||||
|
||||
if (this->servoIndex >= MAX_SERVOS) return -1;
|
||||
|
||||
@@ -307,16 +306,16 @@ int Servo::readMicroseconds() {
|
||||
|
||||
bool Servo::attached() { return servo_info[this->servoIndex].Pin.isActive; }
|
||||
|
||||
void Servo::move(int value) {
|
||||
void Servo::move(const int value) {
|
||||
constexpr uint16_t servo_delay[] = SERVO_DELAY;
|
||||
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
|
||||
if (this->attach(0) >= 0) {
|
||||
this->write(value);
|
||||
delay(servo_delay[this->servoIndex]);
|
||||
safe_delay(servo_delay[this->servoIndex]);
|
||||
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
|
||||
this->detach();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // HAS_SERVOS
|
||||
|
||||
Reference in New Issue
Block a user