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

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