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.

M569.cpp 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 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. #include "../../../inc/MarlinConfig.h"
  23. #if HAS_STEALTHCHOP
  24. #include "../../gcode.h"
  25. #include "../../../feature/tmc_util.h"
  26. #include "../../../module/stepper/indirection.h"
  27. template<typename TMC>
  28. void tmc_say_stealth_status(TMC &st) {
  29. st.printLabel();
  30. SERIAL_ECHOPGM(" driver mode:\t");
  31. serialprintPGM(st.get_stealthChop_status() ? PSTR("stealthChop") : PSTR("spreadCycle"));
  32. SERIAL_EOL();
  33. }
  34. template<typename TMC>
  35. void tmc_set_stealthChop(TMC &st, const bool enable) {
  36. st.stored.stealthChop_enabled = enable;
  37. st.refresh_stepping_mode();
  38. }
  39. static void set_stealth_status(const bool enable, const int8_t target_extruder) {
  40. #define TMC_SET_STEALTH(Q) tmc_set_stealthChop(stepper##Q, enable)
  41. #if AXIS_HAS_STEALTHCHOP(X) || AXIS_HAS_STEALTHCHOP(X2) \
  42. || AXIS_HAS_STEALTHCHOP(Y) || AXIS_HAS_STEALTHCHOP(Y2) \
  43. || AXIS_HAS_STEALTHCHOP(Z) || AXIS_HAS_STEALTHCHOP(Z2) \
  44. || AXIS_HAS_STEALTHCHOP(Z3) || AXIS_HAS_STEALTHCHOP(Z4)
  45. const uint8_t index = parser.byteval('I');
  46. #endif
  47. LOOP_XYZE(i) if (parser.seen(axis_codes[i])) {
  48. switch (i) {
  49. case X_AXIS:
  50. #if AXIS_HAS_STEALTHCHOP(X)
  51. if (index == 0) TMC_SET_STEALTH(X);
  52. #endif
  53. #if AXIS_HAS_STEALTHCHOP(X2)
  54. if (index == 1) TMC_SET_STEALTH(X2);
  55. #endif
  56. break;
  57. case Y_AXIS:
  58. #if AXIS_HAS_STEALTHCHOP(Y)
  59. if (index == 0) TMC_SET_STEALTH(Y);
  60. #endif
  61. #if AXIS_HAS_STEALTHCHOP(Y2)
  62. if (index == 1) TMC_SET_STEALTH(Y2);
  63. #endif
  64. break;
  65. case Z_AXIS:
  66. #if AXIS_HAS_STEALTHCHOP(Z)
  67. if (index == 0) TMC_SET_STEALTH(Z);
  68. #endif
  69. #if AXIS_HAS_STEALTHCHOP(Z2)
  70. if (index == 1) TMC_SET_STEALTH(Z2);
  71. #endif
  72. #if AXIS_HAS_STEALTHCHOP(Z3)
  73. if (index == 2) TMC_SET_STEALTH(Z3);
  74. #endif
  75. #if AXIS_HAS_STEALTHCHOP(Z4)
  76. if (index == 3) TMC_SET_STEALTH(Z4);
  77. #endif
  78. break;
  79. case E_AXIS: {
  80. if (target_extruder < 0) return;
  81. switch (target_extruder) {
  82. #if AXIS_HAS_STEALTHCHOP(E0)
  83. case 0: TMC_SET_STEALTH(E0); break;
  84. #endif
  85. #if AXIS_HAS_STEALTHCHOP(E1)
  86. case 1: TMC_SET_STEALTH(E1); break;
  87. #endif
  88. #if AXIS_HAS_STEALTHCHOP(E2)
  89. case 2: TMC_SET_STEALTH(E2); break;
  90. #endif
  91. #if AXIS_HAS_STEALTHCHOP(E3)
  92. case 3: TMC_SET_STEALTH(E3); break;
  93. #endif
  94. #if AXIS_HAS_STEALTHCHOP(E4)
  95. case 4: TMC_SET_STEALTH(E4); break;
  96. #endif
  97. #if AXIS_HAS_STEALTHCHOP(E5)
  98. case 5: TMC_SET_STEALTH(E5); break;
  99. #endif
  100. }
  101. } break;
  102. }
  103. }
  104. }
  105. static void say_stealth_status() {
  106. #define TMC_SAY_STEALTH_STATUS(Q) tmc_say_stealth_status(stepper##Q)
  107. #if AXIS_HAS_STEALTHCHOP(X)
  108. TMC_SAY_STEALTH_STATUS(X);
  109. #endif
  110. #if AXIS_HAS_STEALTHCHOP(X2)
  111. TMC_SAY_STEALTH_STATUS(X2);
  112. #endif
  113. #if AXIS_HAS_STEALTHCHOP(Y)
  114. TMC_SAY_STEALTH_STATUS(Y);
  115. #endif
  116. #if AXIS_HAS_STEALTHCHOP(Y2)
  117. TMC_SAY_STEALTH_STATUS(Y2);
  118. #endif
  119. #if AXIS_HAS_STEALTHCHOP(Z)
  120. TMC_SAY_STEALTH_STATUS(Z);
  121. #endif
  122. #if AXIS_HAS_STEALTHCHOP(Z2)
  123. TMC_SAY_STEALTH_STATUS(Z2);
  124. #endif
  125. #if AXIS_HAS_STEALTHCHOP(Z3)
  126. TMC_SAY_STEALTH_STATUS(Z3);
  127. #endif
  128. #if AXIS_HAS_STEALTHCHOP(Z4)
  129. TMC_SAY_STEALTH_STATUS(Z4);
  130. #endif
  131. #if AXIS_HAS_STEALTHCHOP(E0)
  132. TMC_SAY_STEALTH_STATUS(E0);
  133. #endif
  134. #if AXIS_HAS_STEALTHCHOP(E1)
  135. TMC_SAY_STEALTH_STATUS(E1);
  136. #endif
  137. #if AXIS_HAS_STEALTHCHOP(E2)
  138. TMC_SAY_STEALTH_STATUS(E2);
  139. #endif
  140. #if AXIS_HAS_STEALTHCHOP(E3)
  141. TMC_SAY_STEALTH_STATUS(E3);
  142. #endif
  143. #if AXIS_HAS_STEALTHCHOP(E4)
  144. TMC_SAY_STEALTH_STATUS(E4);
  145. #endif
  146. #if AXIS_HAS_STEALTHCHOP(E5)
  147. TMC_SAY_STEALTH_STATUS(E5);
  148. #endif
  149. }
  150. /**
  151. * M569: Enable stealthChop on an axis
  152. *
  153. * S[1|0] to enable or disable
  154. * XYZE to target an axis
  155. * No arguments reports the stealthChop status of all capable drivers.
  156. */
  157. void GcodeSuite::M569() {
  158. if (parser.seen('S'))
  159. set_stealth_status(parser.value_bool(), get_target_extruder_from_command());
  160. else
  161. say_stealth_status();
  162. }
  163. #endif // HAS_STEALTHCHOP