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.

M217.cpp 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../inc/MarlinConfigPre.h"
  23. #if HAS_MULTI_EXTRUDER
  24. #include "../gcode.h"
  25. #include "../../module/tool_change.h"
  26. #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
  27. #include "../../module/motion.h"
  28. #endif
  29. #include "../../MarlinCore.h" // for SP_X_STR, etc.
  30. void M217_report(const bool eeprom=false) {
  31. #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
  32. serialprintPGM(eeprom ? PSTR(" M217") : PSTR("Toolchange:"));
  33. SERIAL_ECHOPAIR(" S", LINEAR_UNIT(toolchange_settings.swap_length));
  34. SERIAL_ECHOPAIR_P(SP_B_STR, LINEAR_UNIT(toolchange_settings.extra_resume),
  35. SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime),
  36. SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed));
  37. SERIAL_ECHOPAIR(" R", LINEAR_UNIT(toolchange_settings.retract_speed),
  38. " U", LINEAR_UNIT(toolchange_settings.unretract_speed),
  39. " F", toolchange_settings.fan_speed,
  40. " G", toolchange_settings.fan_time);
  41. #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
  42. SERIAL_ECHOPAIR(" A", migration.automode);
  43. SERIAL_ECHOPAIR(" L", LINEAR_UNIT(migration.last));
  44. #endif
  45. #if ENABLED(TOOLCHANGE_PARK)
  46. SERIAL_ECHOPAIR(" W", LINEAR_UNIT(toolchange_settings.enable_park));
  47. SERIAL_ECHOPAIR_P(SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x));
  48. SERIAL_ECHOPAIR_P(SP_Y_STR, LINEAR_UNIT(toolchange_settings.change_point.y));
  49. #endif
  50. #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED)
  51. SERIAL_ECHOPAIR(" V", LINEAR_UNIT(enable_first_prime));
  52. #endif
  53. #else
  54. UNUSED(eeprom);
  55. #endif
  56. SERIAL_ECHOPAIR_P(SP_Z_STR, LINEAR_UNIT(toolchange_settings.z_raise));
  57. SERIAL_EOL();
  58. }
  59. /**
  60. * M217 - Set SINGLENOZZLE toolchange parameters
  61. *
  62. * // Tool change command
  63. * Q Prime active tool and exit
  64. *
  65. * // Tool change settings
  66. * S[linear] Swap length
  67. * B[linear] Extra Swap length
  68. * E[linear] Prime length
  69. * P[linear/m] Prime speed
  70. * R[linear/m] Retract speed
  71. * U[linear/m] UnRetract speed
  72. * V[linear] 0/1 Enable auto prime first extruder used
  73. * W[linear] 0/1 Enable park & Z Raise
  74. * X[linear] Park X (Requires TOOLCHANGE_PARK)
  75. * Y[linear] Park Y (Requires TOOLCHANGE_PARK)
  76. * Z[linear] Z Raise
  77. * F[linear] Fan Speed 0-255
  78. * G[linear/s] Fan time
  79. *
  80. * Tool migration settings
  81. * A[0|1] Enable auto-migration on runout
  82. * L[index] Last extruder to use for auto-migration
  83. *
  84. * Tool migration command
  85. * T[index] Migrate to next extruder or the given extruder
  86. */
  87. void GcodeSuite::M217() {
  88. #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
  89. static constexpr float max_extrude = TERN(PREVENT_LENGTHY_EXTRUDE, EXTRUDE_MAXLENGTH, 500);
  90. if (parser.seen('Q')) { tool_change_prime(); return; }
  91. if (parser.seenval('S')) { const float v = parser.value_linear_units(); toolchange_settings.swap_length = constrain(v, 0, max_extrude); }
  92. if (parser.seenval('B')) { const float v = parser.value_linear_units(); toolchange_settings.extra_resume = constrain(v, -10, 10); }
  93. if (parser.seenval('E')) { const float v = parser.value_linear_units(); toolchange_settings.extra_prime = constrain(v, 0, max_extrude); }
  94. if (parser.seenval('P')) { const int16_t v = parser.value_linear_units(); toolchange_settings.prime_speed = constrain(v, 10, 5400); }
  95. if (parser.seenval('R')) { const int16_t v = parser.value_linear_units(); toolchange_settings.retract_speed = constrain(v, 10, 5400); }
  96. if (parser.seenval('U')) { const int16_t v = parser.value_linear_units(); toolchange_settings.unretract_speed = constrain(v, 10, 5400); }
  97. #if TOOLCHANGE_FS_FAN >= 0 && HAS_FAN
  98. if (parser.seenval('F')) { const int16_t v = parser.value_linear_units(); toolchange_settings.fan_speed = constrain(v, 0, 255); }
  99. if (parser.seenval('G')) { const int16_t v = parser.value_linear_units(); toolchange_settings.fan_time = constrain(v, 1, 30); }
  100. #endif
  101. #endif
  102. #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED)
  103. if (parser.seenval('V')) { enable_first_prime = parser.value_linear_units(); }
  104. #endif
  105. #if ENABLED(TOOLCHANGE_PARK)
  106. if (parser.seenval('W')) { toolchange_settings.enable_park = parser.value_linear_units(); }
  107. if (parser.seenval('X')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.x = constrain(v, X_MIN_POS, X_MAX_POS); }
  108. if (parser.seenval('Y')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.y = constrain(v, Y_MIN_POS, Y_MAX_POS); }
  109. #endif
  110. if (parser.seenval('Z')) { toolchange_settings.z_raise = parser.value_linear_units(); }
  111. #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
  112. migration.target = 0; // 0 = disabled
  113. if (parser.seenval('L')) { // Last
  114. const int16_t lval = parser.value_int();
  115. if (WITHIN(lval, 0, EXTRUDERS - 1)) {
  116. migration.last = lval;
  117. migration.automode = (active_extruder < migration.last);
  118. }
  119. }
  120. if (parser.seen('A')) // Auto on/off
  121. migration.automode = parser.value_bool();
  122. if (parser.seen('T')) { // Migrate now
  123. if (parser.has_value()) {
  124. const int16_t tval = parser.value_int();
  125. if (WITHIN(tval, 0, EXTRUDERS - 1) && tval != active_extruder) {
  126. migration.target = tval + 1;
  127. extruder_migration();
  128. migration.target = 0; // disable
  129. return;
  130. }
  131. else
  132. migration.target = 0; // disable
  133. }
  134. else {
  135. extruder_migration();
  136. return;
  137. }
  138. }
  139. #endif
  140. M217_report();
  141. }
  142. #endif // HAS_MULTI_EXTRUDER