My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

HAL_Servo_Teensy.cpp 946B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifdef __MK20DX256__
  2. #include "../../inc/MarlinConfig.h"
  3. #if HAS_SERVOS
  4. #include "HAL_Servo_Teensy.h"
  5. uint8_t servoPin[MAX_SERVOS] = { 0 };
  6. int8_t libServo::attach(const int pin) {
  7. if (this->servoIndex >= MAX_SERVOS) return -1;
  8. if (pin > 0) servoPin[this->servoIndex] = pin;
  9. return Servo::attach(servoPin[this->servoIndex]);
  10. }
  11. int8_t libServo::attach(const int pin, const int min, const int max) {
  12. if (pin > 0) servoPin[this->servoIndex] = pin;
  13. return Servo::attach(servoPin[this->servoIndex], min, max);
  14. }
  15. void libServo::move(const int value) {
  16. constexpr uint16_t servo_delay[] = SERVO_DELAY;
  17. static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
  18. if (this->attach(0) >= 0) {
  19. this->write(value);
  20. safe_delay(servo_delay[this->servoIndex]);
  21. #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
  22. this->detach();
  23. #endif
  24. }
  25. }
  26. #endif // HAS_SERVOS
  27. #endif // __MK20DX256__