diff --git a/libraries/Servo/src/Servo.h b/libraries/Servo/src/Servo.h index b55fdb8f2..d4bf861ba 100644 --- a/libraries/Servo/src/Servo.h +++ b/libraries/Servo/src/Servo.h @@ -77,7 +77,7 @@ class Servo public: Servo(); 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, uint16_t min, uint16_t max); // as above but also sets min and max values for writes. void detach(); void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds void writeMicroseconds(int value); // Write pulse width in microseconds diff --git a/libraries/Servo/src/esp8266/Servo.cpp b/libraries/Servo/src/esp8266/Servo.cpp index ef73f94d2..dd15168cb 100644 --- a/libraries/Servo/src/esp8266/Servo.cpp +++ b/libraries/Servo/src/esp8266/Servo.cpp @@ -221,7 +221,7 @@ uint8_t Servo::attach(int pin) return attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); } -uint8_t Servo::attach(int pin, int minUs, int maxUs) +uint8_t Servo::attach(int pin, uint16_t minUs, uint16_t maxUs) { ServoTimerSequence timerId; @@ -235,8 +235,8 @@ uint8_t Servo::attach(int pin, int minUs, int maxUs) // keep the min and max within 200-3000 us, these are extreme // ranges and should support extreme servos while maintaining // reasonable ranges - _maxUs = max(250, min(3000, maxUs)); - _minUs = max(200, min(_maxUs, minUs)); + _maxUs = max((uint16_t)250, min((uint16_t)3000, maxUs)); + _minUs = max((uint16_t)200, min(_maxUs, minUs)); // initialize the timerId if it has not already been initialized timerId = SERVO_INDEX_TO_TIMER(_servoIndex);