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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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/MarlinConfig.h"
  23. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  24. #include "../../gcode.h"
  25. #include "../../../feature/pause.h"
  26. #include "../../../module/motion.h"
  27. #include "../../../module/printcounter.h"
  28. #include "../../../lcd/marlinui.h"
  29. #if HAS_MULTI_EXTRUDER
  30. #include "../../../module/tool_change.h"
  31. #endif
  32. #if ENABLED(HAS_PRUSA_MMU2)
  33. #include "../../../feature/mmu/mmu2.h"
  34. #if ENABLED(MMU2_MENUS)
  35. #include "../../../lcd/menu/menu_mmu2.h"
  36. #endif
  37. #endif
  38. #if ENABLED(MIXING_EXTRUDER)
  39. #include "../../../feature/mixing.h"
  40. #endif
  41. #if HAS_FILAMENT_SENSOR
  42. #include "../../../feature/runout.h"
  43. #endif
  44. /**
  45. * M600: Pause for filament change
  46. *
  47. * E[distance] - Retract the filament this far
  48. * Z[distance] - Move the Z axis by this distance
  49. * X[position] - Move to this X position (instead of NOZZLE_PARK_POINT.x)
  50. * Y[position] - Move to this Y position (instead of NOZZLE_PARK_POINT.y)
  51. * I[position] - Move to this I position (instead of NOZZLE_PARK_POINT.i)
  52. * J[position] - Move to this J position (instead of NOZZLE_PARK_POINT.j)
  53. * K[position] - Move to this K position (instead of NOZZLE_PARK_POINT.k)
  54. * C[position] - Move to this U position (instead of NOZZLE_PARK_POINT.u)
  55. * H[position] - Move to this V position (instead of NOZZLE_PARK_POINT.v)
  56. * O[position] - Move to this W position (instead of NOZZLE_PARK_POINT.w)
  57. * U[distance] - Retract distance for removal (manual reload)
  58. * L[distance] - Extrude distance for insertion (manual reload)
  59. * B[count] - Number of times to beep, -1 for indefinite (if equipped with a buzzer)
  60. * T[toolhead] - Select extruder for filament change
  61. * R[temp] - Resume temperature (in current units)
  62. *
  63. * Default values are used for omitted arguments.
  64. */
  65. void GcodeSuite::M600() {
  66. #if ENABLED(MIXING_EXTRUDER)
  67. const int8_t eindex = get_target_e_stepper_from_command();
  68. if (eindex < 0) return;
  69. const uint8_t old_mixing_tool = mixer.get_current_vtool();
  70. mixer.T(MIXER_DIRECT_SET_TOOL);
  71. MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0);
  72. mixer.normalize();
  73. const int8_t target_extruder = active_extruder;
  74. #else
  75. const int8_t target_extruder = get_target_extruder_from_command();
  76. if (target_extruder < 0) return;
  77. #endif
  78. #if ENABLED(DUAL_X_CARRIAGE)
  79. int8_t DXC_ext = target_extruder;
  80. if (!parser.seen_test('T')) { // If no tool index is specified, M600 was (probably) sent in response to filament runout.
  81. // In this case, for duplicating modes set DXC_ext to the extruder that ran out.
  82. #if MULTI_FILAMENT_SENSOR
  83. if (idex_is_duplicating())
  84. DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT2_STATE) ? 1 : 0;
  85. #else
  86. DXC_ext = active_extruder;
  87. #endif
  88. }
  89. #endif
  90. const bool standardM600 = TERN1(MMU2_MENUS, !mmu2.enabled());
  91. // Show initial "wait for start" message
  92. if (standardM600)
  93. ui.pause_show_message(PAUSE_MESSAGE_CHANGING, PAUSE_MODE_PAUSE_PRINT, target_extruder);
  94. // If needed, home before parking for filament change
  95. TERN_(HOME_BEFORE_FILAMENT_CHANGE, home_if_needed(true));
  96. #if HAS_MULTI_EXTRUDER
  97. // Change toolhead if specified
  98. const uint8_t active_extruder_before_filament_change = active_extruder;
  99. if (active_extruder != target_extruder && TERN1(DUAL_X_CARRIAGE, !idex_is_duplicating()))
  100. tool_change(target_extruder);
  101. #endif
  102. // Initial retract before move to filament change position
  103. const float retract = -ABS(parser.axisunitsval('E', E_AXIS, PAUSE_PARK_RETRACT_LENGTH));
  104. xyz_pos_t park_point NOZZLE_PARK_POINT;
  105. // Move XY axes to filament change position or given position
  106. NUM_AXIS_CODE(
  107. if (parser.seenval('X')) park_point.x = parser.linearval('X'),
  108. if (parser.seenval('Y')) park_point.y = parser.linearval('Y'),
  109. if (parser.seenval('Z')) park_point.z = parser.linearval('Z'), // Lift Z axis
  110. if (parser.seenval('I')) park_point.i = parser.linearval('I'),
  111. if (parser.seenval('J')) park_point.j = parser.linearval('J'),
  112. if (parser.seenval('K')) park_point.k = parser.linearval('K'),
  113. if (parser.seenval('C')) park_point.u = parser.linearval('C'), // U axis
  114. if (parser.seenval('H')) park_point.v = parser.linearval('H'), // V axis
  115. if (parser.seenval('O')) park_point.w = parser.linearval('O') // W axis
  116. );
  117. #if HAS_HOTEND_OFFSET && NONE(DUAL_X_CARRIAGE, DELTA)
  118. park_point += hotend_offset[active_extruder];
  119. #endif
  120. // Unload filament
  121. // For MMU2, when enabled, reset retract value so it doesn't mess with MMU filament handling
  122. const float unload_length = standardM600 ? -ABS(parser.axisunitsval('U', E_AXIS, fc_settings[active_extruder].unload_length)) : 0.5f;
  123. const int beep_count = parser.intval('B', -1
  124. #ifdef FILAMENT_CHANGE_ALERT_BEEPS
  125. + 1 + FILAMENT_CHANGE_ALERT_BEEPS
  126. #endif
  127. );
  128. if (pause_print(retract, park_point, true, unload_length DXC_PASS)) {
  129. if (standardM600) {
  130. wait_for_confirmation(true, beep_count DXC_PASS);
  131. resume_print(
  132. FILAMENT_CHANGE_SLOW_LOAD_LENGTH,
  133. ABS(parser.axisunitsval('L', E_AXIS, fc_settings[active_extruder].load_length)),
  134. ADVANCED_PAUSE_PURGE_LENGTH,
  135. beep_count,
  136. parser.celsiusval('R')
  137. DXC_PASS
  138. );
  139. }
  140. else {
  141. #if ENABLED(MMU2_MENUS)
  142. mmu2_M600();
  143. resume_print(0, 0, 0, beep_count, 0 DXC_PASS);
  144. #endif
  145. }
  146. }
  147. #if HAS_MULTI_EXTRUDER
  148. // Restore toolhead if it was changed
  149. if (active_extruder_before_filament_change != active_extruder)
  150. tool_change(active_extruder_before_filament_change);
  151. #endif
  152. TERN_(MIXING_EXTRUDER, mixer.T(old_mixing_tool)); // Restore original mixing tool
  153. }
  154. #endif // ADVANCED_PAUSE_FEATURE