mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-21 21:22:31 +03:00
Servo: fix arg types for std::min/max
This commit is contained in:
@ -77,7 +77,7 @@ class Servo
|
|||||||
public:
|
public:
|
||||||
Servo();
|
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); // 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 detach();
|
||||||
void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds
|
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
|
void writeMicroseconds(int value); // Write pulse width in microseconds
|
||||||
|
@ -221,7 +221,7 @@ uint8_t Servo::attach(int pin)
|
|||||||
return attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
|
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;
|
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
|
// keep the min and max within 200-3000 us, these are extreme
|
||||||
// ranges and should support extreme servos while maintaining
|
// ranges and should support extreme servos while maintaining
|
||||||
// reasonable ranges
|
// reasonable ranges
|
||||||
_maxUs = max(250, min(3000, maxUs));
|
_maxUs = max((uint16_t)250, min((uint16_t)3000, maxUs));
|
||||||
_minUs = max(200, min(_maxUs, minUs));
|
_minUs = max((uint16_t)200, min(_maxUs, minUs));
|
||||||
|
|
||||||
// initialize the timerId if it has not already been initialized
|
// initialize the timerId if it has not already been initialized
|
||||||
timerId = SERVO_INDEX_TO_TIMER(_servoIndex);
|
timerId = SERVO_INDEX_TO_TIMER(_servoIndex);
|
||||||
|
Reference in New Issue
Block a user