You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
984 B
37 lines
984 B
7 years ago
|
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
|
||
|
|
||
7 years ago
|
#include "../../inc/MarlinConfig.h"
|
||
7 years ago
|
|
||
6 years ago
|
#if HAS_SERVOS
|
||
|
|
||
5 years ago
|
#include "Servo.h"
|
||
6 years ago
|
|
||
6 years ago
|
uint8_t servoPin[MAX_SERVOS] = { 0 };
|
||
|
|
||
7 years ago
|
int8_t libServo::attach(const int pin) {
|
||
|
if (this->servoIndex >= MAX_SERVOS) return -1;
|
||
6 years ago
|
if (pin > 0) servoPin[this->servoIndex] = pin;
|
||
|
return Servo::attach(servoPin[this->servoIndex]);
|
||
7 years ago
|
}
|
||
|
|
||
7 years ago
|
int8_t libServo::attach(const int pin, const int min, const int max) {
|
||
6 years ago
|
if (pin > 0) servoPin[this->servoIndex] = pin;
|
||
|
return Servo::attach(servoPin[this->servoIndex], min, max);
|
||
7 years ago
|
}
|
||
|
|
||
7 years ago
|
void libServo::move(const int value) {
|
||
6 years ago
|
constexpr uint16_t servo_delay[] = SERVO_DELAY;
|
||
|
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
|
||
7 years ago
|
if (this->attach(0) >= 0) {
|
||
|
this->write(value);
|
||
6 years ago
|
safe_delay(servo_delay[this->servoIndex]);
|
||
7 years ago
|
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
|
||
|
this->detach();
|
||
|
#endif
|
||
|
}
|
||
|
}
|
||
|
|
||
6 years ago
|
#endif // HAS_SERVOS
|
||
|
|
||
7 years ago
|
#endif // __MK64FX512__ || __MK66FX1M0__
|