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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * module/servo.h
  25. */
  26. #include "../inc/MarlinConfig.h"
  27. #include "../HAL/shared/servo.h"
  28. #if HAS_SERVO_ANGLES
  29. #if ENABLED(SWITCHING_EXTRUDER)
  30. #ifndef SWITCHING_EXTRUDER_E23_SERVO_NR
  31. #define SWITCHING_EXTRUDER_E23_SERVO_NR -1
  32. #endif
  33. #if EXTRUDERS > 3
  34. #define REQ_ANGLES 4
  35. #else
  36. #define REQ_ANGLES 2
  37. #endif
  38. #define SADATA SWITCHING_EXTRUDER_SERVO_ANGLES
  39. #define ASRC(N,E) (SWITCHING_EXTRUDER_SERVO_NR == N ? asrc[E] : SWITCHING_EXTRUDER_E23_SERVO_NR == N ? asrc[E+2] : 0)
  40. #elif ENABLED(SWITCHING_NOZZLE)
  41. #define SADATA SWITCHING_NOZZLE_SERVO_ANGLES
  42. #define ASRC(N,E) (SWITCHING_NOZZLE_SERVO_NR == N ? asrc[E] : 0)
  43. #elif defined(Z_SERVO_ANGLES) && defined(Z_PROBE_SERVO_NR)
  44. #define SADATA Z_SERVO_ANGLES
  45. #define ASRC(N,E) (Z_PROBE_SERVO_NR == N ? asrc[E] : 0)
  46. #endif
  47. #if ENABLED(EDITABLE_SERVO_ANGLES)
  48. extern uint16_t servo_angles[NUM_SERVOS][2];
  49. #define BASE_SERVO_ANGLES base_servo_angles
  50. #else
  51. #define BASE_SERVO_ANGLES servo_angles
  52. #endif
  53. constexpr uint16_t asrc[] = SADATA;
  54. #if REQ_ANGLES
  55. static_assert(COUNT(asrc) == REQ_ANGLES, "SWITCHING_EXTRUDER_SERVO_ANGLES needs " STRINGIFY(REQ_ANGLES) " angles.");
  56. #endif
  57. constexpr uint16_t BASE_SERVO_ANGLES [NUM_SERVOS][2] = {
  58. { ASRC(0,0), ASRC(0,1) }
  59. #if NUM_SERVOS > 1
  60. , { ASRC(1,0), ASRC(1,1) }
  61. #if NUM_SERVOS > 2
  62. , { ASRC(2,0), ASRC(2,1) }
  63. #if NUM_SERVOS > 3
  64. , { ASRC(3,0), ASRC(3,1) }
  65. #endif
  66. #endif
  67. #endif
  68. };
  69. #if HAS_Z_SERVO_PROBE
  70. #define DEPLOY_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][0])
  71. #define STOW_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][1])
  72. #endif
  73. #endif // HAS_SERVO_ANGLES
  74. #define MOVE_SERVO(I, P) servo[I].move(P)
  75. extern HAL_SERVO_LIB servo[NUM_SERVOS];
  76. extern void servo_init();