My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

pause.cpp 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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. /**
  23. * feature/pause.cpp - Pause feature support functions
  24. * This may be combined with related G-codes if features are consolidated.
  25. */
  26. #include "../inc/MarlinConfigPre.h"
  27. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  28. #include "../Marlin.h"
  29. #include "../gcode/gcode.h"
  30. #include "../module/motion.h"
  31. #include "../module/planner.h"
  32. #include "../module/stepper.h"
  33. #include "../module/printcounter.h"
  34. #include "../module/temperature.h"
  35. #if ENABLED(FWRETRACT)
  36. #include "../feature/fwretract.h"
  37. #endif
  38. #if ENABLED(FILAMENT_RUNOUT_SENSOR)
  39. #include "../feature/runout.h"
  40. #endif
  41. #if HAS_LCD_MENU
  42. #include "../lcd/ultralcd.h"
  43. #endif
  44. #include "../libs/buzzer.h"
  45. #include "../libs/nozzle.h"
  46. #include "pause.h"
  47. // private:
  48. static float resume_position[XYZE];
  49. AdvancedPauseMenuResponse advanced_pause_menu_response;
  50. fil_change_settings_t fc_settings[EXTRUDERS];
  51. #if ENABLED(SDSUPPORT)
  52. #include "../sd/cardreader.h"
  53. #endif
  54. #if HAS_BUZZER
  55. static void filament_change_beep(const int8_t max_beep_count, const bool init=false) {
  56. static millis_t next_buzz = 0;
  57. static int8_t runout_beep = 0;
  58. if (init) next_buzz = runout_beep = 0;
  59. const millis_t ms = millis();
  60. if (ELAPSED(ms, next_buzz)) {
  61. if (max_beep_count < 0 || runout_beep < max_beep_count + 5) { // Only beep as long as we're supposed to
  62. next_buzz = ms + ((max_beep_count < 0 || runout_beep < max_beep_count) ? 1000 : 500);
  63. BUZZ(50, 880 - (runout_beep & 1) * 220);
  64. runout_beep++;
  65. }
  66. }
  67. }
  68. #endif
  69. /**
  70. * Ensure a safe temperature for extrusion
  71. *
  72. * - Fail if the TARGET temperature is too low
  73. * - Display LCD placard with temperature status
  74. * - Return when heating is done or aborted
  75. *
  76. * Returns 'true' if heating was completed, 'false' for abort
  77. */
  78. static bool ensure_safe_temperature(const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT) {
  79. #if ENABLED(PREVENT_COLD_EXTRUSION)
  80. if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder)) {
  81. SERIAL_ERROR_START();
  82. SERIAL_ERRORLNPGM(MSG_ERR_HOTEND_TOO_COLD);
  83. return false;
  84. }
  85. #endif
  86. #if HAS_LCD_MENU
  87. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT, mode);
  88. #else
  89. UNUSED(mode);
  90. #endif
  91. return thermalManager.wait_for_hotend(active_extruder);
  92. }
  93. void do_pause_e_move(const float &length, const float &fr) {
  94. current_position[E_AXIS] += length / planner.e_factor[active_extruder];
  95. planner.buffer_line(current_position, fr, active_extruder);
  96. planner.synchronize();
  97. }
  98. /**
  99. * Load filament into the hotend
  100. *
  101. * - Fail if the a safe temperature was not reached
  102. * - If pausing for confirmation, wait for a click or M108
  103. * - Show "wait for load" placard
  104. * - Load and purge filament
  105. * - Show "Purge more" / "Continue" menu
  106. * - Return when "Continue" is selected
  107. *
  108. * Returns 'true' if load was completed, 'false' for abort
  109. */
  110. bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_length/*=0*/, const float &purge_length/*=0*/, const int8_t max_beep_count/*=0*/,
  111. const bool show_lcd/*=false*/, const bool pause_for_user/*=false*/,
  112. const AdvancedPauseMode mode/*=ADVANCED_PAUSE_MODE_PAUSE_PRINT*/
  113. DXC_ARGS
  114. ) {
  115. #if DISABLED(ULTIPANEL)
  116. UNUSED(show_lcd);
  117. #endif
  118. if (!ensure_safe_temperature(mode)) {
  119. #if HAS_LCD_MENU
  120. if (show_lcd) // Show status screen
  121. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
  122. #endif
  123. return false;
  124. }
  125. if (pause_for_user) {
  126. #if HAS_LCD_MENU
  127. if (show_lcd) // Show "insert filament"
  128. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INSERT, mode);
  129. #endif
  130. SERIAL_ECHO_START();
  131. SERIAL_ECHOLNPGM(MSG_FILAMENT_CHANGE_INSERT);
  132. #if HAS_BUZZER
  133. filament_change_beep(max_beep_count, true);
  134. #else
  135. UNUSED(max_beep_count);
  136. #endif
  137. KEEPALIVE_STATE(PAUSED_FOR_USER);
  138. wait_for_user = true; // LCD click or M108 will clear this
  139. while (wait_for_user) {
  140. #if HAS_BUZZER
  141. filament_change_beep(max_beep_count);
  142. #endif
  143. idle(true);
  144. }
  145. KEEPALIVE_STATE(IN_HANDLER);
  146. }
  147. #if HAS_LCD_MENU
  148. if (show_lcd) // Show "wait for load" message
  149. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_LOAD, mode);
  150. #endif
  151. #if ENABLED(DUAL_X_CARRIAGE)
  152. const int8_t saved_ext = active_extruder;
  153. const bool saved_ext_dup_mode = extruder_duplication_enabled;
  154. active_extruder = DXC_ext;
  155. extruder_duplication_enabled = false;
  156. #endif
  157. // Slow Load filament
  158. if (slow_load_length) do_pause_e_move(slow_load_length, FILAMENT_CHANGE_SLOW_LOAD_FEEDRATE);
  159. // Fast Load Filament
  160. if (fast_load_length) {
  161. #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
  162. const float saved_acceleration = planner.settings.retract_acceleration;
  163. planner.settings.retract_acceleration = FILAMENT_CHANGE_FAST_LOAD_ACCEL;
  164. #endif
  165. do_pause_e_move(fast_load_length, FILAMENT_CHANGE_FAST_LOAD_FEEDRATE);
  166. #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
  167. planner.settings.retract_acceleration = saved_acceleration;
  168. #endif
  169. }
  170. #if ENABLED(DUAL_X_CARRIAGE) // Tie the two extruders movement back together.
  171. active_extruder = saved_ext;
  172. extruder_duplication_enabled = saved_ext_dup_mode;
  173. stepper.set_directions();
  174. #endif
  175. #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)
  176. #if HAS_LCD_MENU
  177. if (show_lcd)
  178. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_CONTINUOUS_PURGE);
  179. #endif
  180. wait_for_user = true;
  181. for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
  182. do_pause_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
  183. wait_for_user = false;
  184. #else
  185. do {
  186. if (purge_length > 0) {
  187. // "Wait for filament purge"
  188. #if HAS_LCD_MENU
  189. if (show_lcd)
  190. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_PURGE, mode);
  191. #endif
  192. // Extrude filament to get into hotend
  193. do_pause_e_move(purge_length, ADVANCED_PAUSE_PURGE_FEEDRATE);
  194. }
  195. // Show "Purge More" / "Resume" menu and wait for reply
  196. #if HAS_LCD_MENU
  197. if (show_lcd) {
  198. KEEPALIVE_STATE(PAUSED_FOR_USER);
  199. wait_for_user = false;
  200. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_OPTION, mode);
  201. while (advanced_pause_menu_response == ADVANCED_PAUSE_RESPONSE_WAIT_FOR) idle(true);
  202. KEEPALIVE_STATE(IN_HANDLER);
  203. }
  204. #endif
  205. // Keep looping if "Purge More" was selected
  206. } while (
  207. #if HAS_LCD_MENU
  208. show_lcd && advanced_pause_menu_response == ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE
  209. #else
  210. 0
  211. #endif
  212. );
  213. #endif
  214. return true;
  215. }
  216. /**
  217. * Unload filament from the hotend
  218. *
  219. * - Fail if the a safe temperature was not reached
  220. * - Show "wait for unload" placard
  221. * - Retract, pause, then unload filament
  222. * - Disable E stepper (on most machines)
  223. *
  224. * Returns 'true' if unload was completed, 'false' for abort
  225. */
  226. bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
  227. const AdvancedPauseMode mode/*=ADVANCED_PAUSE_MODE_PAUSE_PRINT*/
  228. ) {
  229. if (!ensure_safe_temperature(mode)) {
  230. #if HAS_LCD_MENU
  231. if (show_lcd) // Show status screen
  232. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
  233. #endif
  234. return false;
  235. }
  236. #if DISABLED(ULTIPANEL)
  237. UNUSED(show_lcd);
  238. #else
  239. if (show_lcd)
  240. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_UNLOAD, mode);
  241. #endif
  242. // Retract filament
  243. do_pause_e_move(-FILAMENT_UNLOAD_RETRACT_LENGTH, PAUSE_PARK_RETRACT_FEEDRATE);
  244. // Wait for filament to cool
  245. safe_delay(FILAMENT_UNLOAD_DELAY);
  246. // Quickly purge
  247. do_pause_e_move(FILAMENT_UNLOAD_RETRACT_LENGTH + FILAMENT_UNLOAD_PURGE_LENGTH, planner.settings.max_feedrate_mm_s[E_AXIS]);
  248. // Unload filament
  249. #if FILAMENT_CHANGE_UNLOAD_ACCEL > 0
  250. const float saved_acceleration = planner.settings.retract_acceleration;
  251. planner.settings.retract_acceleration = FILAMENT_CHANGE_UNLOAD_ACCEL;
  252. #endif
  253. do_pause_e_move(unload_length, FILAMENT_CHANGE_UNLOAD_FEEDRATE);
  254. #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
  255. planner.settings.retract_acceleration = saved_acceleration;
  256. #endif
  257. // Disable extruders steppers for manual filament changing (only on boards that have separate ENABLE_PINS)
  258. #if (E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN) || AXIS_DRIVER_TYPE(E0, TMC2660) || AXIS_DRIVER_TYPE(E1, TMC2660) || AXIS_DRIVER_TYPE(E2, TMC2660) || AXIS_DRIVER_TYPE(E3, TMC2660) || AXIS_DRIVER_TYPE(E4, TMC2660) || AXIS_DRIVER_TYPE(E5, TMC2660)
  259. disable_e_stepper(active_extruder);
  260. safe_delay(100);
  261. #endif
  262. return true;
  263. }
  264. // public:
  265. /**
  266. * Pause procedure
  267. *
  268. * - Abort if already paused
  269. * - Send host action for pause, if configured
  270. * - Abort if TARGET temperature is too low
  271. * - Display "wait for start of filament change" (if a length was specified)
  272. * - Initial retract, if current temperature is hot enough
  273. * - Park the nozzle at the given position
  274. * - Call unload_filament (if a length was specified)
  275. *
  276. * Returns 'true' if pause was completed, 'false' for abort
  277. */
  278. uint8_t did_pause_print = 0;
  279. bool pause_print(const float &retract, const point_t &park_point, const float &unload_length/*=0*/, const bool show_lcd/*=false*/ DXC_ARGS) {
  280. if (did_pause_print) return false; // already paused
  281. #ifdef ACTION_ON_PAUSE
  282. SERIAL_ECHOLNPGM("//action:" ACTION_ON_PAUSE);
  283. #endif
  284. #if HAS_LCD_MENU
  285. if (show_lcd) // Show initial message
  286. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT);
  287. #endif
  288. if (!DEBUGGING(DRYRUN) && unload_length && thermalManager.targetTooColdToExtrude(active_extruder)) {
  289. SERIAL_ERROR_START();
  290. SERIAL_ERRORLNPGM(MSG_ERR_HOTEND_TOO_COLD);
  291. #if HAS_LCD_MENU
  292. if (show_lcd) { // Show status screen
  293. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
  294. LCD_MESSAGEPGM(MSG_M600_TOO_COLD);
  295. }
  296. #endif
  297. return false; // unable to reach safe temperature
  298. }
  299. // Indicate that the printer is paused
  300. ++did_pause_print;
  301. // Pause the print job and timer
  302. #if ENABLED(SDSUPPORT)
  303. if (card.sdprinting) {
  304. card.pauseSDPrint();
  305. ++did_pause_print; // Indicate SD pause also
  306. }
  307. #endif
  308. print_job_timer.pause();
  309. // Save current position
  310. COPY(resume_position, current_position);
  311. // Wait for buffered blocks to complete
  312. planner.synchronize();
  313. // Initial retract before move to filament change position
  314. if (retract && thermalManager.hotEnoughToExtrude(active_extruder))
  315. do_pause_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
  316. // Park the nozzle by moving up by z_lift and then moving to (x_pos, y_pos)
  317. if (!axis_unhomed_error())
  318. Nozzle::park(2, park_point);
  319. #if ENABLED(DUAL_X_CARRIAGE)
  320. const int8_t saved_ext = active_extruder;
  321. const bool saved_ext_dup_mode = extruder_duplication_enabled;
  322. active_extruder = DXC_ext;
  323. extruder_duplication_enabled = false;
  324. #endif
  325. if (unload_length) // Unload the filament
  326. unload_filament(unload_length, show_lcd);
  327. #if ENABLED(DUAL_X_CARRIAGE)
  328. active_extruder = saved_ext;
  329. extruder_duplication_enabled = saved_ext_dup_mode;
  330. stepper.set_directions();
  331. #endif
  332. return true;
  333. }
  334. /**
  335. * - Show "Insert filament and press button to continue"
  336. * - Wait for a click before returning
  337. * - Heaters can time out, reheated before accepting a click
  338. *
  339. * Used by M125 and M600
  340. */
  341. void wait_for_filament_reload(const int8_t max_beep_count/*=0*/ DXC_ARGS) {
  342. bool nozzle_timed_out = false;
  343. #if HAS_LCD_MENU
  344. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INSERT);
  345. #endif
  346. SERIAL_ECHO_START();
  347. SERIAL_ERRORLNPGM(MSG_FILAMENT_CHANGE_INSERT);
  348. #if HAS_BUZZER
  349. filament_change_beep(max_beep_count, true);
  350. #endif
  351. // Start the heater idle timers
  352. const millis_t nozzle_timeout = (millis_t)(PAUSE_PARK_NOZZLE_TIMEOUT) * 1000UL;
  353. HOTEND_LOOP()
  354. thermalManager.start_heater_idle_timer(e, nozzle_timeout);
  355. #if ENABLED(DUAL_X_CARRIAGE)
  356. const int8_t saved_ext = active_extruder;
  357. const bool saved_ext_dup_mode = extruder_duplication_enabled;
  358. active_extruder = DXC_ext;
  359. extruder_duplication_enabled = false;
  360. #endif
  361. // Wait for filament insert by user and press button
  362. KEEPALIVE_STATE(PAUSED_FOR_USER);
  363. wait_for_user = true; // LCD click or M108 will clear this
  364. while (wait_for_user) {
  365. #if HAS_BUZZER
  366. filament_change_beep(max_beep_count);
  367. #endif
  368. // If the nozzle has timed out, wait for the user to press the button to re-heat the nozzle, then
  369. // re-heat the nozzle, re-show the insert screen, restart the idle timers, and start over
  370. if (!nozzle_timed_out)
  371. HOTEND_LOOP()
  372. nozzle_timed_out |= thermalManager.is_heater_idle(e);
  373. if (nozzle_timed_out) {
  374. #if HAS_LCD_MENU
  375. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_CLICK_TO_HEAT_NOZZLE);
  376. #endif
  377. SERIAL_ECHO_START();
  378. #if HAS_LCD_MENU && ENABLED(EMERGENCY_PARSER)
  379. SERIAL_ECHOLNPGM(MSG_FILAMENT_CHANGE_HEAT);
  380. #elif ENABLED(EMERGENCY_PARSER)
  381. SERIAL_ECHOLNPGM(MSG_FILAMENT_CHANGE_HEAT_M108);
  382. #else
  383. SERIAL_ECHOLNPGM(MSG_FILAMENT_CHANGE_HEAT_LCD);
  384. #endif
  385. // Wait for LCD click or M108
  386. while (wait_for_user) idle(true);
  387. // Re-enable the heaters if they timed out
  388. HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e);
  389. // Wait for the heaters to reach the target temperatures
  390. ensure_safe_temperature();
  391. #if HAS_LCD_MENU
  392. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INSERT);
  393. #endif
  394. SERIAL_ECHO_START();
  395. #if HAS_LCD_MENU && ENABLED(EMERGENCY_PARSER)
  396. SERIAL_ECHOLNPGM(MSG_FILAMENT_CHANGE_INSERT);
  397. #elif ENABLED(EMERGENCY_PARSER)
  398. SERIAL_ECHOLNPGM(MSG_FILAMENT_CHANGE_INSERT_M108);
  399. #else
  400. SERIAL_ECHOLNPGM(MSG_FILAMENT_CHANGE_INSERT_LCD);
  401. #endif
  402. // Start the heater idle timers
  403. const millis_t nozzle_timeout = (millis_t)(PAUSE_PARK_NOZZLE_TIMEOUT) * 1000UL;
  404. HOTEND_LOOP()
  405. thermalManager.start_heater_idle_timer(e, nozzle_timeout);
  406. wait_for_user = true; // Wait for user to load filament
  407. nozzle_timed_out = false;
  408. #if HAS_BUZZER
  409. filament_change_beep(max_beep_count, true);
  410. #endif
  411. }
  412. idle(true);
  413. }
  414. #if ENABLED(DUAL_X_CARRIAGE)
  415. active_extruder = saved_ext;
  416. extruder_duplication_enabled = saved_ext_dup_mode;
  417. stepper.set_directions();
  418. #endif
  419. KEEPALIVE_STATE(IN_HANDLER);
  420. }
  421. /**
  422. * Resume or Start print procedure
  423. *
  424. * - Abort if not paused
  425. * - Reset heater idle timers
  426. * - Load filament if specified, but only if:
  427. * - a nozzle timed out, or
  428. * - the nozzle is already heated.
  429. * - Display "wait for print to resume"
  430. * - Re-prime the nozzle...
  431. * - FWRETRACT: Recover/prime from the prior G10.
  432. * - !FWRETRACT: Retract by resume_position[E], if negative.
  433. * Not sure how this logic comes into use.
  434. * - Move the nozzle back to resume_position
  435. * - Sync the planner E to resume_position[E]
  436. * - Send host action for resume, if configured
  437. * - Resume the current SD print job, if any
  438. */
  439. void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_length/*=0*/, const float &purge_length/*=ADVANCED_PAUSE_PURGE_LENGTH*/, const int8_t max_beep_count/*=0*/ DXC_ARGS) {
  440. /*
  441. SERIAL_ECHOPGM("start of resume_print()\n");
  442. SERIAL_ECHOPAIR("\ndual_x_carriage_mode:", dual_x_carriage_mode);
  443. SERIAL_ECHOPAIR("\nextruder_duplication_enabled:", extruder_duplication_enabled);
  444. SERIAL_ECHOPAIR("\nactive_extruder:", active_extruder);
  445. SERIAL_ECHOPGM("\n\n");
  446. */
  447. if (!did_pause_print) return;
  448. // Re-enable the heaters if they timed out
  449. bool nozzle_timed_out = false;
  450. HOTEND_LOOP() {
  451. nozzle_timed_out |= thermalManager.is_heater_idle(e);
  452. thermalManager.reset_heater_idle_timer(e);
  453. }
  454. if (nozzle_timed_out || thermalManager.hotEnoughToExtrude(active_extruder)) // Load the new filament
  455. load_filament(slow_load_length, fast_load_length, purge_length, max_beep_count, true, nozzle_timed_out, ADVANCED_PAUSE_MODE_PAUSE_PRINT DXC_PASS);
  456. #if HAS_LCD_MENU
  457. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_RESUME); // "Wait for print to resume"
  458. #endif
  459. // Intelligent resuming
  460. #if ENABLED(FWRETRACT)
  461. // If retracted before goto pause
  462. if (fwretract.retracted[active_extruder])
  463. do_pause_e_move(-fwretract.settings.retract_length, fwretract.settings.retract_feedrate_mm_s);
  464. #endif
  465. // If resume_position is negative
  466. if (resume_position[E_AXIS] < 0) do_pause_e_move(resume_position[E_AXIS], PAUSE_PARK_RETRACT_FEEDRATE);
  467. // Move XY to starting position, then Z
  468. do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], NOZZLE_PARK_XY_FEEDRATE);
  469. // Move Z_AXIS to saved position
  470. do_blocking_move_to_z(resume_position[Z_AXIS], NOZZLE_PARK_Z_FEEDRATE);
  471. // Now all extrusion positions are resumed and ready to be confirmed
  472. // Set extruder to saved position
  473. planner.set_e_position_mm((destination[E_AXIS] = current_position[E_AXIS] = resume_position[E_AXIS]));
  474. #if ENABLED(FILAMENT_RUNOUT_SENSOR)
  475. runout.reset();
  476. #endif
  477. #if HAS_LCD_MENU
  478. // Show status screen
  479. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
  480. #endif
  481. #ifdef ACTION_ON_RESUME
  482. SERIAL_ECHOLNPGM("//action:" ACTION_ON_RESUME);
  483. #endif
  484. --did_pause_print;
  485. #if ENABLED(SDSUPPORT)
  486. if (did_pause_print) {
  487. card.startFileprint();
  488. --did_pause_print;
  489. }
  490. #endif
  491. #if ENABLED(ULTRA_LCD)
  492. lcd_reset_status();
  493. #endif
  494. }
  495. #endif // ADVANCED_PAUSE_FEATURE