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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * HAL Servo for Teensy 3.5 (MK64FX512) and Teensy 3.6 (MK66FX1M0)
  24. */
  25. #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
  26. #include "../../inc/MarlinConfig.h"
  27. #if HAS_SERVOS
  28. #include "Servo.h"
  29. uint8_t servoPin[MAX_SERVOS] = { 0 };
  30. int8_t libServo::attach(const int inPin) {
  31. if (servoIndex >= MAX_SERVOS) return -1;
  32. if (inPin > 0) servoPin[servoIndex] = inPin;
  33. return super::attach(servoPin[servoIndex]);
  34. }
  35. int8_t libServo::attach(const int inPin, const int inMin, const int inMax) {
  36. if (inPin > 0) servoPin[servoIndex] = inPin;
  37. return super::attach(servoPin[servoIndex], inMin, inMax);
  38. }
  39. void libServo::move(const int value) {
  40. constexpr uint16_t servo_delay[] = SERVO_DELAY;
  41. static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
  42. if (attach(0) >= 0) {
  43. write(value);
  44. safe_delay(servo_delay[servoIndex]);
  45. TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
  46. }
  47. }
  48. #endif // HAS_SERVOS
  49. #endif // __MK64FX512__ || __MK66FX1M0__