|
@@ -89,11 +89,11 @@
|
89
|
89
|
this->servoIndex = INVALID_SERVO; // too many servos
|
90
|
90
|
}
|
91
|
91
|
|
92
|
|
- int8_t Servo::attach(int pin) {
|
|
92
|
+ int8_t Servo::attach(const int pin) {
|
93
|
93
|
return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
|
94
|
94
|
}
|
95
|
95
|
|
96
|
|
- int8_t Servo::attach(int pin, int min, int max) {
|
|
96
|
+ int8_t Servo::attach(const int pin, const int min, const int max) {
|
97
|
97
|
|
98
|
98
|
if (this->servoIndex >= MAX_SERVOS) return -1;
|
99
|
99
|
|
|
@@ -113,7 +113,7 @@
|
113
|
113
|
servo_info[this->servoIndex].Pin.isActive = false;
|
114
|
114
|
}
|
115
|
115
|
|
116
|
|
- void Servo::write(int value) {
|
|
116
|
+ void Servo::write(const int value) {
|
117
|
117
|
if (value < MIN_PULSE_WIDTH) { // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)
|
118
|
118
|
value = map(constrain(value, 0, 180), 0, 180, SERVO_MIN(), SERVO_MAX());
|
119
|
119
|
// odd - this sets zero degrees to 544 and 180 degrees to 2400 microseconds but the literature says
|
|
@@ -122,7 +122,7 @@
|
122
|
122
|
this->writeMicroseconds(value);
|
123
|
123
|
}
|
124
|
124
|
|
125
|
|
- void Servo::writeMicroseconds(int value) {
|
|
125
|
+ void Servo::writeMicroseconds(const int value) {
|
126
|
126
|
// calculate and store the values for the given channel
|
127
|
127
|
byte channel = this->servoIndex;
|
128
|
128
|
if (channel < MAX_SERVOS) { // ensure channel is valid
|
|
@@ -146,7 +146,7 @@
|
146
|
146
|
|
147
|
147
|
bool Servo::attached() { return servo_info[this->servoIndex].Pin.isActive; }
|
148
|
148
|
|
149
|
|
- void Servo::move(int value) {
|
|
149
|
+ void Servo::move(const int value) {
|
150
|
150
|
if (this->attach(0) >= 0) { // notice the pin number is zero here
|
151
|
151
|
this->write(value);
|
152
|
152
|
delay(SERVO_DELAY);
|