My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

pause.cpp 20KB

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