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.

M600.cpp 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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 <http://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. #if EXTRUDERS > 1
  29. #include "../../../module/tool_change.h"
  30. #endif
  31. #if HAS_LCD_MENU
  32. #include "../../../lcd/ultralcd.h"
  33. #endif
  34. #if ENABLED(MMU2_MENUS)
  35. #include "../../../lcd/menu/menu_mmu2.h"
  36. #endif
  37. #if ENABLED(MIXING_EXTRUDER)
  38. #include "../../../feature/mixing.h"
  39. #endif
  40. /**
  41. * M600: Pause for filament change
  42. *
  43. * E[distance] - Retract the filament this far
  44. * Z[distance] - Move the Z axis by this distance
  45. * X[position] - Move to this X position, with Y
  46. * Y[position] - Move to this Y position, with X
  47. * U[distance] - Retract distance for removal (manual reload)
  48. * L[distance] - Extrude distance for insertion (manual reload)
  49. * B[count] - Number of times to beep, -1 for indefinite (if equipped with a buzzer)
  50. * T[toolhead] - Select extruder for filament change
  51. *
  52. * Default values are used for omitted arguments.
  53. */
  54. void GcodeSuite::M600() {
  55. #if ENABLED(MIXING_EXTRUDER)
  56. const int8_t target_e_stepper = get_target_e_stepper_from_command();
  57. if (target_e_stepper < 0) return;
  58. const uint8_t old_mixing_tool = mixer.get_current_vtool();
  59. mixer.T(MIXER_DIRECT_SET_TOOL);
  60. MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(target_e_stepper) ? 1.0 : 0.0);
  61. mixer.normalize();
  62. const int8_t target_extruder = active_extruder;
  63. #else
  64. const int8_t target_extruder = get_target_extruder_from_command();
  65. if (target_extruder < 0) return;
  66. #endif
  67. #if ENABLED(DUAL_X_CARRIAGE)
  68. int8_t DXC_ext = target_extruder;
  69. if (!parser.seen('T')) { // If no tool index is specified, M600 was (probably) sent in response to filament runout.
  70. // In this case, for duplicating modes set DXC_ext to the extruder that ran out.
  71. #if HAS_FILAMENT_SENSOR && NUM_RUNOUT_SENSORS > 1
  72. if (dxc_is_duplicating())
  73. DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT_INVERTING) ? 1 : 0;
  74. #else
  75. DXC_ext = active_extruder;
  76. #endif
  77. }
  78. #endif
  79. // Show initial "wait for start" message
  80. #if HAS_LCD_MENU && DISABLED(MMU2_MENUS)
  81. lcd_pause_show_message(PAUSE_MESSAGE_CHANGING, PAUSE_MODE_PAUSE_PRINT, target_extruder);
  82. #endif
  83. #if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
  84. // Don't allow filament change without homing first
  85. if (axes_need_homing()) home_all_axes();
  86. #endif
  87. #if EXTRUDERS > 1
  88. // Change toolhead if specified
  89. const uint8_t active_extruder_before_filament_change = active_extruder;
  90. if (
  91. active_extruder != target_extruder
  92. #if ENABLED(DUAL_X_CARRIAGE)
  93. && dual_x_carriage_mode != DXC_DUPLICATION_MODE && dual_x_carriage_mode != DXC_MIRRORED_MODE
  94. #endif
  95. ) tool_change(target_extruder, false);
  96. #endif
  97. // Initial retract before move to filament change position
  98. const float retract = -ABS(parser.seen('E') ? parser.value_axis_units(E_AXIS) : (PAUSE_PARK_RETRACT_LENGTH));
  99. xyz_pos_t park_point NOZZLE_PARK_POINT;
  100. // Lift Z axis
  101. if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
  102. // Move XY axes to filament change position or given position
  103. if (parser.seenval('X')) park_point.x = parser.linearval('X');
  104. if (parser.seenval('Y')) park_point.y = parser.linearval('Y');
  105. #if HAS_HOTEND_OFFSET && NONE(DUAL_X_CARRIAGE, DELTA)
  106. park_point += hotend_offset[active_extruder];
  107. #endif
  108. #if ENABLED(MMU2_MENUS)
  109. // For MMU2 reset retract and load/unload values so they don't mess with MMU filament handling
  110. constexpr float unload_length = 0.5f,
  111. slow_load_length = 0.0f,
  112. fast_load_length = 0.0f;
  113. #else
  114. // Unload filament
  115. const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
  116. : fc_settings[active_extruder].unload_length);
  117. // Slow load filament
  118. constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
  119. // Fast load filament
  120. const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
  121. : fc_settings[active_extruder].load_length);
  122. #endif
  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, unload_length, true DXC_PASS)) {
  129. #if ENABLED(MMU2_MENUS)
  130. mmu2_M600();
  131. resume_print(slow_load_length, fast_load_length, 0, beep_count DXC_PASS);
  132. #else
  133. wait_for_confirmation(true, beep_count DXC_PASS);
  134. resume_print(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, beep_count DXC_PASS);
  135. #endif
  136. }
  137. #if EXTRUDERS > 1
  138. // Restore toolhead if it was changed
  139. if (active_extruder_before_filament_change != active_extruder)
  140. tool_change(active_extruder_before_filament_change, false);
  141. #endif
  142. TERN_(MIXING_EXTRUDER, mixer.T(old_mixing_tool)); // Restore original mixing tool
  143. }
  144. #endif // ADVANCED_PAUSE_FEATURE