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 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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 ENABLED(ULTIPANEL)
  32. #include "../../../lcd/ultralcd.h"
  33. #endif
  34. /**
  35. * M600: Pause for filament change
  36. *
  37. * E[distance] - Retract the filament this far
  38. * Z[distance] - Move the Z axis by this distance
  39. * X[position] - Move to this X position, with Y
  40. * Y[position] - Move to this Y position, with X
  41. * U[distance] - Retract distance for removal (manual reload)
  42. * L[distance] - Extrude distance for insertion (manual reload)
  43. * B[count] - Number of times to beep, -1 for indefinite (if equipped with a buzzer)
  44. * T[toolhead] - Select extruder for filament change
  45. *
  46. * Default values are used for omitted arguments.
  47. */
  48. void GcodeSuite::M600() {
  49. point_t park_point = NOZZLE_PARK_POINT;
  50. if (get_target_extruder_from_command()) return;
  51. // Show initial "wait for start" message
  52. #if ENABLED(ULTIPANEL)
  53. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT, ADVANCED_PAUSE_MODE_PAUSE_PRINT, target_extruder);
  54. #endif
  55. #if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
  56. // Don't allow filament change without homing first
  57. if (axis_unhomed_error()) home_all_axes();
  58. #endif
  59. #if EXTRUDERS > 1
  60. // Change toolhead if specified
  61. uint8_t active_extruder_before_filament_change = active_extruder;
  62. if (active_extruder != target_extruder)
  63. tool_change(target_extruder, 0, true);
  64. #endif
  65. // Initial retract before move to filament change position
  66. const float retract = -FABS(parser.seen('E') ? parser.value_axis_units(E_AXIS) : 0
  67. #ifdef PAUSE_PARK_RETRACT_LENGTH
  68. + (PAUSE_PARK_RETRACT_LENGTH)
  69. #endif
  70. );
  71. // Move XY axes to filament change position or given position
  72. if (parser.seenval('X')) park_point.x = parser.linearval('X');
  73. if (parser.seenval('Y')) park_point.y = parser.linearval('Y');
  74. // Lift Z axis
  75. if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
  76. #if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE)
  77. park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
  78. park_point.y += (active_extruder ? hotend_offset[Y_AXIS][active_extruder] : 0);
  79. #endif
  80. // Unload filament
  81. const float unload_length = -FABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
  82. : filament_change_unload_length[active_extruder]);
  83. // Load filament
  84. const float load_length = FABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
  85. : filament_change_load_length[active_extruder]);
  86. const int beep_count = parser.intval('B',
  87. #ifdef FILAMENT_CHANGE_ALERT_BEEPS
  88. FILAMENT_CHANGE_ALERT_BEEPS
  89. #else
  90. -1
  91. #endif
  92. );
  93. const bool job_running = print_job_timer.isRunning();
  94. if (pause_print(retract, park_point, unload_length, true)) {
  95. wait_for_filament_reload(beep_count);
  96. resume_print(load_length, ADVANCED_PAUSE_EXTRUDE_LENGTH, beep_count);
  97. }
  98. #if EXTRUDERS > 1
  99. // Restore toolhead if it was changed
  100. if (active_extruder_before_filament_change != active_extruder)
  101. tool_change(active_extruder_before_filament_change, 0, true);
  102. #endif
  103. // Resume the print job timer if it was running
  104. if (job_running) print_job_timer.start();
  105. }
  106. #endif // ADVANCED_PAUSE_FEATURE