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

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