Apply LIMIT macro
This commit is contained in:
		@@ -48,8 +48,8 @@ void Servo::detach() { ledcDetachPin(this->pin); }
 | 
			
		||||
 | 
			
		||||
int Servo::read() { return this->degrees; }
 | 
			
		||||
 | 
			
		||||
void Servo::write(int degrees) {
 | 
			
		||||
  this->degrees = constrain(degrees, MIN_ANGLE, MAX_ANGLE);
 | 
			
		||||
void Servo::write(int inDegrees) {
 | 
			
		||||
  this->degrees = constrain(inDegrees, MIN_ANGLE, MAX_ANGLE);
 | 
			
		||||
  int us = map(this->degrees, MIN_ANGLE, MAX_ANGLE, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
 | 
			
		||||
  int duty = map(us, 0, TAU_USEC, 0, MAX_COMPARE);
 | 
			
		||||
  ledcWrite(channel, duty);
 | 
			
		||||
 
 | 
			
		||||
@@ -127,7 +127,7 @@ void Servo::writeMicroseconds(int value) {
 | 
			
		||||
  byte channel = this->servoIndex;
 | 
			
		||||
  if (channel < MAX_SERVOS) {  // ensure channel is valid
 | 
			
		||||
    // ensure pulse width is valid
 | 
			
		||||
    value = constrain(value, SERVO_MIN(), SERVO_MAX()) - (TRIM_DURATION);
 | 
			
		||||
    LIMIT(value, SERVO_MIN(), SERVO_MAX()) - (TRIM_DURATION);
 | 
			
		||||
    value = usToTicks(value);  // convert to ticks after compensating for interrupt overhead - 12 Aug 2009
 | 
			
		||||
 | 
			
		||||
    CRITICAL_SECTION_START;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user