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

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