My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

M600.cpp 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. #if HAS_MULTI_EXTRUDER
  29. #include "../../../module/tool_change.h"
  30. #endif
  31. #if HAS_LCD_MENU
  32. #include "../../../lcd/marlinui.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. #if HAS_FILAMENT_SENSOR
  41. #include "../../../feature/runout.h"
  42. #endif
  43. /**
  44. * M600: Pause for filament change
  45. *
  46. * E[distance] - Retract the filament this far
  47. * Z[distance] - Move the Z axis by this distance
  48. * X[position] - Move to this X position, with Y
  49. * Y[position] - Move to this Y position, with X
  50. * U[distance] - Retract distance for removal (manual reload)
  51. * L[distance] - Extrude distance for insertion (manual reload)
  52. * B[count] - Number of times to beep, -1 for indefinite (if equipped with a buzzer)
  53. * T[toolhead] - Select extruder for filament change
  54. * R[temp] - Resume temperature (in current units)
  55. *
  56. * Default values are used for omitted arguments.
  57. */
  58. void GcodeSuite::M600() {
  59. #if ENABLED(MIXING_EXTRUDER)
  60. const int8_t target_e_stepper = get_target_e_stepper_from_command();
  61. if (target_e_stepper < 0) return;
  62. const uint8_t old_mixing_tool = mixer.get_current_vtool();
  63. mixer.T(MIXER_DIRECT_SET_TOOL);
  64. MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(target_e_stepper) ? 1.0 : 0.0);
  65. mixer.normalize();
  66. const int8_t target_extruder = active_extruder;
  67. #else
  68. const int8_t target_extruder = get_target_extruder_from_command();
  69. if (target_extruder < 0) return;
  70. #endif
  71. #if ENABLED(DUAL_X_CARRIAGE)
  72. int8_t DXC_ext = target_extruder;
  73. if (!parser.seen('T')) { // If no tool index is specified, M600 was (probably) sent in response to filament runout.
  74. // In this case, for duplicating modes set DXC_ext to the extruder that ran out.
  75. #if HAS_FILAMENT_SENSOR && NUM_RUNOUT_SENSORS > 1
  76. if (idex_is_duplicating())
  77. DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT_STATE) ? 1 : 0;
  78. #else
  79. DXC_ext = active_extruder;
  80. #endif
  81. }
  82. #endif
  83. // Show initial "wait for start" message
  84. #if HAS_LCD_MENU && DISABLED(MMU2_MENUS)
  85. lcd_pause_show_message(PAUSE_MESSAGE_CHANGING, PAUSE_MODE_PAUSE_PRINT, target_extruder);
  86. #endif
  87. #if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
  88. // If needed, home before parking for filament change
  89. if (!all_axes_known()) home_all_axes();
  90. #endif
  91. #if HAS_MULTI_EXTRUDER
  92. // Change toolhead if specified
  93. const uint8_t active_extruder_before_filament_change = active_extruder;
  94. if (active_extruder != target_extruder && TERN1(DUAL_X_CARRIAGE, !idex_is_duplicating()))
  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,
  135. beep_count, (parser.seenval('R') ? parser.value_celsius() : 0) DXC_PASS);
  136. #endif
  137. }
  138. #if HAS_MULTI_EXTRUDER
  139. // Restore toolhead if it was changed
  140. if (active_extruder_before_filament_change != active_extruder)
  141. tool_change(active_extruder_before_filament_change, false);
  142. #endif
  143. TERN_(MIXING_EXTRUDER, mixer.T(old_mixing_tool)); // Restore original mixing tool
  144. }
  145. #endif // ADVANCED_PAUSE_FEATURE