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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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) || AXIS_HAS_STEALTHCHOP(Y) || AXIS_HAS_STEALTHCHOP(Y2) || AXIS_HAS_STEALTHCHOP(Z) || AXIS_HAS_STEALTHCHOP(Z2) || AXIS_HAS_STEALTHCHOP(Z3)
  42. const uint8_t index = parser.byteval('I');
  43. #endif
  44. LOOP_XYZE(i) if (parser.seen(axis_codes[i])) {
  45. switch (i) {
  46. case X_AXIS:
  47. #if AXIS_HAS_STEALTHCHOP(X)
  48. if (index == 0) TMC_SET_STEALTH(X);
  49. #endif
  50. #if AXIS_HAS_STEALTHCHOP(X2)
  51. if (index == 1) TMC_SET_STEALTH(X2);
  52. #endif
  53. break;
  54. case Y_AXIS:
  55. #if AXIS_HAS_STEALTHCHOP(Y)
  56. if (index == 0) TMC_SET_STEALTH(Y);
  57. #endif
  58. #if AXIS_HAS_STEALTHCHOP(Y2)
  59. if (index == 1) TMC_SET_STEALTH(Y2);
  60. #endif
  61. break;
  62. case Z_AXIS:
  63. #if AXIS_HAS_STEALTHCHOP(Z)
  64. if (index == 0) TMC_SET_STEALTH(Z);
  65. #endif
  66. #if AXIS_HAS_STEALTHCHOP(Z2)
  67. if (index == 1) TMC_SET_STEALTH(Z2);
  68. #endif
  69. #if AXIS_HAS_STEALTHCHOP(Z3)
  70. if (index == 2) TMC_SET_STEALTH(Z3);
  71. #endif
  72. break;
  73. case E_AXIS: {
  74. if (target_extruder < 0) return;
  75. switch (target_extruder) {
  76. #if AXIS_HAS_STEALTHCHOP(E0)
  77. case 0: TMC_SET_STEALTH(E0); break;
  78. #endif
  79. #if AXIS_HAS_STEALTHCHOP(E1)
  80. case 1: TMC_SET_STEALTH(E1); break;
  81. #endif
  82. #if AXIS_HAS_STEALTHCHOP(E2)
  83. case 2: TMC_SET_STEALTH(E2); break;
  84. #endif
  85. #if AXIS_HAS_STEALTHCHOP(E3)
  86. case 3: TMC_SET_STEALTH(E3); break;
  87. #endif
  88. #if AXIS_HAS_STEALTHCHOP(E4)
  89. case 4: TMC_SET_STEALTH(E4); break;
  90. #endif
  91. #if AXIS_HAS_STEALTHCHOP(E5)
  92. case 5: TMC_SET_STEALTH(E5); break;
  93. #endif
  94. }
  95. } break;
  96. }
  97. }
  98. }
  99. static void say_stealth_status() {
  100. #define TMC_SAY_STEALTH_STATUS(Q) tmc_say_stealth_status(stepper##Q)
  101. #if AXIS_HAS_STEALTHCHOP(X)
  102. TMC_SAY_STEALTH_STATUS(X);
  103. #endif
  104. #if AXIS_HAS_STEALTHCHOP(X2)
  105. TMC_SAY_STEALTH_STATUS(X2);
  106. #endif
  107. #if AXIS_HAS_STEALTHCHOP(Y)
  108. TMC_SAY_STEALTH_STATUS(Y);
  109. #endif
  110. #if AXIS_HAS_STEALTHCHOP(Y2)
  111. TMC_SAY_STEALTH_STATUS(Y2);
  112. #endif
  113. #if AXIS_HAS_STEALTHCHOP(Z)
  114. TMC_SAY_STEALTH_STATUS(Z);
  115. #endif
  116. #if AXIS_HAS_STEALTHCHOP(Z2)
  117. TMC_SAY_STEALTH_STATUS(Z2);
  118. #endif
  119. #if AXIS_HAS_STEALTHCHOP(Z3)
  120. TMC_SAY_STEALTH_STATUS(Z3);
  121. #endif
  122. #if AXIS_HAS_STEALTHCHOP(E0)
  123. TMC_SAY_STEALTH_STATUS(E0);
  124. #endif
  125. #if AXIS_HAS_STEALTHCHOP(E1)
  126. TMC_SAY_STEALTH_STATUS(E1);
  127. #endif
  128. #if AXIS_HAS_STEALTHCHOP(E2)
  129. TMC_SAY_STEALTH_STATUS(E2);
  130. #endif
  131. #if AXIS_HAS_STEALTHCHOP(E3)
  132. TMC_SAY_STEALTH_STATUS(E3);
  133. #endif
  134. #if AXIS_HAS_STEALTHCHOP(E4)
  135. TMC_SAY_STEALTH_STATUS(E4);
  136. #endif
  137. #if AXIS_HAS_STEALTHCHOP(E5)
  138. TMC_SAY_STEALTH_STATUS(E5);
  139. #endif
  140. }
  141. /**
  142. * M569: Enable stealthChop on an axis
  143. *
  144. * S[1|0] to enable or disable
  145. * XYZE to target an axis
  146. * No arguments reports the stealthChop status of all capable drivers.
  147. */
  148. void GcodeSuite::M569() {
  149. if (parser.seen('S'))
  150. set_stealth_status(parser.value_bool(), get_target_extruder_from_command());
  151. else
  152. say_stealth_status();
  153. }
  154. #endif // HAS_STEALTHCHOP