2017-09-06 11:28:31 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-02-12 21:06:53 +00:00
|
|
|
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 11:28:31 +00:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2017-09-16 07:13:07 +00:00
|
|
|
* feature/pause.cpp - Pause feature support functions
|
|
|
|
* This may be combined with related G-codes if features are consolidated.
|
2017-09-06 11:28:31 +00:00
|
|
|
*/
|
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
#include "../inc/MarlinConfigPre.h"
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
2017-09-16 07:13:07 +00:00
|
|
|
|
|
|
|
#include "../Marlin.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"
|
|
|
|
|
2018-01-04 05:18:27 +00:00
|
|
|
#if ENABLED(FWRETRACT)
|
2019-02-04 09:41:55 +00:00
|
|
|
#include "fwretract.h"
|
2018-01-04 05:18:27 +00:00
|
|
|
#endif
|
|
|
|
|
2019-02-13 02:08:34 +00:00
|
|
|
#if HAS_FILAMENT_SENSOR
|
2019-02-04 09:41:55 +00:00
|
|
|
#include "runout.h"
|
2017-10-10 07:35:20 +00:00
|
|
|
#endif
|
|
|
|
|
2019-02-12 21:55:47 +00:00
|
|
|
#if ENABLED(HOST_ACTION_COMMANDS)
|
|
|
|
#include "host_actions.h"
|
|
|
|
#endif
|
|
|
|
|
2018-11-29 01:28:31 +00:00
|
|
|
#include "../lcd/ultralcd.h"
|
2017-09-16 07:13:07 +00:00
|
|
|
#include "../libs/buzzer.h"
|
2017-12-25 07:38:06 +00:00
|
|
|
#include "../libs/nozzle.h"
|
2018-02-22 18:28:46 +00:00
|
|
|
#include "pause.h"
|
2017-09-16 07:13:07 +00:00
|
|
|
|
|
|
|
// private:
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
static float resume_position[XYZE];
|
2017-09-16 07:13:07 +00:00
|
|
|
|
2019-03-14 07:26:07 +00:00
|
|
|
PauseMode pause_mode = PAUSE_MODE_PAUSE_PRINT;
|
|
|
|
|
|
|
|
PauseMenuResponse pause_menu_response;
|
2018-01-04 11:06:34 +00:00
|
|
|
|
2018-10-10 14:45:20 +00:00
|
|
|
fil_change_settings_t fc_settings[EXTRUDERS];
|
2018-01-04 11:06:34 +00:00
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
#if ENABLED(SDSUPPORT)
|
2017-09-16 07:13:07 +00:00
|
|
|
#include "../sd/cardreader.h"
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
|
2017-09-30 21:06:43 +00:00
|
|
|
#if HAS_BUZZER
|
|
|
|
static void filament_change_beep(const int8_t max_beep_count, const bool init=false) {
|
2019-03-14 07:26:07 +00:00
|
|
|
if (pause_mode == PAUSE_MODE_PAUSE_PRINT) return;
|
2017-09-30 21:06:43 +00:00
|
|
|
static millis_t next_buzz = 0;
|
|
|
|
static int8_t runout_beep = 0;
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2017-09-30 21:06:43 +00:00
|
|
|
if (init) next_buzz = runout_beep = 0;
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2017-09-30 21:06:43 +00: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
|
2018-01-04 11:06:34 +00:00
|
|
|
next_buzz = ms + ((max_beep_count < 0 || runout_beep < max_beep_count) ? 1000 : 500);
|
|
|
|
BUZZ(50, 880 - (runout_beep & 1) * 220);
|
2017-09-30 21:06:43 +00:00
|
|
|
runout_beep++;
|
|
|
|
}
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-30 21:06:43 +00:00
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-01-22 10:37:40 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2019-03-14 07:26:07 +00:00
|
|
|
static bool ensure_safe_temperature(const PauseMode mode=PAUSE_MODE_SAME) {
|
2018-01-04 11:06:34 +00:00
|
|
|
|
|
|
|
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
|
|
|
if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder)) {
|
2019-01-21 18:50:30 +00:00
|
|
|
SERIAL_ECHO_MSG(MSG_ERR_HOTEND_TOO_COLD);
|
2018-01-04 11:06:34 +00:00
|
|
|
return false;
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif
|
|
|
|
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
lcd_pause_show_message(PAUSE_MESSAGE_HEATING, mode);
|
2018-01-04 11:06:34 +00:00
|
|
|
#else
|
|
|
|
UNUSED(mode);
|
|
|
|
#endif
|
|
|
|
|
2018-09-29 06:44:47 +00:00
|
|
|
return thermalManager.wait_for_hotend(active_extruder);
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
|
2019-02-14 22:41:46 +00:00
|
|
|
void do_pause_e_move(const float &length, const float &fr_mm_s) {
|
2019-02-13 02:08:34 +00:00
|
|
|
#if HAS_FILAMENT_SENSOR
|
2019-02-06 12:39:42 +00:00
|
|
|
runout.reset();
|
|
|
|
#endif
|
2018-10-06 21:36:24 +00:00
|
|
|
current_position[E_AXIS] += length / planner.e_factor[active_extruder];
|
2019-02-14 22:41:46 +00:00
|
|
|
planner.buffer_line(current_position, fr_mm_s, active_extruder);
|
2018-05-12 06:38:02 +00:00
|
|
|
planner.synchronize();
|
2018-01-04 11:06:34 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 10:37:40 +00:00
|
|
|
/**
|
|
|
|
* 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 18:19:10 +00: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*/,
|
2018-01-22 16:21:42 +00:00
|
|
|
const bool show_lcd/*=false*/, const bool pause_for_user/*=false*/,
|
2019-03-14 07:26:07 +00:00
|
|
|
const PauseMode mode/*=PAUSE_MODE_PAUSE_PRINT*/
|
2018-09-17 06:06:22 +00:00
|
|
|
DXC_ARGS
|
2018-01-04 11:06:34 +00:00
|
|
|
) {
|
2019-02-19 20:37:18 +00:00
|
|
|
#if !HAS_LCD_MENU
|
|
|
|
UNUSED(show_lcd);
|
|
|
|
#endif
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
if (!ensure_safe_temperature(mode)) {
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_STATUS, mode);
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pause_for_user) {
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_INSERT, mode);
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif
|
2018-11-29 22:58:58 +00:00
|
|
|
SERIAL_ECHO_MSG(MSG_FILAMENT_CHANGE_INSERT);
|
2018-01-04 11:06:34 +00:00
|
|
|
|
|
|
|
#if HAS_BUZZER
|
|
|
|
filament_change_beep(max_beep_count, true);
|
|
|
|
#else
|
|
|
|
UNUSED(max_beep_count);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
|
|
|
wait_for_user = true; // LCD click or M108 will clear this
|
2019-02-12 21:55:47 +00:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
const char tool = '0'
|
|
|
|
#if NUM_RUNOUT_SENSORS > 1
|
|
|
|
+ active_extruder
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
host_prompt_reason = PROMPT_USER_CONTINUE;
|
|
|
|
host_action_prompt_end();
|
|
|
|
host_action_prompt_begin(PSTR("Load Filament T"), false);
|
|
|
|
SERIAL_CHAR(tool);
|
|
|
|
SERIAL_EOL();
|
|
|
|
host_action_prompt_button(PSTR("Continue"));
|
|
|
|
host_action_prompt_show();
|
|
|
|
#endif
|
2018-01-04 11:06:34 +00:00
|
|
|
while (wait_for_user) {
|
|
|
|
#if HAS_BUZZER
|
|
|
|
filament_change_beep(max_beep_count);
|
|
|
|
#endif
|
|
|
|
idle(true);
|
|
|
|
}
|
|
|
|
KEEPALIVE_STATE(IN_HANDLER);
|
|
|
|
}
|
|
|
|
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_LOAD, mode);
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif
|
|
|
|
|
2018-09-17 06:06:22 +00: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 18:19:10 +00:00
|
|
|
// Slow Load filament
|
|
|
|
if (slow_load_length) do_pause_e_move(slow_load_length, FILAMENT_CHANGE_SLOW_LOAD_FEEDRATE);
|
|
|
|
|
|
|
|
// Fast Load Filament
|
|
|
|
if (fast_load_length) {
|
|
|
|
#if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
|
2018-10-10 14:45:20 +00:00
|
|
|
const float saved_acceleration = planner.settings.retract_acceleration;
|
|
|
|
planner.settings.retract_acceleration = FILAMENT_CHANGE_FAST_LOAD_ACCEL;
|
2018-03-20 18:19:10 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
do_pause_e_move(fast_load_length, FILAMENT_CHANGE_FAST_LOAD_FEEDRATE);
|
|
|
|
|
|
|
|
#if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.settings.retract_acceleration = saved_acceleration;
|
2018-03-20 18:19:10 +00:00
|
|
|
#endif
|
|
|
|
}
|
2018-01-04 11:06:34 +00:00
|
|
|
|
2018-09-17 06:06:22 +00: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
|
|
|
|
|
2018-03-20 18:33:01 +00:00
|
|
|
#if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)
|
2018-01-04 11:06:34 +00:00
|
|
|
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif
|
|
|
|
|
2018-03-20 18:33:01 +00:00
|
|
|
wait_for_user = true;
|
2019-02-12 21:55:47 +00:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Continuous Purge Running..."), PSTR("Continue"));
|
|
|
|
#endif
|
2018-03-20 18:33:01 +00:00
|
|
|
for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
|
2018-03-20 18:19:10 +00:00
|
|
|
do_pause_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
|
2018-03-20 18:33:01 +00:00
|
|
|
wait_for_user = false;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (purge_length > 0) {
|
|
|
|
// "Wait for filament purge"
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
|
2018-03-20 18:33:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Extrude filament to get into hotend
|
2018-03-20 18:19:10 +00:00
|
|
|
do_pause_e_move(purge_length, ADVANCED_PAUSE_PURGE_FEEDRATE);
|
2018-03-20 18:33:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Show "Purge More" / "Resume" menu and wait for reply
|
2019-02-12 21:55:47 +00:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
|
|
|
|
host_action_prompt_end(); // Close current prompt
|
|
|
|
host_action_prompt_begin(PSTR("Paused"));
|
|
|
|
host_action_prompt_button(PSTR("PurgeMore"));
|
|
|
|
if (false
|
2019-02-13 02:08:34 +00:00
|
|
|
#if HAS_FILAMENT_SENSOR
|
2019-02-12 21:55:47 +00:00
|
|
|
|| runout.filament_ran_out
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
host_action_prompt_button(PSTR("DisableRunout"));
|
|
|
|
else {
|
|
|
|
host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
|
|
|
|
host_action_prompt_button(PSTR("Continue"));
|
|
|
|
}
|
|
|
|
host_action_prompt_show();
|
|
|
|
#endif
|
|
|
|
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2018-03-20 18:33:01 +00:00
|
|
|
if (show_lcd) {
|
|
|
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
|
|
|
wait_for_user = false;
|
2019-03-14 07:26:07 +00:00
|
|
|
lcd_pause_show_message(PAUSE_MESSAGE_OPTION);
|
|
|
|
while (pause_menu_response == PAUSE_RESPONSE_WAIT_FOR) idle(true);
|
2018-03-20 18:33:01 +00:00
|
|
|
KEEPALIVE_STATE(IN_HANDLER);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Keep looping if "Purge More" was selected
|
2019-02-04 08:22:48 +00:00
|
|
|
} while (false
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
|| (show_lcd && pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE)
|
2018-03-20 18:33:01 +00:00
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
2018-03-20 18:19:10 +00:00
|
|
|
#endif
|
2018-01-04 11:06:34 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-01-22 10:37:40 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2018-01-04 11:06:34 +00:00
|
|
|
bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
|
2019-03-14 07:26:07 +00:00
|
|
|
const PauseMode mode/*=PAUSE_MODE_PAUSE_PRINT*/
|
2018-01-04 11:06:34 +00:00
|
|
|
) {
|
2019-02-19 20:37:18 +00:00
|
|
|
#if !HAS_LCD_MENU
|
|
|
|
UNUSED(show_lcd);
|
|
|
|
#endif
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
if (!ensure_safe_temperature(mode)) {
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-11-07 01:25:57 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_UNLOAD, mode);
|
2017-10-23 14:34:16 +00:00
|
|
|
#endif
|
2018-01-04 11:06:34 +00:00
|
|
|
|
|
|
|
// Retract filament
|
|
|
|
do_pause_e_move(-FILAMENT_UNLOAD_RETRACT_LENGTH, PAUSE_PARK_RETRACT_FEEDRATE);
|
|
|
|
|
|
|
|
// Wait for filament to cool
|
|
|
|
safe_delay(FILAMENT_UNLOAD_DELAY);
|
|
|
|
|
|
|
|
// Quickly purge
|
2018-10-10 14:45:20 +00:00
|
|
|
do_pause_e_move(FILAMENT_UNLOAD_RETRACT_LENGTH + FILAMENT_UNLOAD_PURGE_LENGTH, planner.settings.max_feedrate_mm_s[E_AXIS]);
|
2018-01-04 11:06:34 +00:00
|
|
|
|
|
|
|
// Unload filament
|
2018-03-20 18:19:10 +00:00
|
|
|
#if FILAMENT_CHANGE_UNLOAD_ACCEL > 0
|
2018-10-10 14:45:20 +00:00
|
|
|
const float saved_acceleration = planner.settings.retract_acceleration;
|
|
|
|
planner.settings.retract_acceleration = FILAMENT_CHANGE_UNLOAD_ACCEL;
|
2018-03-20 18:19:10 +00:00
|
|
|
#endif
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
do_pause_e_move(unload_length, FILAMENT_CHANGE_UNLOAD_FEEDRATE);
|
|
|
|
|
2018-03-20 18:19:10 +00:00
|
|
|
#if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
|
2018-10-10 14:45:20 +00:00
|
|
|
planner.settings.retract_acceleration = saved_acceleration;
|
2018-03-20 18:19:10 +00:00
|
|
|
#endif
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
// Disable extruders steppers for manual filament changing (only on boards that have separate ENABLE_PINS)
|
2019-01-24 01:06:54 +00:00
|
|
|
#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)
|
2018-01-04 11:06:34 +00:00
|
|
|
disable_e_stepper(active_extruder);
|
|
|
|
safe_delay(100);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
2017-10-23 14:34:16 +00:00
|
|
|
}
|
|
|
|
|
2017-09-16 07:13:07 +00:00
|
|
|
// public:
|
|
|
|
|
2018-01-22 10:37:40 +00:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
*
|
|
|
|
* Returns 'true' if pause was completed, 'false' for abort
|
|
|
|
*/
|
2017-12-30 10:03:41 +00:00
|
|
|
uint8_t did_pause_print = 0;
|
2017-09-16 07:13:07 +00:00
|
|
|
|
2018-09-17 06:06:22 +00:00
|
|
|
bool pause_print(const float &retract, const point_t &park_point, const float &unload_length/*=0*/, const bool show_lcd/*=false*/ DXC_ARGS) {
|
|
|
|
|
2019-02-19 20:37:18 +00:00
|
|
|
#if !HAS_LCD_MENU
|
|
|
|
UNUSED(show_lcd);
|
|
|
|
#endif
|
|
|
|
|
2017-12-30 10:03:41 +00:00
|
|
|
if (did_pause_print) return false; // already paused
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2019-02-12 21:55:47 +00:00
|
|
|
#if ENABLED(HOST_ACTION_COMMANDS)
|
|
|
|
#ifdef ACTION_ON_PAUSED
|
|
|
|
host_action_paused();
|
|
|
|
#elif defined(ACTION_ON_PAUSE)
|
|
|
|
host_action_pause();
|
|
|
|
#endif
|
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
host_prompt_open(PROMPT_INFO, PSTR("Pause"));
|
|
|
|
#endif
|
2017-12-25 07:36:42 +00:00
|
|
|
#endif
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
if (!DEBUGGING(DRYRUN) && unload_length && thermalManager.targetTooColdToExtrude(active_extruder)) {
|
2019-01-21 18:50:30 +00:00
|
|
|
SERIAL_ECHO_MSG(MSG_ERR_HOTEND_TOO_COLD);
|
2018-01-04 11:06:34 +00:00
|
|
|
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2018-01-22 10:30:49 +00:00
|
|
|
if (show_lcd) { // Show status screen
|
2019-03-14 07:26:07 +00:00
|
|
|
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
|
2018-01-22 10:30:49 +00:00
|
|
|
LCD_MESSAGEPGM(MSG_M600_TOO_COLD);
|
|
|
|
}
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
return false; // unable to reach safe temperature
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Indicate that the printer is paused
|
2017-12-30 10:03:41 +00:00
|
|
|
++did_pause_print;
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
// Pause the print job and timer
|
|
|
|
#if ENABLED(SDSUPPORT)
|
2018-11-07 02:52:39 +00:00
|
|
|
if (IS_SD_PRINTING()) {
|
2017-09-06 11:28:31 +00:00
|
|
|
card.pauseSDPrint();
|
2018-01-22 10:37:40 +00:00
|
|
|
++did_pause_print; // Indicate SD pause also
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
#endif
|
2018-11-07 02:52:39 +00:00
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
print_job_timer.pause();
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
// Save current position
|
|
|
|
COPY(resume_position, current_position);
|
2017-10-23 14:34:16 +00:00
|
|
|
|
2018-05-04 01:51:10 +00:00
|
|
|
// Wait for buffered blocks to complete
|
2018-05-12 06:38:02 +00:00
|
|
|
planner.synchronize();
|
2018-05-04 01:51:10 +00:00
|
|
|
|
2017-10-23 14:34:16 +00:00
|
|
|
// Initial retract before move to filament change position
|
2018-01-22 10:29:29 +00:00
|
|
|
if (retract && thermalManager.hotEnoughToExtrude(active_extruder))
|
2017-12-25 07:38:06 +00:00
|
|
|
do_pause_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-07-17 02:49:29 +00:00
|
|
|
// Park the nozzle by moving up by z_lift and then moving to (x_pos, y_pos)
|
|
|
|
if (!axis_unhomed_error())
|
|
|
|
Nozzle::park(2, park_point);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-09-17 06:06:22 +00: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
|
2018-01-04 11:06:34 +00:00
|
|
|
unload_filament(unload_length, show_lcd);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-09-17 06:06:22 +00:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
active_extruder = saved_ext;
|
|
|
|
extruder_duplication_enabled = saved_ext_dup_mode;
|
|
|
|
stepper.set_directions();
|
|
|
|
#endif
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-01-22 10:37:40 +00:00
|
|
|
/**
|
2018-11-18 04:21:44 +00:00
|
|
|
* For Paused Print:
|
|
|
|
* - Show "Press button (or M108) to resume"
|
|
|
|
*
|
|
|
|
* For Filament Change:
|
2018-01-22 10:37:40 +00:00
|
|
|
* - Show "Insert filament and press button to continue"
|
2018-11-18 04:21:44 +00:00
|
|
|
*
|
2018-01-22 10:37:40 +00:00
|
|
|
* - Wait for a click before returning
|
2018-11-18 04:21:44 +00:00
|
|
|
* - Heaters can time out and must reheat before continuing
|
2018-01-22 10:37:40 +00:00
|
|
|
*
|
|
|
|
* Used by M125 and M600
|
|
|
|
*/
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-11-18 04:21:44 +00:00
|
|
|
#if (HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI)) && ENABLED(EMERGENCY_PARSER)
|
2018-11-06 10:13:48 +00:00
|
|
|
#define _PMSG(L) L
|
|
|
|
#elif ENABLED(EMERGENCY_PARSER)
|
|
|
|
#define _PMSG(L) L##_M108
|
|
|
|
#else
|
|
|
|
#define _PMSG(L) L##_LCD
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void show_continue_prompt(const bool is_reload) {
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
lcd_pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING);
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
2018-01-04 11:06:34 +00:00
|
|
|
SERIAL_ECHO_START();
|
2018-11-06 10:13:48 +00:00
|
|
|
serialprintPGM(is_reload ? PSTR(_PMSG(MSG_FILAMENT_CHANGE_INSERT) "\n") : PSTR(_PMSG(MSG_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);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
#if HAS_BUZZER
|
|
|
|
filament_change_beep(max_beep_count, true);
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Start the heater idle timers
|
|
|
|
const millis_t nozzle_timeout = (millis_t)(PAUSE_PARK_NOZZLE_TIMEOUT) * 1000UL;
|
|
|
|
|
2019-03-07 08:09:39 +00:00
|
|
|
HOTEND_LOOP() thermalManager.hotend_idle[e].start(nozzle_timeout);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-09-17 06:06:22 +00: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
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
// Wait for filament insert by user and press button
|
|
|
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
|
|
|
wait_for_user = true; // LCD click or M108 will clear this
|
2019-02-12 21:55:47 +00:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Nozzle Parked"), PSTR("Continue"));
|
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
while (wait_for_user) {
|
|
|
|
#if HAS_BUZZER
|
|
|
|
filament_change_beep(max_beep_count);
|
|
|
|
#endif
|
|
|
|
|
2018-11-06 10:13:48 +00:00
|
|
|
// If the nozzle has timed out...
|
2017-09-06 11:28:31 +00:00
|
|
|
if (!nozzle_timed_out)
|
2019-03-07 08:09:39 +00:00
|
|
|
HOTEND_LOOP() nozzle_timed_out |= thermalManager.hotend_idle[e].timed_out;
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-11-06 10:13:48 +00:00
|
|
|
// 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
|
2017-09-06 11:28:31 +00:00
|
|
|
if (nozzle_timed_out) {
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
lcd_pause_show_message(PAUSE_MESSAGE_HEAT);
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
2018-11-29 22:58:58 +00:00
|
|
|
SERIAL_ECHO_MSG(_PMSG(MSG_FILAMENT_CHANGE_HEAT));
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2019-02-12 21:55:47 +00:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("HeaterTimeout"), PSTR("Reheat"));
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
// Wait for LCD click or M108
|
|
|
|
while (wait_for_user) idle(true);
|
|
|
|
|
2019-02-12 21:55:47 +00:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheating"));
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
// Re-enable the heaters if they timed out
|
|
|
|
HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e);
|
|
|
|
|
|
|
|
// Wait for the heaters to reach the target temperatures
|
|
|
|
ensure_safe_temperature();
|
|
|
|
|
2018-11-06 10:13:48 +00:00
|
|
|
// Show the prompt to continue
|
|
|
|
show_continue_prompt(is_reload);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
// Start the heater idle timers
|
|
|
|
const millis_t nozzle_timeout = (millis_t)(PAUSE_PARK_NOZZLE_TIMEOUT) * 1000UL;
|
|
|
|
|
2019-03-07 08:09:39 +00:00
|
|
|
HOTEND_LOOP() thermalManager.hotend_idle[e].start(nozzle_timeout);
|
2019-02-12 21:55:47 +00:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), PSTR("Continue"));
|
|
|
|
#endif
|
2018-11-06 10:13:48 +00:00
|
|
|
wait_for_user = true;
|
2017-09-06 11:28:31 +00:00
|
|
|
nozzle_timed_out = false;
|
|
|
|
|
|
|
|
#if HAS_BUZZER
|
|
|
|
filament_change_beep(max_beep_count, true);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
idle(true);
|
|
|
|
}
|
2018-09-17 06:06:22 +00:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
active_extruder = saved_ext;
|
|
|
|
extruder_duplication_enabled = saved_ext_dup_mode;
|
|
|
|
stepper.set_directions();
|
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
KEEPALIVE_STATE(IN_HANDLER);
|
|
|
|
}
|
|
|
|
|
2018-01-22 10:37:40 +00:00
|
|
|
/**
|
|
|
|
* Resume or Start print procedure
|
|
|
|
*
|
|
|
|
* - Abort if not paused
|
|
|
|
* - 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"
|
|
|
|
* - Re-prime the nozzle...
|
|
|
|
* - FWRETRACT: Recover/prime from the prior G10.
|
|
|
|
* - !FWRETRACT: Retract by resume_position[E], if negative.
|
|
|
|
* Not sure how this logic comes into use.
|
|
|
|
* - Move the nozzle back to resume_position
|
|
|
|
* - 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 06:06:22 +00: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) {
|
|
|
|
/*
|
2019-03-05 12:46:19 +00:00
|
|
|
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-11-29 01:28:31 +00:00
|
|
|
//*/
|
2018-09-17 06:06:22 +00:00
|
|
|
|
2017-12-30 10:03:41 +00:00
|
|
|
if (!did_pause_print) return;
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
// Re-enable the heaters if they timed out
|
2018-01-22 10:37:40 +00:00
|
|
|
bool nozzle_timed_out = false;
|
2017-09-06 11:28:31 +00:00
|
|
|
HOTEND_LOOP() {
|
2019-03-07 08:09:39 +00:00
|
|
|
nozzle_timed_out |= thermalManager.hotend_idle[e].timed_out;
|
2017-09-06 11:28:31 +00:00
|
|
|
thermalManager.reset_heater_idle_timer(e);
|
|
|
|
}
|
|
|
|
|
2018-09-17 06:06:22 +00:00
|
|
|
if (nozzle_timed_out || thermalManager.hotEnoughToExtrude(active_extruder)) // Load the new filament
|
2019-03-14 07:26:07 +00:00
|
|
|
load_filament(slow_load_length, fast_load_length, purge_length, max_beep_count, true, nozzle_timed_out, PAUSE_MODE_PAUSE_PRINT DXC_PASS);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
lcd_pause_show_message(PAUSE_MESSAGE_RESUME);
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
|
2018-01-04 05:18:27 +00:00
|
|
|
// Intelligent resuming
|
|
|
|
#if ENABLED(FWRETRACT)
|
|
|
|
// If retracted before goto pause
|
|
|
|
if (fwretract.retracted[active_extruder])
|
2018-10-10 14:45:20 +00:00
|
|
|
do_pause_e_move(-fwretract.settings.retract_length, fwretract.settings.retract_feedrate_mm_s);
|
2018-01-04 05:18:27 +00:00
|
|
|
#endif
|
2018-03-20 18:19:10 +00:00
|
|
|
|
2018-01-29 20:57:37 +00:00
|
|
|
// If resume_position is negative
|
|
|
|
if (resume_position[E_AXIS] < 0) do_pause_e_move(resume_position[E_AXIS], PAUSE_PARK_RETRACT_FEEDRATE);
|
2018-02-04 02:05:23 +00:00
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
// Move XY to starting position, then Z
|
2017-12-25 07:38:06 +00:00
|
|
|
do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], NOZZLE_PARK_XY_FEEDRATE);
|
2018-01-04 05:18:27 +00:00
|
|
|
|
2018-05-28 22:39:23 +00:00
|
|
|
// Move Z_AXIS to saved position
|
2017-12-25 07:38:06 +00:00
|
|
|
do_blocking_move_to_z(resume_position[Z_AXIS], NOZZLE_PARK_Z_FEEDRATE);
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2019-02-06 12:39:42 +00:00
|
|
|
#if ADVANCED_PAUSE_RESUME_PRIME != 0
|
|
|
|
do_pause_e_move(ADVANCED_PAUSE_RESUME_PRIME, ADVANCED_PAUSE_PURGE_FEEDRATE);
|
|
|
|
#endif
|
|
|
|
|
2018-01-04 05:18:27 +00:00
|
|
|
// Now all extrusion positions are resumed and ready to be confirmed
|
|
|
|
// Set extruder to saved position
|
2018-03-20 18:19:10 +00:00
|
|
|
planner.set_e_position_mm((destination[E_AXIS] = current_position[E_AXIS] = resume_position[E_AXIS]));
|
2018-01-04 05:18:27 +00:00
|
|
|
|
2018-10-30 21:34:45 +00:00
|
|
|
#if HAS_LCD_MENU
|
2019-03-14 07:26:07 +00:00
|
|
|
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
|
2019-01-28 04:43:13 +00:00
|
|
|
#ifdef ACTION_ON_RESUMED
|
|
|
|
host_action_resumed();
|
|
|
|
#elif defined(ACTION_ON_RESUME)
|
|
|
|
host_action_resume();
|
2017-12-25 07:36:42 +00:00
|
|
|
#endif
|
|
|
|
|
2017-12-30 10:03:41 +00:00
|
|
|
--did_pause_print;
|
|
|
|
|
2019-02-12 21:55:47 +00:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
host_prompt_open(PROMPT_INFO, PSTR("Resume"));
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
#if ENABLED(SDSUPPORT)
|
2017-12-30 10:03:41 +00:00
|
|
|
if (did_pause_print) {
|
2017-09-06 11:28:31 +00:00
|
|
|
card.startFileprint();
|
2017-12-30 10:03:41 +00:00
|
|
|
--did_pause_print;
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
#endif
|
2018-10-16 21:58:29 +00:00
|
|
|
|
2018-11-29 01:28:31 +00:00
|
|
|
// Resume the print job timer if it was running
|
|
|
|
if (print_job_timer.isPaused()) print_job_timer.start();
|
|
|
|
|
2019-04-26 07:32:01 +00:00
|
|
|
#if HAS_LCD_MENU
|
|
|
|
ui.return_to_status();
|
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
|
2018-01-04 11:06:34 +00:00
|
|
|
#endif // ADVANCED_PAUSE_FEATURE
|