Skip to content

Commit

Permalink
Servo: fix arg types for std::min/max
Browse files Browse the repository at this point in the history
  • Loading branch information
devyte authored and igrr committed Nov 5, 2017
1 parent 7ad89e5 commit 303a71d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libraries/Servo/src/Servo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions libraries/Servo/src/esp8266/Servo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down

0 comments on commit 303a71d

Please sign in to comment.