@@ -46,9 +46,9 @@ int improved_map(int value, int minIn, int maxIn, int minOut, int maxOut)
4646Servo::Servo ()
4747{
4848 _attached = false ;
49- _valueUs = DEFAULT_PULSE_WIDTH ;
50- _minUs = MIN_PULSE_WIDTH ;
51- _maxUs = MAX_PULSE_WIDTH ;
49+ _valueUs = DEFAULT_NEUTRAL_PULSE_WIDTH ;
50+ _minUs = DEFAULT_MIN_PULSE_WIDTH ;
51+ _maxUs = DEFAULT_MAX_PULSE_WIDTH ;
5252}
5353
5454Servo::~Servo () {
@@ -58,7 +58,7 @@ Servo::~Servo() {
5858
5959uint8_t Servo::attach (int pin)
6060{
61- return attach (pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH );
61+ return attach (pin, DEFAULT_MIN_PULSE_WIDTH, DEFAULT_MAX_PULSE_WIDTH );
6262}
6363
6464uint8_t Servo::attach (int pin, uint16_t minUs, uint16_t maxUs)
@@ -70,11 +70,11 @@ uint8_t Servo::attach(int pin, uint16_t minUs, uint16_t maxUs)
7070 _attached = true ;
7171 }
7272
73- // keep the min and max within 200-3000 us, these are extreme
73+ // keep the min and max within 500-2500 us, these are extreme
7474 // ranges and should support extreme servos while maintaining
7575 // reasonable ranges
76- _maxUs = max ((uint16_t )250 , min ((uint16_t )3000 , maxUs));
77- _minUs = max ((uint16_t )200 , min (_maxUs, minUs));
76+ _maxUs = max ((uint16_t )550 , min ((uint16_t )2500 , maxUs));
77+ _minUs = max ((uint16_t )500 , min (_maxUs, minUs));
7878
7979 write (_valueUs);
8080
@@ -97,9 +97,11 @@ void Servo::write(int value)
9797 if (value < _minUs) {
9898 // assumed to be 0-180 degrees servo
9999 value = constrain (value, 0 , 180 );
100- // writeMicroseconds will contrain the calculated value for us
100+ // writeMicroseconds will contain the calculated value for us
101101 // for any user defined min and max, but we must use default min max
102102 value = improved_map (value, 0 , 180 , _minUs, _maxUs);
103+ } else if (value > _maxUs) {
104+ value = constrain (value, _minUs, _maxUs);
103105 }
104106 writeMicroseconds (value);
105107}
0 commit comments