This repository has been archived on 2022-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
Marlin-Artillery-M600/Marlin/src/feature/pause.cpp

625 lines
20 KiB
C++
Raw Normal View History

/**
* Marlin 3D Printer Firmware
2020-02-03 15:00:57 +01:00
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
2019-06-28 06:57:50 +02:00
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* feature/pause.cpp - Pause feature support functions
* This may be combined with related G-codes if features are consolidated.
*/
#include "../inc/MarlinConfigPre.h"
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#include "../MarlinCore.h"
#include "../gcode/gcode.h"
#include "../module/motion.h"
#include "../module/planner.h"
#include "../module/stepper.h"
#include "../module/printcounter.h"
#include "../module/temperature.h"
#if ENABLED(FWRETRACT)
2019-02-04 10:41:55 +01:00
#include "fwretract.h"
#endif
2019-02-13 03:08:34 +01:00
#if HAS_FILAMENT_SENSOR
2019-02-04 10:41:55 +01:00
#include "runout.h"
#endif
2019-02-12 22:55:47 +01:00
#if ENABLED(HOST_ACTION_COMMANDS)
#include "host_actions.h"
#endif
#if ENABLED(EXTENSIBLE_UI)
2020-03-13 22:29:29 +01:00
#include "../lcd/extui/ui_api.h"
#endif
#include "../lcd/ultralcd.h"
2019-07-29 02:14:50 +02:00
#if HAS_BUZZER
#include "../libs/buzzer.h"
#endif
#include "../libs/nozzle.h"
2018-02-22 19:28:46 +01:00
#include "pause.h"
// private:
2019-09-29 11:25:39 +02:00
static xyze_pos_t resume_position;
2020-02-14 06:39:27 +01:00
#if HAS_LCD_MENU
PauseMenuResponse pause_menu_response;
PauseMode pause_mode = PAUSE_MODE_PAUSE_PRINT;
#endif
fil_change_settings_t fc_settings[EXTRUDERS];
#if ENABLED(SDSUPPORT)
#include "../sd/cardreader.h"
#endif
2019-10-10 02:46:10 +02:00
#if ENABLED(EMERGENCY_PARSER)
#define _PMSG(L) L##_M108
#else
#define _PMSG(L) L##_LCD
#endif
2017-09-30 23:06:43 +02:00
#if HAS_BUZZER
static void filament_change_beep(const int8_t max_beep_count, const bool init=false) {
2020-02-14 06:39:27 +01:00
2020-04-22 23:35:03 +02:00
if (TERN0(HAS_LCD_MENU, pause_mode == PAUSE_MODE_PAUSE_PRINT)) return;
2020-02-14 06:39:27 +01:00
2017-09-30 23:06:43 +02:00
static millis_t next_buzz = 0;
static int8_t runout_beep = 0;
2017-09-30 23:06:43 +02:00
if (init) next_buzz = runout_beep = 0;
2017-09-30 23:06:43 +02:00
const millis_t ms = millis();
if (ELAPSED(ms, next_buzz)) {
if (max_beep_count < 0 || runout_beep < max_beep_count + 5) { // Only beep as long as we're supposed to
next_buzz = ms + ((max_beep_count < 0 || runout_beep < max_beep_count) ? 1000 : 500);
BUZZ(50, 880 - (runout_beep & 1) * 220);
2017-09-30 23:06:43 +02:00
runout_beep++;
}
}
}
2020-04-25 19:31:21 +02:00
#else
inline void filament_change_beep(const int8_t, const bool=false) {}
2017-09-30 23:06:43 +02:00
#endif
/**
* Ensure a safe temperature for extrusion
*
* - Fail if the TARGET temperature is too low
* - Display LCD placard with temperature status
* - Return when heating is done or aborted
*
* Returns 'true' if heating was completed, 'false' for abort
*/
static bool ensure_safe_temperature(const PauseMode mode=PAUSE_MODE_SAME) {
#if ENABLED(PREVENT_COLD_EXTRUSION)
if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder)) {
SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD);
return false;
}
#endif
2018-10-30 22:34:45 +01:00
#if HAS_LCD_MENU
lcd_pause_show_message(PAUSE_MESSAGE_HEATING, mode);
#else
UNUSED(mode);
#endif
return thermalManager.wait_for_hotend(active_extruder);
}
/**
* Load filament into the hotend
*
* - Fail if the a safe temperature was not reached
* - If pausing for confirmation, wait for a click or M108
* - Show "wait for load" placard
* - Load and purge filament
* - Show "Purge more" / "Continue" menu
* - Return when "Continue" is selected
*
* Returns 'true' if load was completed, 'false' for abort
*/
2018-03-20 19:19:10 +01:00
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*/,
const bool show_lcd/*=false*/, const bool pause_for_user/*=false*/,
const PauseMode mode/*=PAUSE_MODE_PAUSE_PRINT*/
2018-09-17 08:06:22 +02:00
DXC_ARGS
) {
2020-04-25 19:31:21 +02:00
TERN(HAS_LCD_MENU,,UNUSED(show_lcd));
2019-02-19 21:37:18 +01:00
if (!ensure_safe_temperature(mode)) {
2018-10-30 22:34:45 +01:00
#if HAS_LCD_MENU
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_STATUS, mode);
#endif
return false;
}
if (pause_for_user) {
2018-10-30 22:34:45 +01:00
#if HAS_LCD_MENU
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_INSERT, mode);
#endif
2020-02-26 11:11:03 +01:00
SERIAL_ECHO_MSG(_PMSG(STR_FILAMENT_CHANGE_INSERT));
2020-04-25 19:31:21 +02:00
filament_change_beep(max_beep_count, true);
KEEPALIVE_STATE(PAUSED_FOR_USER);
2019-02-12 22:55:47 +01:00
#if ENABLED(HOST_PROMPT_SUPPORT)
const char tool = '0'
#if NUM_RUNOUT_SENSORS > 1
+ active_extruder
#endif
;
2020-02-14 06:39:27 +01:00
host_action_prompt_begin(PROMPT_USER_CONTINUE, PSTR("Load Filament T"), tool);
host_action_prompt_button(CONTINUE_STR);
2019-02-12 22:55:47 +01:00
host_action_prompt_show();
#endif
2020-04-22 23:35:03 +02:00
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Load Filament")));
while (wait_for_user) {
2020-04-25 19:31:21 +02:00
filament_change_beep(max_beep_count);
2020-02-27 13:34:48 +01:00
idle_no_sleep();
}
}
2018-10-30 22:34:45 +01:00
#if HAS_LCD_MENU
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_LOAD, mode);
#endif
2018-09-17 08:06:22 +02:00
#if ENABLED(DUAL_X_CARRIAGE)
const int8_t saved_ext = active_extruder;
const bool saved_ext_dup_mode = extruder_duplication_enabled;
active_extruder = DXC_ext;
extruder_duplication_enabled = false;
#endif
2018-03-20 19:19:10 +01:00
// Slow Load filament
2020-03-29 23:26:55 +02:00
if (slow_load_length) unscaled_e_move(slow_load_length, FILAMENT_CHANGE_SLOW_LOAD_FEEDRATE);
2018-03-20 19:19:10 +01:00
// Fast Load Filament
if (fast_load_length) {
#if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
const float saved_acceleration = planner.settings.retract_acceleration;
planner.settings.retract_acceleration = FILAMENT_CHANGE_FAST_LOAD_ACCEL;
2018-03-20 19:19:10 +01:00
#endif
2020-03-29 23:26:55 +02:00
unscaled_e_move(fast_load_length, FILAMENT_CHANGE_FAST_LOAD_FEEDRATE);
2018-03-20 19:19:10 +01:00
#if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
planner.settings.retract_acceleration = saved_acceleration;
2018-03-20 19:19:10 +01:00
#endif
}
2018-09-17 08:06:22 +02:00
#if ENABLED(DUAL_X_CARRIAGE) // Tie the two extruders movement back together.
active_extruder = saved_ext;
extruder_duplication_enabled = saved_ext_dup_mode;
stepper.set_directions();
#endif
#if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)
2018-10-30 22:34:45 +01:00
#if HAS_LCD_MENU
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
#endif
2020-04-22 23:35:03 +02:00
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging...")));
wait_for_user = true; // A click or M108 breaks the purge_length loop
for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
2020-03-29 23:26:55 +02:00
unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
wait_for_user = false;
#else
do {
if (purge_length > 0) {
// "Wait for filament purge"
2018-10-30 22:34:45 +01:00
#if HAS_LCD_MENU
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
#endif
// Extrude filament to get into hotend
2020-03-29 23:26:55 +02:00
unscaled_e_move(purge_length, ADVANCED_PAUSE_PURGE_FEEDRATE);
}
2020-04-22 23:35:03 +02:00
TERN_(HOST_PROMPT_SUPPORT, filament_load_host_prompt()); // Initiate another host prompt. (NOTE: host_response_handler may also do this!)
2019-02-12 22:55:47 +01:00
2018-10-30 22:34:45 +01:00
#if HAS_LCD_MENU
if (show_lcd) {
2020-02-14 06:39:27 +01:00
// Show "Purge More" / "Resume" menu and wait for reply
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = false;
lcd_pause_show_message(PAUSE_MESSAGE_OPTION);
2020-02-27 13:34:48 +01:00
while (pause_menu_response == PAUSE_RESPONSE_WAIT_FOR) idle_no_sleep();
}
#endif
// Keep looping if "Purge More" was selected
2020-04-22 23:35:03 +02:00
} while (TERN0(HAS_LCD_MENU, show_lcd && pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE));
2018-03-20 19:19:10 +01:00
#endif
return true;
}
/**
* Unload filament from the hotend
*
* - Fail if the a safe temperature was not reached
* - Show "wait for unload" placard
* - Retract, pause, then unload filament
* - Disable E stepper (on most machines)
*
* Returns 'true' if unload was completed, 'false' for abort
*/
bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
const PauseMode mode/*=PAUSE_MODE_PAUSE_PRINT*/
#if BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
, const float &mix_multiplier/*=1.0*/
#endif
) {
2020-04-25 19:31:21 +02:00
TERN(HAS_LCD_MENU,,UNUSED(show_lcd));
2019-02-19 21:37:18 +01:00
#if !BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
constexpr float mix_multiplier = 1.0;
#endif
if (!ensure_safe_temperature(mode)) {
2018-10-30 22:34:45 +01:00
#if HAS_LCD_MENU
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
#endif
return false;
}
#if HAS_LCD_MENU
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_UNLOAD, mode);
2017-10-23 16:34:16 +02:00
#endif
// Retract filament
2020-03-29 23:26:55 +02:00
unscaled_e_move(-(FILAMENT_UNLOAD_PURGE_RETRACT) * mix_multiplier, (PAUSE_PARK_RETRACT_FEEDRATE) * mix_multiplier);
// Wait for filament to cool
2019-12-13 05:14:36 +01:00
safe_delay(FILAMENT_UNLOAD_PURGE_DELAY);
// Quickly purge
2020-03-29 23:26:55 +02:00
unscaled_e_move((FILAMENT_UNLOAD_PURGE_RETRACT + FILAMENT_UNLOAD_PURGE_LENGTH) * mix_multiplier,
(FILAMENT_UNLOAD_PURGE_FEEDRATE) * mix_multiplier);
// Unload filament
2018-03-20 19:19:10 +01:00
#if FILAMENT_CHANGE_UNLOAD_ACCEL > 0
const float saved_acceleration = planner.settings.retract_acceleration;
planner.settings.retract_acceleration = FILAMENT_CHANGE_UNLOAD_ACCEL;
2018-03-20 19:19:10 +01:00
#endif
2020-03-29 23:26:55 +02:00
unscaled_e_move(unload_length * mix_multiplier, (FILAMENT_CHANGE_UNLOAD_FEEDRATE) * mix_multiplier);
2018-03-20 19:19:10 +01:00
#if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
planner.settings.retract_acceleration = saved_acceleration;
2018-03-20 19:19:10 +01:00
#endif
// Disable E steppers for manual change
#if HAS_E_STEPPER_ENABLE
disable_e_stepper(active_extruder);
safe_delay(100);
#endif
return true;
2017-10-23 16:34:16 +02:00
}
// public:
/**
* Pause procedure
*
* - Abort if already paused
* - Send host action for pause, if configured
* - Abort if TARGET temperature is too low
* - Display "wait for start of filament change" (if a length was specified)
* - Initial retract, if current temperature is hot enough
* - Park the nozzle at the given position
* - Call unload_filament (if a length was specified)
*
2019-10-03 01:54:20 +02:00
* Return 'true' if pause was completed, 'false' for abort
*/
uint8_t did_pause_print = 0;
2019-09-29 11:25:39 +02:00
bool pause_print(const float &retract, const xyz_pos_t &park_point, const float &unload_length/*=0*/, const bool show_lcd/*=false*/ DXC_ARGS) {
2020-04-25 19:31:21 +02:00
TERN(HAS_LCD_MENU,,UNUSED(show_lcd));
2019-02-19 21:37:18 +01:00
if (did_pause_print) return false; // already paused
2019-02-12 22:55:47 +01:00
#if ENABLED(HOST_ACTION_COMMANDS)
#ifdef ACTION_ON_PAUSED
host_action_paused();
#elif defined(ACTION_ON_PAUSE)
host_action_pause();
#endif
2017-12-25 08:36:42 +01:00
#endif
2020-04-22 23:35:03 +02:00
TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Pause"), DISMISS_STR));
2019-09-28 00:06:26 +02:00
if (!DEBUGGING(DRYRUN) && unload_length && thermalManager.targetTooColdToExtrude(active_extruder)) {
SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD);
2018-10-30 22:34:45 +01:00
#if HAS_LCD_MENU
2018-01-22 11:30:49 +01:00
if (show_lcd) { // Show status screen
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
2018-01-22 11:30:49 +01:00
LCD_MESSAGEPGM(MSG_M600_TOO_COLD);
}
#endif
return false; // unable to reach safe temperature
}
// Indicate that the printer is paused
++did_pause_print;
// Pause the print job and timer
#if ENABLED(SDSUPPORT)
2018-11-07 03:52:39 +01:00
if (IS_SD_PRINTING()) {
card.pauseSDPrint();
++did_pause_print; // Indicate SD pause also
}
#endif
2018-11-07 03:52:39 +01:00
print_job_timer.pause();
// Save current position
2019-09-29 11:25:39 +02:00
resume_position = current_position;
2017-10-23 16:34:16 +02:00
2018-05-04 03:51:10 +02:00
// Wait for buffered blocks to complete
planner.synchronize();
2018-05-04 03:51:10 +02:00
2020-04-27 11:41:18 +02:00
#if ENABLED(ADVANCED_PAUSE_FANS_PAUSE) && HAS_FAN
thermalManager.set_fans_paused(true);
#endif
2017-10-23 16:34:16 +02:00
// Initial retract before move to filament change position
2018-01-22 11:29:29 +01:00
if (retract && thermalManager.hotEnoughToExtrude(active_extruder))
2020-03-29 23:26:55 +02:00
unscaled_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
// Park the nozzle by moving up by z_lift and then moving to (x_pos, y_pos)
if (!axes_need_homing())
2020-04-25 05:39:08 +02:00
nozzle.park(0, park_point);
2018-09-17 08:06:22 +02:00
#if ENABLED(DUAL_X_CARRIAGE)
const int8_t saved_ext = active_extruder;
const bool saved_ext_dup_mode = extruder_duplication_enabled;
active_extruder = DXC_ext;
extruder_duplication_enabled = false;
#endif
if (unload_length) // Unload the filament
unload_filament(unload_length, show_lcd, PAUSE_MODE_CHANGE_FILAMENT);
2018-09-17 08:06:22 +02:00
#if ENABLED(DUAL_X_CARRIAGE)
active_extruder = saved_ext;
extruder_duplication_enabled = saved_ext_dup_mode;
stepper.set_directions();
#endif
return true;
}
/**
* For Paused Print:
* - Show "Press button (or M108) to resume"
*
* For Filament Change:
* - Show "Insert filament and press button to continue"
*
* - Wait for a click before returning
* - Heaters can time out and must reheat before continuing
*
* Used by M125 and M600
*/
void show_continue_prompt(const bool is_reload) {
2020-04-22 23:35:03 +02:00
TERN_(HAS_LCD_MENU, lcd_pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING));
SERIAL_ECHO_START();
2020-02-26 11:11:03 +01:00
serialprintPGM(is_reload ? PSTR(_PMSG(STR_FILAMENT_CHANGE_INSERT) "\n") : PSTR(_PMSG(STR_FILAMENT_CHANGE_WAIT) "\n"));
}
void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep_count/*=0*/ DXC_ARGS) {
bool nozzle_timed_out = false;
show_continue_prompt(is_reload);
2020-04-25 19:31:21 +02:00
filament_change_beep(max_beep_count, true);
// Start the heater idle timers
2020-04-04 02:49:45 +02:00
const millis_t nozzle_timeout = SEC_TO_MS(PAUSE_PARK_NOZZLE_TIMEOUT);
HOTEND_LOOP() thermalManager.hotend_idle[e].start(nozzle_timeout);
2018-09-17 08:06:22 +02:00
#if ENABLED(DUAL_X_CARRIAGE)
const int8_t saved_ext = active_extruder;
const bool saved_ext_dup_mode = extruder_duplication_enabled;
active_extruder = DXC_ext;
extruder_duplication_enabled = false;
#endif
// Wait for filament insert by user and press button
KEEPALIVE_STATE(PAUSED_FOR_USER);
2020-04-22 23:35:03 +02:00
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_NOZZLE_PARKED), CONTINUE_STR));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_NOZZLE_PARKED)));
wait_for_user = true; // LCD click or M108 will clear this
while (wait_for_user) {
2020-04-25 19:31:21 +02:00
filament_change_beep(max_beep_count);
// If the nozzle has timed out...
if (!nozzle_timed_out)
HOTEND_LOOP() nozzle_timed_out |= thermalManager.hotend_idle[e].timed_out;
// Wait for the user to press the button to re-heat the nozzle, then
// re-heat the nozzle, re-show the continue prompt, restart idle timers, start over
if (nozzle_timed_out) {
2020-04-22 23:35:03 +02:00
TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_HEAT));
2020-02-26 11:11:03 +01:00
SERIAL_ECHO_MSG(_PMSG(STR_FILAMENT_CHANGE_HEAT));
2020-04-22 23:35:03 +02:00
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_HEATER_TIMEOUT), GET_TEXT(MSG_REHEAT)));
2019-02-12 22:55:47 +01:00
2020-04-22 23:35:03 +02:00
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_HEATER_TIMEOUT)));
wait_for_user_response(0, true); // Wait for LCD click or M108
2020-04-22 23:35:03 +02:00
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, GET_TEXT(MSG_REHEATING)));
TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING)));
2019-02-12 22:55:47 +01:00
// Re-enable the heaters if they timed out
HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e);
// Wait for the heaters to reach the target temperatures
ensure_safe_temperature();
// Show the prompt to continue
show_continue_prompt(is_reload);
// Start the heater idle timers
2020-04-04 02:49:45 +02:00
const millis_t nozzle_timeout = SEC_TO_MS(PAUSE_PARK_NOZZLE_TIMEOUT);
HOTEND_LOOP() thermalManager.hotend_idle[e].start(nozzle_timeout);
2020-04-22 23:35:03 +02:00
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), CONTINUE_STR));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Reheat finished.")));
wait_for_user = true;
nozzle_timed_out = false;
2020-04-25 19:31:21 +02:00
filament_change_beep(max_beep_count, true);
}
2020-02-27 13:34:48 +01:00
idle_no_sleep();
}
2018-09-17 08:06:22 +02:00
#if ENABLED(DUAL_X_CARRIAGE)
active_extruder = saved_ext;
extruder_duplication_enabled = saved_ext_dup_mode;
stepper.set_directions();
#endif
}
/**
* Resume or Start print procedure
*
2019-10-03 01:54:20 +02:00
* - If not paused, do nothing and return
* - Reset heater idle timers
* - Load filament if specified, but only if:
* - a nozzle timed out, or
* - the nozzle is already heated.
* - Display "wait for print to resume"
* - Retract to prevent oozing
* - Move the nozzle back to resume_position
* - Unretract
* - Re-prime the nozzle...
* - FWRETRACT: Recover/prime from the prior G10.
2019-09-29 11:25:39 +02:00
* - !FWRETRACT: Retract by resume_position.e, if negative.
* Not sure how this logic comes into use.
2019-09-29 11:25:39 +02:00
* - Sync the planner E to resume_position.e
* - Send host action for resume, if configured
* - Resume the current SD print job, if any
*/
2018-09-17 08:06:22 +02:00
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) {
/*
SERIAL_ECHOLNPAIR(
"start of resume_print()\ndual_x_carriage_mode:", dual_x_carriage_mode,
"\nextruder_duplication_enabled:", extruder_duplication_enabled,
"\nactive_extruder:", active_extruder,
"\n"
);
//*/
2018-09-17 08:06:22 +02:00
if (!did_pause_print) return;
// Re-enable the heaters if they timed out
bool nozzle_timed_out = false;
HOTEND_LOOP() {
nozzle_timed_out |= thermalManager.hotend_idle[e].timed_out;
thermalManager.reset_hotend_idle_timer(e);
}
2018-09-17 08:06:22 +02:00
if (nozzle_timed_out || thermalManager.hotEnoughToExtrude(active_extruder)) // Load the new filament
load_filament(slow_load_length, fast_load_length, purge_length, max_beep_count, true, nozzle_timed_out, PAUSE_MODE_SAME DXC_PASS);
2020-04-22 23:35:03 +02:00
TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_RESUME));
// Retract to prevent oozing
unscaled_e_move(-(PAUSE_PARK_RETRACT_LENGTH), feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE));
// Move XY to starting position, then Z
do_blocking_move_to_xy(resume_position, feedRate_t(NOZZLE_PARK_XY_FEEDRATE));
// Move Z_AXIS to saved position
do_blocking_move_to_z(resume_position.z, feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
// Unretract
unscaled_e_move(PAUSE_PARK_RETRACT_LENGTH, feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE));
// Intelligent resuming
#if ENABLED(FWRETRACT)
// If retracted before goto pause
if (fwretract.retracted[active_extruder])
2020-03-29 23:26:55 +02:00
unscaled_e_move(-fwretract.settings.retract_length, fwretract.settings.retract_feedrate_mm_s);
#endif
2018-03-20 19:19:10 +01:00
2018-01-29 21:57:37 +01:00
// If resume_position is negative
2020-03-29 23:26:55 +02:00
if (resume_position.e < 0) unscaled_e_move(resume_position.e, feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE));
2019-02-06 13:39:42 +01:00
#if ADVANCED_PAUSE_RESUME_PRIME != 0
2020-03-29 23:26:55 +02:00
unscaled_e_move(ADVANCED_PAUSE_RESUME_PRIME, feedRate_t(ADVANCED_PAUSE_PURGE_FEEDRATE));
2019-02-06 13:39:42 +01:00
#endif
// Now all extrusion positions are resumed and ready to be confirmed
// Set extruder to saved position
2019-09-29 11:25:39 +02:00
planner.set_e_position_mm((destination.e = current_position.e = resume_position.e));
2020-04-22 23:35:03 +02:00
TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_STATUS));
2019-01-28 05:43:13 +01:00
#ifdef ACTION_ON_RESUMED
host_action_resumed();
#elif defined(ACTION_ON_RESUME)
host_action_resume();
2017-12-25 08:36:42 +01:00
#endif
--did_pause_print;
2020-04-22 23:35:03 +02:00
TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Resuming"), DISMISS_STR));
2019-09-28 00:06:26 +02:00
#if ENABLED(SDSUPPORT)
if (did_pause_print) { card.startFileprint(); --did_pause_print; }
#endif
2020-04-27 11:41:18 +02:00
#if ENABLED(ADVANCED_PAUSE_FANS_PAUSE) && HAS_FAN
thermalManager.set_fans_paused(false);
#endif
2020-04-22 23:35:03 +02:00
TERN_(HAS_FILAMENT_SENSOR, runout.reset());
// Resume the print job timer if it was running
if (print_job_timer.isPaused()) print_job_timer.start();
2020-04-22 23:35:03 +02:00
TERN_(HAS_DISPLAY, ui.reset_status());
TERN_(HAS_LCD_MENU, ui.return_to_status());
}
#endif // ADVANCED_PAUSE_FEATURE