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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. #ifndef __MARLIN_H__
  23. #define __MARLIN_H__
  24. #include "inc/MarlinConfig.h"
  25. #ifdef DEBUG_GCODE_PARSER
  26. #include "gcode/parser.h"
  27. #endif
  28. #include <math.h>
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. void stop();
  32. void idle(
  33. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  34. bool no_stepper_sleep = false // pass true to keep steppers from disabling on timeout
  35. #endif
  36. );
  37. void manage_inactivity(const bool ignore_stepper_queue=false);
  38. #if HAS_X2_ENABLE
  39. #define enable_X() do{ X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); }while(0)
  40. #define disable_X() do{ X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); CBI(axis_known_position, X_AXIS); }while(0)
  41. #elif HAS_X_ENABLE
  42. #define enable_X() X_ENABLE_WRITE( X_ENABLE_ON)
  43. #define disable_X() do{ X_ENABLE_WRITE(!X_ENABLE_ON); CBI(axis_known_position, X_AXIS); }while(0)
  44. #else
  45. #define enable_X() NOOP
  46. #define disable_X() NOOP
  47. #endif
  48. #if HAS_Y2_ENABLE
  49. #define enable_Y() do{ Y_ENABLE_WRITE( Y_ENABLE_ON); Y2_ENABLE_WRITE(Y_ENABLE_ON); }while(0)
  50. #define disable_Y() do{ Y_ENABLE_WRITE(!Y_ENABLE_ON); Y2_ENABLE_WRITE(!Y_ENABLE_ON); CBI(axis_known_position, Y_AXIS); }while(0)
  51. #elif HAS_Y_ENABLE
  52. #define enable_Y() Y_ENABLE_WRITE( Y_ENABLE_ON)
  53. #define disable_Y() do{ Y_ENABLE_WRITE(!Y_ENABLE_ON); CBI(axis_known_position, Y_AXIS); }while(0)
  54. #else
  55. #define enable_Y() NOOP
  56. #define disable_Y() NOOP
  57. #endif
  58. #if HAS_Z3_ENABLE
  59. #define enable_Z() do{ Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); Z3_ENABLE_WRITE(Z_ENABLE_ON); }while(0)
  60. #define disable_Z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); Z3_ENABLE_WRITE(!Z_ENABLE_ON); CBI(axis_known_position, Z_AXIS); }while(0)
  61. #elif HAS_Z2_ENABLE
  62. #define enable_Z() do{ Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); }while(0)
  63. #define disable_Z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); CBI(axis_known_position, Z_AXIS); }while(0)
  64. #elif HAS_Z_ENABLE
  65. #define enable_Z() Z_ENABLE_WRITE( Z_ENABLE_ON)
  66. #define disable_Z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); CBI(axis_known_position, Z_AXIS); }while(0)
  67. #else
  68. #define enable_Z() NOOP
  69. #define disable_Z() NOOP
  70. #endif
  71. #if ENABLED(MIXING_EXTRUDER)
  72. /**
  73. * Mixing steppers synchronize their enable (and direction) together
  74. */
  75. #if MIXING_STEPPERS > 5
  76. #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); E4_ENABLE_WRITE( E_ENABLE_ON); E5_ENABLE_WRITE( E_ENABLE_ON); }
  77. #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); E4_ENABLE_WRITE(!E_ENABLE_ON); E5_ENABLE_WRITE(!E_ENABLE_ON); }
  78. #elif MIXING_STEPPERS > 4
  79. #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); E4_ENABLE_WRITE( E_ENABLE_ON); }
  80. #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); E4_ENABLE_WRITE(!E_ENABLE_ON); }
  81. #elif MIXING_STEPPERS > 3
  82. #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); }
  83. #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); }
  84. #elif MIXING_STEPPERS > 2
  85. #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); }
  86. #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); }
  87. #else
  88. #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); }
  89. #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); }
  90. #endif
  91. #define enable_E1() NOOP
  92. #define disable_E1() NOOP
  93. #define enable_E2() NOOP
  94. #define disable_E2() NOOP
  95. #define enable_E3() NOOP
  96. #define disable_E3() NOOP
  97. #define enable_E4() NOOP
  98. #define disable_E4() NOOP
  99. #define enable_E5() NOOP
  100. #define disable_E5() NOOP
  101. #else // !MIXING_EXTRUDER
  102. #if HAS_E0_ENABLE
  103. #define enable_E0() E0_ENABLE_WRITE( E_ENABLE_ON)
  104. #define disable_E0() E0_ENABLE_WRITE(!E_ENABLE_ON)
  105. #else
  106. #define enable_E0() NOOP
  107. #define disable_E0() NOOP
  108. #endif
  109. #if E_STEPPERS > 1 && HAS_E1_ENABLE
  110. #define enable_E1() E1_ENABLE_WRITE( E_ENABLE_ON)
  111. #define disable_E1() E1_ENABLE_WRITE(!E_ENABLE_ON)
  112. #else
  113. #define enable_E1() NOOP
  114. #define disable_E1() NOOP
  115. #endif
  116. #if E_STEPPERS > 2 && HAS_E2_ENABLE
  117. #define enable_E2() E2_ENABLE_WRITE( E_ENABLE_ON)
  118. #define disable_E2() E2_ENABLE_WRITE(!E_ENABLE_ON)
  119. #else
  120. #define enable_E2() NOOP
  121. #define disable_E2() NOOP
  122. #endif
  123. #if E_STEPPERS > 3 && HAS_E3_ENABLE
  124. #define enable_E3() E3_ENABLE_WRITE( E_ENABLE_ON)
  125. #define disable_E3() E3_ENABLE_WRITE(!E_ENABLE_ON)
  126. #else
  127. #define enable_E3() NOOP
  128. #define disable_E3() NOOP
  129. #endif
  130. #if E_STEPPERS > 4 && HAS_E4_ENABLE
  131. #define enable_E4() E4_ENABLE_WRITE( E_ENABLE_ON)
  132. #define disable_E4() E4_ENABLE_WRITE(!E_ENABLE_ON)
  133. #else
  134. #define enable_E4() NOOP
  135. #define disable_E4() NOOP
  136. #endif
  137. #if E_STEPPERS > 5 && HAS_E5_ENABLE
  138. #define enable_E5() E5_ENABLE_WRITE( E_ENABLE_ON)
  139. #define disable_E5() E5_ENABLE_WRITE(!E_ENABLE_ON)
  140. #else
  141. #define enable_E5() NOOP
  142. #define disable_E5() NOOP
  143. #endif
  144. #endif // !MIXING_EXTRUDER
  145. #if ENABLED(EXPERIMENTAL_I2CBUS)
  146. #include "feature/twibus.h"
  147. extern TWIBus i2c;
  148. #endif
  149. #if ENABLED(G38_PROBE_TARGET)
  150. extern bool G38_move, // flag to tell the interrupt handler that a G38 command is being run
  151. G38_endstop_hit; // flag from the interrupt handler to indicate if the endstop went active
  152. #endif
  153. /**
  154. * The axis order in all axis related arrays is X, Y, Z, E
  155. */
  156. void enable_all_steppers();
  157. void disable_e_stepper(const uint8_t e);
  158. void disable_e_steppers();
  159. void disable_all_steppers();
  160. void kill(const char*);
  161. void quickstop_stepper();
  162. extern bool Running;
  163. inline bool IsRunning() { return Running; }
  164. inline bool IsStopped() { return !Running; }
  165. extern uint8_t axis_homed, axis_known_position;
  166. constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);
  167. FORCE_INLINE bool all_axes_homed() { return (axis_homed & xyz_bits) == xyz_bits; }
  168. FORCE_INLINE bool all_axes_known() { return (axis_known_position & xyz_bits) == xyz_bits; }
  169. extern volatile bool wait_for_heatup;
  170. #if HAS_RESUME_CONTINUE
  171. extern volatile bool wait_for_user;
  172. #endif
  173. #if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
  174. extern bool suspend_auto_report;
  175. #endif
  176. // Inactivity shutdown timer
  177. extern millis_t max_inactive_time, stepper_inactive_time;
  178. #if FAN_COUNT > 0
  179. extern int16_t fanSpeeds[FAN_COUNT];
  180. #if ENABLED(EXTRA_FAN_SPEED)
  181. extern int16_t old_fanSpeeds[FAN_COUNT],
  182. new_fanSpeeds[FAN_COUNT];
  183. #endif
  184. #if ENABLED(PROBING_FANS_OFF)
  185. extern bool fans_paused;
  186. extern int16_t paused_fanSpeeds[FAN_COUNT];
  187. #endif
  188. #endif
  189. #if ENABLED(USE_CONTROLLER_FAN)
  190. extern uint8_t controllerFanSpeed;
  191. #endif
  192. #if HAS_POWER_SWITCH
  193. extern bool powersupply_on;
  194. #define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); powersupply_on = true; }while(0)
  195. #define PSU_PIN_OFF() do{ OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP); powersupply_on = false; }while(0)
  196. #if ENABLED(AUTO_POWER_CONTROL)
  197. #define PSU_ON() powerManager.power_on()
  198. #define PSU_OFF() powerManager.power_off()
  199. #else
  200. #define PSU_ON() PSU_PIN_ON()
  201. #define PSU_OFF() PSU_PIN_OFF()
  202. #endif
  203. #endif
  204. bool pin_is_protected(const pin_t pin);
  205. void protected_pin_err();
  206. #if HAS_SUICIDE
  207. inline void suicide() { OUT_WRITE(SUICIDE_PIN, LOW); }
  208. #endif
  209. #endif // __MARLIN_H__