diff --git a/src/nrf52/Servo.cpp b/src/nrf52/Servo.cpp index fe9876a..5f6d2d0 100644 --- a/src/nrf52/Servo.cpp +++ b/src/nrf52/Servo.cpp @@ -74,13 +74,14 @@ void Servo::detach() void Servo::write(int value) { - if (value < 0) - value = 0; - else if (value > 180) - value = 180; - value = map(value, 0, 180, MIN_PULSE, MAX_PULSE); - - writeMicroseconds(value); + if(value < MIN_PULSE_WIDTH) { + if (value < 0) + value = 0; + else if (value > 180) + value = 180; + value = map(value, 0, 180, MIN_PULSE, MAX_PULSE); + } + this->writeMicroseconds(value); } diff --git a/src/renesas/Servo.cpp b/src/renesas/Servo.cpp index fba4210..141d91f 100644 --- a/src/renesas/Servo.cpp +++ b/src/renesas/Servo.cpp @@ -232,12 +232,15 @@ void Servo::detach() } } -void Servo::write(int angle) +void Servo::write(int value) { if (servoIndex != SERVO_INVALID_INDEX) { ra_servo_t *servo = &ra_servos[servoIndex]; - angle = constrain(angle, 0, 180); - writeMicroseconds(map(angle, 0, 180, servo->period_min, servo->period_max)); + if(value < MIN_PULSE_WIDTH) { + value = constrain(value, 0, 180); + value = map(value, 0, 180, servo->period_min, servo->period_max); + } + writeMicroseconds(value); } } diff --git a/src/stm32f4/Servo.cpp b/src/stm32f4/Servo.cpp index 8687c51..2149f2e 100644 --- a/src/stm32f4/Servo.cpp +++ b/src/stm32f4/Servo.cpp @@ -148,9 +148,12 @@ bool Servo::detach() { return true; } -void Servo::write(int degrees) { - degrees = constrain(degrees, this->minAngle, this->maxAngle); - this->writeMicroseconds(ANGLE_TO_US(degrees)); +void Servo::write(int value) { + if(value < MIN_PULSE_WIDTH) { + value = constrain(value, this->minAngle, this->maxAngle); + value = ANGLE_TO_US(value); + } + this->writeMicroseconds(value); } int Servo::read() const {