My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

M600.cpp 6.0KB

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