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

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