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

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