My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 <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. // Switching extruder can have 2 or 4 angles
  31. #if EXTRUDERS > 3
  32. #define REQ_ANGLES 4
  33. #else
  34. #define REQ_ANGLES 2
  35. #endif
  36. constexpr uint16_t sase[] = SWITCHING_EXTRUDER_SERVO_ANGLES;
  37. static_assert(COUNT(sase) == REQ_ANGLES, "SWITCHING_EXTRUDER_SERVO_ANGLES needs " STRINGIFY(REQ_ANGLES) " angles.");
  38. #else
  39. constexpr uint16_t sase[4] = { 0 };
  40. #endif
  41. #if ENABLED(SWITCHING_NOZZLE)
  42. constexpr uint16_t sasn[] = SWITCHING_NOZZLE_SERVO_ANGLES;
  43. static_assert(COUNT(sasn) == 2, "SWITCHING_NOZZLE_SERVO_ANGLES needs 2 angles.");
  44. #else
  45. constexpr uint16_t sasn[2] = { 0 };
  46. #endif
  47. #ifdef Z_PROBE_SERVO_NR
  48. #if ENABLED(BLTOUCH)
  49. #include "../feature/bltouch.h"
  50. #undef Z_SERVO_ANGLES
  51. #define Z_SERVO_ANGLES { BLTOUCH_DEPLOY, BLTOUCH_STOW }
  52. #endif
  53. constexpr uint16_t sazp[] = Z_SERVO_ANGLES;
  54. static_assert(COUNT(sazp) == 2, "Z_SERVO_ANGLES needs 2 angles.");
  55. #else
  56. constexpr uint16_t sazp[2] = { 0 };
  57. #endif
  58. #ifndef SWITCHING_EXTRUDER_SERVO_NR
  59. #define SWITCHING_EXTRUDER_SERVO_NR -1
  60. #endif
  61. #ifndef SWITCHING_EXTRUDER_E23_SERVO_NR
  62. #define SWITCHING_EXTRUDER_E23_SERVO_NR -1
  63. #endif
  64. #ifndef SWITCHING_NOZZLE_SERVO_NR
  65. #define SWITCHING_NOZZLE_SERVO_NR -1
  66. #endif
  67. #ifndef Z_PROBE_SERVO_NR
  68. #define Z_PROBE_SERVO_NR -1
  69. #endif
  70. #define ASRC(N,I) ( \
  71. N == SWITCHING_EXTRUDER_SERVO_NR ? sase[I] \
  72. : N == SWITCHING_EXTRUDER_E23_SERVO_NR ? sase[I+2] \
  73. : N == SWITCHING_NOZZLE_SERVO_NR ? sasn[I] \
  74. : N == Z_PROBE_SERVO_NR ? sazp[I] \
  75. : 0 )
  76. #if ENABLED(EDITABLE_SERVO_ANGLES)
  77. extern uint16_t servo_angles[NUM_SERVOS][2];
  78. #define CONST_SERVO_ANGLES base_servo_angles
  79. #else
  80. #define CONST_SERVO_ANGLES servo_angles
  81. #endif
  82. constexpr uint16_t CONST_SERVO_ANGLES [NUM_SERVOS][2] = {
  83. { ASRC(0,0), ASRC(0,1) }
  84. #if NUM_SERVOS > 1
  85. , { ASRC(1,0), ASRC(1,1) }
  86. #if NUM_SERVOS > 2
  87. , { ASRC(2,0), ASRC(2,1) }
  88. #if NUM_SERVOS > 3
  89. , { ASRC(3,0), ASRC(3,1) }
  90. #endif
  91. #endif
  92. #endif
  93. };
  94. #if HAS_Z_SERVO_PROBE
  95. #define DEPLOY_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][0])
  96. #define STOW_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][1])
  97. #endif
  98. #endif // HAS_SERVO_ANGLES
  99. #define MOVE_SERVO(I, P) servo[I].move(P)
  100. extern HAL_SERVO_LIB servo[NUM_SERVOS];
  101. extern void servo_init();