Tweaks to Servo classes

This commit is contained in:
Scott Lahteine
2017-09-27 03:33:29 -05:00
parent f582f1bf4e
commit 0cb4d25431
4 changed files with 21 additions and 24 deletions

View File

@ -1,20 +1,18 @@
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
#include "HAL_Servo_Teensy.h"
#include "../../inc/MarlinConfig.h"
int8_t libServo::attach(int pin) {
if (this->servoIndex >= MAX_SERVOS) return -1;
return Servo::attach(pin);
int8_t libServo::attach(const int pin) {
if (this->servoIndex >= MAX_SERVOS) return -1;
return Servo::attach(pin);
}
int8_t libServo::attach(int pin, int min, int max) {
return Servo::attach(pin, min, max);
int8_t libServo::attach(const int pin, const int min, const int max) {
return Servo::attach(pin, min, max);
}
void libServo::move(int value) {
void libServo::move(const int value) {
if (this->attach(0) >= 0) {
this->write(value);
delay(SERVO_DELAY);
@ -24,5 +22,4 @@ void libServo::move(int value) {
}
}
#endif
#endif // __MK64FX512__ || __MK66FX1M0__

View File

@ -6,13 +6,13 @@
// Inherit and expand on the official library
class libServo : public Servo {
public:
int8_t attach(int pin);
int8_t attach(int pin, int min, int max);
void move(int value);
int8_t attach(const int pin);
int8_t attach(const int pin, const int min, const int max);
void move(const int value);
private:
uint16_t min_ticks;
uint16_t max_ticks;
uint8_t servoIndex; // index into the channel data for this servo
};
#endif
#endif // HAL_Servo_Teensy_h