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.

pause.cpp 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2019 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 "fwretract.h"
  37. #endif
  38. #if HAS_FILAMENT_SENSOR
  39. #include "runout.h"
  40. #endif
  41. #if ENABLED(HOST_ACTION_COMMANDS)
  42. #include "host_actions.h"
  43. #endif
  44. #include "../lcd/ultralcd.h"
  45. #include "../libs/buzzer.h"
  46. #include "../libs/nozzle.h"
  47. #include "pause.h"
  48. // private:
  49. static float resume_position[XYZE];
  50. AdvancedPauseMenuResponse advanced_pause_menu_response;
  51. fil_change_settings_t fc_settings[EXTRUDERS];
  52. #if ENABLED(SDSUPPORT)
  53. #include "../sd/cardreader.h"
  54. #endif
  55. #if HAS_BUZZER
  56. static void filament_change_beep(const int8_t max_beep_count, const bool init=false) {
  57. static millis_t next_buzz = 0;
  58. static int8_t runout_beep = 0;
  59. if (init) next_buzz = runout_beep = 0;
  60. const millis_t ms = millis();
  61. if (ELAPSED(ms, next_buzz)) {
  62. if (max_beep_count < 0 || runout_beep < max_beep_count + 5) { // Only beep as long as we're supposed to
  63. next_buzz = ms + ((max_beep_count < 0 || runout_beep < max_beep_count) ? 1000 : 500);
  64. BUZZ(50, 880 - (runout_beep & 1) * 220);
  65. runout_beep++;
  66. }
  67. }
  68. }
  69. #endif
  70. /**
  71. * Ensure a safe temperature for extrusion
  72. *
  73. * - Fail if the TARGET temperature is too low
  74. * - Display LCD placard with temperature status
  75. * - Return when heating is done or aborted
  76. *
  77. * Returns 'true' if heating was completed, 'false' for abort
  78. */
  79. static bool ensure_safe_temperature(const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_SAME) {
  80. #if ENABLED(PREVENT_COLD_EXTRUSION)
  81. if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder)) {
  82. SERIAL_ECHO_MSG(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_HEATING, 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_mm_s) {
  94. #if HAS_FILAMENT_SENSOR
  95. runout.reset();
  96. #endif
  97. current_position[E_AXIS] += length / planner.e_factor[active_extruder];
  98. planner.buffer_line(current_position, fr_mm_s, active_extruder);
  99. planner.synchronize();
  100. }
  101. /**
  102. * Load filament into the hotend
  103. *
  104. * - Fail if the a safe temperature was not reached
  105. * - If pausing for confirmation, wait for a click or M108
  106. * - Show "wait for load" placard
  107. * - Load and purge filament
  108. * - Show "Purge more" / "Continue" menu
  109. * - Return when "Continue" is selected
  110. *
  111. * Returns 'true' if load was completed, 'false' for abort
  112. */
  113. 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*/,
  114. const bool show_lcd/*=false*/, const bool pause_for_user/*=false*/,
  115. const AdvancedPauseMode mode/*=ADVANCED_PAUSE_MODE_PAUSE_PRINT*/
  116. DXC_ARGS
  117. ) {
  118. #if !HAS_LCD_MENU
  119. UNUSED(show_lcd);
  120. #endif
  121. if (!ensure_safe_temperature(mode)) {
  122. #if HAS_LCD_MENU
  123. if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS, mode);
  124. #endif
  125. return false;
  126. }
  127. if (pause_for_user) {
  128. #if HAS_LCD_MENU
  129. if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INSERT, mode);
  130. #endif
  131. SERIAL_ECHO_MSG(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. #if ENABLED(HOST_PROMPT_SUPPORT)
  140. const char tool = '0'
  141. #if NUM_RUNOUT_SENSORS > 1
  142. + active_extruder
  143. #endif
  144. ;
  145. host_prompt_reason = PROMPT_USER_CONTINUE;
  146. host_action_prompt_end();
  147. host_action_prompt_begin(PSTR("Load Filament T"), false);
  148. SERIAL_CHAR(tool);
  149. SERIAL_EOL();
  150. host_action_prompt_button(PSTR("Continue"));
  151. host_action_prompt_show();
  152. #endif
  153. while (wait_for_user) {
  154. #if HAS_BUZZER
  155. filament_change_beep(max_beep_count);
  156. #endif
  157. idle(true);
  158. }
  159. KEEPALIVE_STATE(IN_HANDLER);
  160. }
  161. #if HAS_LCD_MENU
  162. if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_LOAD, mode);
  163. #endif
  164. #if ENABLED(DUAL_X_CARRIAGE)
  165. const int8_t saved_ext = active_extruder;
  166. const bool saved_ext_dup_mode = extruder_duplication_enabled;
  167. active_extruder = DXC_ext;
  168. extruder_duplication_enabled = false;
  169. #endif
  170. // Slow Load filament
  171. if (slow_load_length) do_pause_e_move(slow_load_length, FILAMENT_CHANGE_SLOW_LOAD_FEEDRATE);
  172. // Fast Load Filament
  173. if (fast_load_length) {
  174. #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
  175. const float saved_acceleration = planner.settings.retract_acceleration;
  176. planner.settings.retract_acceleration = FILAMENT_CHANGE_FAST_LOAD_ACCEL;
  177. #endif
  178. do_pause_e_move(fast_load_length, FILAMENT_CHANGE_FAST_LOAD_FEEDRATE);
  179. #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
  180. planner.settings.retract_acceleration = saved_acceleration;
  181. #endif
  182. }
  183. #if ENABLED(DUAL_X_CARRIAGE) // Tie the two extruders movement back together.
  184. active_extruder = saved_ext;
  185. extruder_duplication_enabled = saved_ext_dup_mode;
  186. stepper.set_directions();
  187. #endif
  188. #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)
  189. #if HAS_LCD_MENU
  190. if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_PURGE);
  191. #endif
  192. wait_for_user = true;
  193. #if ENABLED(HOST_PROMPT_SUPPORT)
  194. host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Continuous Purge Running..."), PSTR("Continue"));
  195. #endif
  196. for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
  197. do_pause_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
  198. wait_for_user = false;
  199. #else
  200. do {
  201. if (purge_length > 0) {
  202. // "Wait for filament purge"
  203. #if HAS_LCD_MENU
  204. if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_PURGE);
  205. #endif
  206. // Extrude filament to get into hotend
  207. do_pause_e_move(purge_length, ADVANCED_PAUSE_PURGE_FEEDRATE);
  208. }
  209. // Show "Purge More" / "Resume" menu and wait for reply
  210. #if ENABLED(HOST_PROMPT_SUPPORT)
  211. host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
  212. host_action_prompt_end(); // Close current prompt
  213. host_action_prompt_begin(PSTR("Paused"));
  214. host_action_prompt_button(PSTR("PurgeMore"));
  215. if (false
  216. #if HAS_FILAMENT_SENSOR
  217. || runout.filament_ran_out
  218. #endif
  219. )
  220. host_action_prompt_button(PSTR("DisableRunout"));
  221. else {
  222. host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
  223. host_action_prompt_button(PSTR("Continue"));
  224. }
  225. host_action_prompt_show();
  226. #endif
  227. #if HAS_LCD_MENU
  228. if (show_lcd) {
  229. KEEPALIVE_STATE(PAUSED_FOR_USER);
  230. wait_for_user = false;
  231. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_OPTION);
  232. while (advanced_pause_menu_response == ADVANCED_PAUSE_RESPONSE_WAIT_FOR) idle(true);
  233. KEEPALIVE_STATE(IN_HANDLER);
  234. }
  235. #endif
  236. // Keep looping if "Purge More" was selected
  237. } while (false
  238. #if HAS_LCD_MENU
  239. || (show_lcd && advanced_pause_menu_response == ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE)
  240. #endif
  241. );
  242. #endif
  243. return true;
  244. }
  245. /**
  246. * Unload filament from the hotend
  247. *
  248. * - Fail if the a safe temperature was not reached
  249. * - Show "wait for unload" placard
  250. * - Retract, pause, then unload filament
  251. * - Disable E stepper (on most machines)
  252. *
  253. * Returns 'true' if unload was completed, 'false' for abort
  254. */
  255. bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
  256. const AdvancedPauseMode mode/*=ADVANCED_PAUSE_MODE_PAUSE_PRINT*/
  257. ) {
  258. #if !HAS_LCD_MENU
  259. UNUSED(show_lcd);
  260. #endif
  261. if (!ensure_safe_temperature(mode)) {
  262. #if HAS_LCD_MENU
  263. if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
  264. #endif
  265. return false;
  266. }
  267. #if HAS_LCD_MENU
  268. if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_UNLOAD, mode);
  269. #endif
  270. // Retract filament
  271. do_pause_e_move(-FILAMENT_UNLOAD_RETRACT_LENGTH, PAUSE_PARK_RETRACT_FEEDRATE);
  272. // Wait for filament to cool
  273. safe_delay(FILAMENT_UNLOAD_DELAY);
  274. // Quickly purge
  275. do_pause_e_move(FILAMENT_UNLOAD_RETRACT_LENGTH + FILAMENT_UNLOAD_PURGE_LENGTH, planner.settings.max_feedrate_mm_s[E_AXIS]);
  276. // Unload filament
  277. #if FILAMENT_CHANGE_UNLOAD_ACCEL > 0
  278. const float saved_acceleration = planner.settings.retract_acceleration;
  279. planner.settings.retract_acceleration = FILAMENT_CHANGE_UNLOAD_ACCEL;
  280. #endif
  281. do_pause_e_move(unload_length, FILAMENT_CHANGE_UNLOAD_FEEDRATE);
  282. #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
  283. planner.settings.retract_acceleration = saved_acceleration;
  284. #endif
  285. // Disable extruders steppers for manual filament changing (only on boards that have separate ENABLE_PINS)
  286. #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)
  287. disable_e_stepper(active_extruder);
  288. safe_delay(100);
  289. #endif
  290. return true;
  291. }
  292. // public:
  293. /**
  294. * Pause procedure
  295. *
  296. * - Abort if already paused
  297. * - Send host action for pause, if configured
  298. * - Abort if TARGET temperature is too low
  299. * - Display "wait for start of filament change" (if a length was specified)
  300. * - Initial retract, if current temperature is hot enough
  301. * - Park the nozzle at the given position
  302. * - Call unload_filament (if a length was specified)
  303. *
  304. * Returns 'true' if pause was completed, 'false' for abort
  305. */
  306. uint8_t did_pause_print = 0;
  307. bool pause_print(const float &retract, const point_t &park_point, const float &unload_length/*=0*/, const bool show_lcd/*=false*/ DXC_ARGS) {
  308. #if !HAS_LCD_MENU
  309. UNUSED(show_lcd);
  310. #endif
  311. if (did_pause_print) return false; // already paused
  312. #if ENABLED(HOST_ACTION_COMMANDS)
  313. #ifdef ACTION_ON_PAUSED
  314. host_action_paused();
  315. #elif defined(ACTION_ON_PAUSE)
  316. host_action_pause();
  317. #endif
  318. #if ENABLED(HOST_PROMPT_SUPPORT)
  319. host_prompt_open(PROMPT_INFO, PSTR("Pause"));
  320. #endif
  321. #endif
  322. if (!DEBUGGING(DRYRUN) && unload_length && thermalManager.targetTooColdToExtrude(active_extruder)) {
  323. SERIAL_ECHO_MSG(MSG_ERR_HOTEND_TOO_COLD);
  324. #if HAS_LCD_MENU
  325. if (show_lcd) { // Show status screen
  326. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
  327. LCD_MESSAGEPGM(MSG_M600_TOO_COLD);
  328. }
  329. #endif
  330. return false; // unable to reach safe temperature
  331. }
  332. // Indicate that the printer is paused
  333. ++did_pause_print;
  334. // Pause the print job and timer
  335. #if ENABLED(SDSUPPORT)
  336. if (IS_SD_PRINTING()) {
  337. card.pauseSDPrint();
  338. ++did_pause_print; // Indicate SD pause also
  339. }
  340. #endif
  341. print_job_timer.pause();
  342. // Save current position
  343. COPY(resume_position, current_position);
  344. // Wait for buffered blocks to complete
  345. planner.synchronize();
  346. // Initial retract before move to filament change position
  347. if (retract && thermalManager.hotEnoughToExtrude(active_extruder))
  348. do_pause_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
  349. // Park the nozzle by moving up by z_lift and then moving to (x_pos, y_pos)
  350. if (!axis_unhomed_error())
  351. Nozzle::park(2, park_point);
  352. #if ENABLED(DUAL_X_CARRIAGE)
  353. const int8_t saved_ext = active_extruder;
  354. const bool saved_ext_dup_mode = extruder_duplication_enabled;
  355. active_extruder = DXC_ext;
  356. extruder_duplication_enabled = false;
  357. #endif
  358. if (unload_length) // Unload the filament
  359. unload_filament(unload_length, show_lcd);
  360. #if ENABLED(DUAL_X_CARRIAGE)
  361. active_extruder = saved_ext;
  362. extruder_duplication_enabled = saved_ext_dup_mode;
  363. stepper.set_directions();
  364. #endif
  365. return true;
  366. }
  367. /**
  368. * For Paused Print:
  369. * - Show "Press button (or M108) to resume"
  370. *
  371. * For Filament Change:
  372. * - Show "Insert filament and press button to continue"
  373. *
  374. * - Wait for a click before returning
  375. * - Heaters can time out and must reheat before continuing
  376. *
  377. * Used by M125 and M600
  378. */
  379. #if (HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI)) && ENABLED(EMERGENCY_PARSER)
  380. #define _PMSG(L) L
  381. #elif ENABLED(EMERGENCY_PARSER)
  382. #define _PMSG(L) L##_M108
  383. #else
  384. #define _PMSG(L) L##_LCD
  385. #endif
  386. void show_continue_prompt(const bool is_reload) {
  387. #if HAS_LCD_MENU
  388. lcd_advanced_pause_show_message(is_reload ? ADVANCED_PAUSE_MESSAGE_INSERT : ADVANCED_PAUSE_MESSAGE_WAITING);
  389. #endif
  390. SERIAL_ECHO_START();
  391. serialprintPGM(is_reload ? PSTR(_PMSG(MSG_FILAMENT_CHANGE_INSERT) "\n") : PSTR(_PMSG(MSG_FILAMENT_CHANGE_WAIT) "\n"));
  392. }
  393. void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep_count/*=0*/ DXC_ARGS) {
  394. bool nozzle_timed_out = false;
  395. show_continue_prompt(is_reload);
  396. #if HAS_BUZZER
  397. filament_change_beep(max_beep_count, true);
  398. #endif
  399. // Start the heater idle timers
  400. const millis_t nozzle_timeout = (millis_t)(PAUSE_PARK_NOZZLE_TIMEOUT) * 1000UL;
  401. HOTEND_LOOP()
  402. thermalManager.start_heater_idle_timer(e, nozzle_timeout);
  403. #if ENABLED(DUAL_X_CARRIAGE)
  404. const int8_t saved_ext = active_extruder;
  405. const bool saved_ext_dup_mode = extruder_duplication_enabled;
  406. active_extruder = DXC_ext;
  407. extruder_duplication_enabled = false;
  408. #endif
  409. // Wait for filament insert by user and press button
  410. KEEPALIVE_STATE(PAUSED_FOR_USER);
  411. wait_for_user = true; // LCD click or M108 will clear this
  412. #if ENABLED(HOST_PROMPT_SUPPORT)
  413. host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Nozzle Parked"), PSTR("Continue"));
  414. #endif
  415. while (wait_for_user) {
  416. #if HAS_BUZZER
  417. filament_change_beep(max_beep_count);
  418. #endif
  419. // If the nozzle has timed out...
  420. if (!nozzle_timed_out)
  421. HOTEND_LOOP() nozzle_timed_out |= thermalManager.is_heater_idle(e);
  422. // Wait for the user to press the button to re-heat the nozzle, then
  423. // re-heat the nozzle, re-show the continue prompt, restart idle timers, start over
  424. if (nozzle_timed_out) {
  425. #if HAS_LCD_MENU
  426. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_HEAT);
  427. #endif
  428. SERIAL_ECHO_MSG(_PMSG(MSG_FILAMENT_CHANGE_HEAT));
  429. #if ENABLED(HOST_PROMPT_SUPPORT)
  430. host_prompt_do(PROMPT_USER_CONTINUE, PSTR("HeaterTimeout"), PSTR("Reheat"));
  431. #endif
  432. // Wait for LCD click or M108
  433. while (wait_for_user) idle(true);
  434. #if ENABLED(HOST_PROMPT_SUPPORT)
  435. host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheating"));
  436. #endif
  437. // Re-enable the heaters if they timed out
  438. HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e);
  439. // Wait for the heaters to reach the target temperatures
  440. ensure_safe_temperature();
  441. // Show the prompt to continue
  442. show_continue_prompt(is_reload);
  443. // Start the heater idle timers
  444. const millis_t nozzle_timeout = (millis_t)(PAUSE_PARK_NOZZLE_TIMEOUT) * 1000UL;
  445. HOTEND_LOOP()
  446. thermalManager.start_heater_idle_timer(e, nozzle_timeout);
  447. #if ENABLED(HOST_PROMPT_SUPPORT)
  448. host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), PSTR("Continue"));
  449. #endif
  450. wait_for_user = true;
  451. nozzle_timed_out = false;
  452. #if HAS_BUZZER
  453. filament_change_beep(max_beep_count, true);
  454. #endif
  455. }
  456. idle(true);
  457. }
  458. #if ENABLED(DUAL_X_CARRIAGE)
  459. active_extruder = saved_ext;
  460. extruder_duplication_enabled = saved_ext_dup_mode;
  461. stepper.set_directions();
  462. #endif
  463. KEEPALIVE_STATE(IN_HANDLER);
  464. }
  465. /**
  466. * Resume or Start print procedure
  467. *
  468. * - Abort if not paused
  469. * - Reset heater idle timers
  470. * - Load filament if specified, but only if:
  471. * - a nozzle timed out, or
  472. * - the nozzle is already heated.
  473. * - Display "wait for print to resume"
  474. * - Re-prime the nozzle...
  475. * - FWRETRACT: Recover/prime from the prior G10.
  476. * - !FWRETRACT: Retract by resume_position[E], if negative.
  477. * Not sure how this logic comes into use.
  478. * - Move the nozzle back to resume_position
  479. * - Sync the planner E to resume_position[E]
  480. * - Send host action for resume, if configured
  481. * - Resume the current SD print job, if any
  482. */
  483. 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) {
  484. /*
  485. SERIAL_ECHOLNPAIR(
  486. "start of resume_print()\ndual_x_carriage_mode:", dual_x_carriage_mode,
  487. "\nextruder_duplication_enabled:", extruder_duplication_enabled,
  488. "\nactive_extruder:", active_extruder,
  489. "\n"
  490. );
  491. //*/
  492. if (!did_pause_print) return;
  493. // Re-enable the heaters if they timed out
  494. bool nozzle_timed_out = false;
  495. HOTEND_LOOP() {
  496. nozzle_timed_out |= thermalManager.is_heater_idle(e);
  497. thermalManager.reset_heater_idle_timer(e);
  498. }
  499. if (nozzle_timed_out || thermalManager.hotEnoughToExtrude(active_extruder)) // Load the new filament
  500. load_filament(slow_load_length, fast_load_length, purge_length, max_beep_count, true, nozzle_timed_out, ADVANCED_PAUSE_MODE_PAUSE_PRINT DXC_PASS);
  501. #if HAS_LCD_MENU
  502. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_RESUME);
  503. #endif
  504. // Intelligent resuming
  505. #if ENABLED(FWRETRACT)
  506. // If retracted before goto pause
  507. if (fwretract.retracted[active_extruder])
  508. do_pause_e_move(-fwretract.settings.retract_length, fwretract.settings.retract_feedrate_mm_s);
  509. #endif
  510. // If resume_position is negative
  511. if (resume_position[E_AXIS] < 0) do_pause_e_move(resume_position[E_AXIS], PAUSE_PARK_RETRACT_FEEDRATE);
  512. // Move XY to starting position, then Z
  513. do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], NOZZLE_PARK_XY_FEEDRATE);
  514. // Move Z_AXIS to saved position
  515. do_blocking_move_to_z(resume_position[Z_AXIS], NOZZLE_PARK_Z_FEEDRATE);
  516. #if ADVANCED_PAUSE_RESUME_PRIME != 0
  517. do_pause_e_move(ADVANCED_PAUSE_RESUME_PRIME, ADVANCED_PAUSE_PURGE_FEEDRATE);
  518. #endif
  519. // Now all extrusion positions are resumed and ready to be confirmed
  520. // Set extruder to saved position
  521. planner.set_e_position_mm((destination[E_AXIS] = current_position[E_AXIS] = resume_position[E_AXIS]));
  522. #if HAS_LCD_MENU
  523. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
  524. #endif
  525. #ifdef ACTION_ON_RESUMED
  526. host_action_resumed();
  527. #elif defined(ACTION_ON_RESUME)
  528. host_action_resume();
  529. #endif
  530. --did_pause_print;
  531. #if ENABLED(HOST_PROMPT_SUPPORT)
  532. host_prompt_open(PROMPT_INFO, PSTR("Resume"));
  533. #endif
  534. #if ENABLED(SDSUPPORT)
  535. if (did_pause_print) {
  536. card.startFileprint();
  537. --did_pause_print;
  538. }
  539. #endif
  540. // Resume the print job timer if it was running
  541. if (print_job_timer.isPaused()) print_job_timer.start();
  542. ui.reset_status();
  543. }
  544. #endif // ADVANCED_PAUSE_FEATURE