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.

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