My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

M217.cpp 6.3KB

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