Fix Servo class compile errors
This commit is contained in:
parent
de05b2b309
commit
020ce176c4
|
@ -113,7 +113,7 @@
|
||||||
servo_info[this->servoIndex].Pin.isActive = false;
|
servo_info[this->servoIndex].Pin.isActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Servo::write(const int value) {
|
void Servo::write(int value) {
|
||||||
if (value < MIN_PULSE_WIDTH) { // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)
|
if (value < MIN_PULSE_WIDTH) { // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)
|
||||||
value = map(constrain(value, 0, 180), 0, 180, SERVO_MIN(), SERVO_MAX());
|
value = map(constrain(value, 0, 180), 0, 180, SERVO_MIN(), SERVO_MAX());
|
||||||
// odd - this sets zero degrees to 544 and 180 degrees to 2400 microseconds but the literature says
|
// odd - this sets zero degrees to 544 and 180 degrees to 2400 microseconds but the literature says
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
this->writeMicroseconds(value);
|
this->writeMicroseconds(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Servo::writeMicroseconds(const int value) {
|
void Servo::writeMicroseconds(int value) {
|
||||||
// calculate and store the values for the given channel
|
// calculate and store the values for the given channel
|
||||||
byte channel = this->servoIndex;
|
byte channel = this->servoIndex;
|
||||||
if (channel < MAX_SERVOS) { // ensure channel is valid
|
if (channel < MAX_SERVOS) { // ensure channel is valid
|
||||||
|
|
|
@ -42,8 +42,8 @@
|
||||||
int8_t attach(const int pin); // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail)
|
int8_t attach(const int pin); // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail)
|
||||||
int8_t attach(const int pin, const int min, const int max); // as above but also sets min and max values for writes.
|
int8_t attach(const int pin, const int min, const int max); // as above but also sets min and max values for writes.
|
||||||
void detach();
|
void detach();
|
||||||
void write(const int value); // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
|
void write(int value); // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
|
||||||
void writeMicroseconds(const int value); // write pulse width in microseconds
|
void writeMicroseconds(int value); // write pulse width in microseconds
|
||||||
void move(const int value); // attach the servo, then move to value
|
void move(const int value); // attach the servo, then move to value
|
||||||
// if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
|
// if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
|
||||||
// if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY, then detach
|
// if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY, then detach
|
||||||
|
|
Loading…
Reference in a new issue