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.

Servo.h 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #pragma once
  23. /**
  24. * servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
  25. * Copyright (c) 2009 Michael Margolis. All right reserved.
  26. *
  27. * This library is free software; you can redistribute it and/or
  28. * modify it under the terms of the GNU Lesser General Public
  29. * License as published by the Free Software Foundation; either
  30. * version 2.1 of the License, or (at your option) any later version.
  31. *
  32. * This library is distributed in the hope that it will be useful,
  33. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  34. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  35. * Lesser General Public License for more details.
  36. *
  37. * You should have received a copy of the GNU Lesser General Public
  38. * License along with this library; if not, write to the Free Software
  39. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  40. */
  41. #pragma once
  42. /**
  43. * Based on "servo.h - Interrupt driven Servo library for Arduino using 16 bit timers -
  44. * Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
  45. *
  46. * The only modification was to update/delete macros to match the LPC176x.
  47. */
  48. #include <Servo.h>
  49. class libServo: public Servo {
  50. public:
  51. void move(const int value) {
  52. constexpr uint16_t servo_delay[] = SERVO_DELAY;
  53. static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
  54. if (attach(servo_info[servoIndex].Pin.nbr) >= 0) { // try to reattach
  55. write(value);
  56. safe_delay(servo_delay[servoIndex]); // delay to allow servo to reach position
  57. TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
  58. }
  59. }
  60. };
  61. #define HAL_SERVO_LIB libServo