Skip to content

Commit 303a71d

Browse files
devyteigrr
authored andcommitted
Servo: fix arg types for std::min/max
1 parent 7ad89e5 commit 303a71d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

libraries/Servo/src/Servo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Servo
7777
public:
7878
Servo();
7979
uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure
80-
uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
80+
uint8_t attach(int pin, uint16_t min, uint16_t max); // as above but also sets min and max values for writes.
8181
void detach();
8282
void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds
8383
void writeMicroseconds(int value); // Write pulse width in microseconds

libraries/Servo/src/esp8266/Servo.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ uint8_t Servo::attach(int pin)
221221
return attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
222222
}
223223

224-
uint8_t Servo::attach(int pin, int minUs, int maxUs)
224+
uint8_t Servo::attach(int pin, uint16_t minUs, uint16_t maxUs)
225225
{
226226
ServoTimerSequence timerId;
227227

@@ -235,8 +235,8 @@ uint8_t Servo::attach(int pin, int minUs, int maxUs)
235235
// keep the min and max within 200-3000 us, these are extreme
236236
// ranges and should support extreme servos while maintaining
237237
// reasonable ranges
238-
_maxUs = max(250, min(3000, maxUs));
239-
_minUs = max(200, min(_maxUs, minUs));
238+
_maxUs = max((uint16_t)250, min((uint16_t)3000, maxUs));
239+
_minUs = max((uint16_t)200, min(_maxUs, minUs));
240240

241241
// initialize the timerId if it has not already been initialized
242242
timerId = SERVO_INDEX_TO_TIMER(_servoIndex);

0 commit comments

Comments
 (0)