Skip to content

Commit

Permalink
Fix Pause Print message and behavior (#13394)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored Mar 14, 2019
1 parent f5bcc00 commit 9a515cb
Show file tree
Hide file tree
Showing 18 changed files with 174 additions and 154 deletions.
6 changes: 3 additions & 3 deletions Marlin/src/feature/fwretract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ void FWRetract::reset() {
settings.retract_length = RETRACT_LENGTH;
settings.retract_feedrate_mm_s = RETRACT_FEEDRATE;
settings.retract_zraise = RETRACT_ZRAISE;
settings.retract_recover_length = RETRACT_RECOVER_LENGTH;
settings.retract_recover_extra = RETRACT_RECOVER_LENGTH;
settings.retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE;
settings.swap_retract_length = RETRACT_LENGTH_SWAP;
settings.swap_retract_recover_length = RETRACT_RECOVER_LENGTH_SWAP;
settings.swap_retract_recover_extra = RETRACT_RECOVER_LENGTH_SWAP;
settings.swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
current_hop = 0.0;

Expand Down Expand Up @@ -175,7 +175,7 @@ void FWRetract::retract(const bool retracting
planner.synchronize(); // Wait for move to complete
}

const float extra_recover = swapping ? settings.swap_retract_recover_length : settings.retract_recover_length;
const float extra_recover = swapping ? settings.swap_retract_recover_extra : settings.retract_recover_extra;
if (extra_recover != 0.0) {
current_position[E_AXIS] -= extra_recover; // Adjust the current E position by the extra amount to recover
sync_plan_position_e(); // Sync the planner position so the extra amount is recovered
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/feature/fwretract.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
typedef struct {
float retract_length, // M207 S - G10 Retract length
retract_feedrate_mm_s, // M207 F - G10 Retract feedrate
retract_zraise, // M207 Z - G10 Retract hop size
retract_recover_length, // M208 S - G11 Recover length
retract_zraise, // M207 Z - G10 Retract hop size
retract_recover_extra, // M208 S - G11 Recover length
retract_recover_feedrate_mm_s, // M208 F - G11 Recover feedrate
swap_retract_length, // M207 W - G10 Swap Retract length
swap_retract_recover_length, // M208 W - G11 Swap Recover length
swap_retract_recover_extra, // M208 W - G11 Swap Recover length
swap_retract_recover_feedrate_mm_s; // M208 R - G11 Swap Recover feedrate
} fwretract_settings_t;

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/feature/host_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void host_action(const char * const pstr, const bool eol) {
case PROMPT_FILAMENT_RUNOUT:
msg = PSTR("FILAMENT_RUNOUT");
if (response == 0) {
advanced_pause_menu_response = ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE;
pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
host_action_prompt_end(); // Close current prompt
host_action_prompt_begin(PSTR("Paused"));
host_action_prompt_button(PSTR("Purge More"));
Expand All @@ -133,7 +133,7 @@ void host_action(const char * const pstr, const bool eol) {
runout.reset();
}
#endif
advanced_pause_menu_response = ADVANCED_PAUSE_RESPONSE_RESUME_PRINT;
pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT;
}
break;
case PROMPT_USER_CONTINUE:
Expand Down
45 changes: 24 additions & 21 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@

static float resume_position[XYZE];

AdvancedPauseMenuResponse advanced_pause_menu_response;
PauseMode pause_mode = PAUSE_MODE_PAUSE_PRINT;

PauseMenuResponse pause_menu_response;

fil_change_settings_t fc_settings[EXTRUDERS];

Expand All @@ -68,6 +70,7 @@ fil_change_settings_t fc_settings[EXTRUDERS];

#if HAS_BUZZER
static void filament_change_beep(const int8_t max_beep_count, const bool init=false) {
if (pause_mode == PAUSE_MODE_PAUSE_PRINT) return;
static millis_t next_buzz = 0;
static int8_t runout_beep = 0;

Expand All @@ -93,7 +96,7 @@ fil_change_settings_t fc_settings[EXTRUDERS];
*
* Returns 'true' if heating was completed, 'false' for abort
*/
static bool ensure_safe_temperature(const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_SAME) {
static bool ensure_safe_temperature(const PauseMode mode=PAUSE_MODE_SAME) {

#if ENABLED(PREVENT_COLD_EXTRUSION)
if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder)) {
Expand All @@ -103,7 +106,7 @@ static bool ensure_safe_temperature(const AdvancedPauseMode mode=ADVANCED_PAUSE_
#endif

#if HAS_LCD_MENU
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_HEATING, mode);
lcd_pause_show_message(PAUSE_MESSAGE_HEATING, mode);
#else
UNUSED(mode);
#endif
Expand Down Expand Up @@ -134,7 +137,7 @@ void do_pause_e_move(const float &length, const float &fr_mm_s) {
*/
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 AdvancedPauseMode mode/*=ADVANCED_PAUSE_MODE_PAUSE_PRINT*/
const PauseMode mode/*=PAUSE_MODE_PAUSE_PRINT*/
DXC_ARGS
) {
#if !HAS_LCD_MENU
Expand All @@ -143,14 +146,14 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l

if (!ensure_safe_temperature(mode)) {
#if HAS_LCD_MENU
if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS, mode);
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_STATUS, mode);
#endif
return false;
}

if (pause_for_user) {
#if HAS_LCD_MENU
if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INSERT, mode);
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_INSERT, mode);
#endif
SERIAL_ECHO_MSG(MSG_FILAMENT_CHANGE_INSERT);

Expand Down Expand Up @@ -186,7 +189,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
}

#if HAS_LCD_MENU
if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_LOAD, mode);
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_LOAD, mode);
#endif

#if ENABLED(DUAL_X_CARRIAGE)
Expand Down Expand Up @@ -222,7 +225,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
#if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)

#if HAS_LCD_MENU
if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_PURGE);
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
#endif

wait_for_user = true;
Expand All @@ -239,7 +242,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
if (purge_length > 0) {
// "Wait for filament purge"
#if HAS_LCD_MENU
if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_PURGE);
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
#endif

// Extrude filament to get into hotend
Expand Down Expand Up @@ -269,16 +272,16 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
if (show_lcd) {
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = false;
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_OPTION);
while (advanced_pause_menu_response == ADVANCED_PAUSE_RESPONSE_WAIT_FOR) idle(true);
lcd_pause_show_message(PAUSE_MESSAGE_OPTION);
while (pause_menu_response == PAUSE_RESPONSE_WAIT_FOR) idle(true);
KEEPALIVE_STATE(IN_HANDLER);
}
#endif

// Keep looping if "Purge More" was selected
} while (false
#if HAS_LCD_MENU
|| (show_lcd && advanced_pause_menu_response == ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE)
|| (show_lcd && pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE)
#endif
);

Expand All @@ -298,22 +301,22 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
* Returns 'true' if unload was completed, 'false' for abort
*/
bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
const AdvancedPauseMode mode/*=ADVANCED_PAUSE_MODE_PAUSE_PRINT*/
const PauseMode mode/*=PAUSE_MODE_PAUSE_PRINT*/
) {
#if !HAS_LCD_MENU
UNUSED(show_lcd);
#endif

if (!ensure_safe_temperature(mode)) {
#if HAS_LCD_MENU
if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
#endif

return false;
}

#if HAS_LCD_MENU
if (show_lcd) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_UNLOAD, mode);
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_UNLOAD, mode);
#endif

// Retract filament
Expand Down Expand Up @@ -387,7 +390,7 @@ bool pause_print(const float &retract, const point_t &park_point, const float &u

#if HAS_LCD_MENU
if (show_lcd) { // Show status screen
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
LCD_MESSAGEPGM(MSG_M600_TOO_COLD);
}
#endif
Expand Down Expand Up @@ -464,7 +467,7 @@ bool pause_print(const float &retract, const point_t &park_point, const float &u

void show_continue_prompt(const bool is_reload) {
#if HAS_LCD_MENU
lcd_advanced_pause_show_message(is_reload ? ADVANCED_PAUSE_MESSAGE_INSERT : ADVANCED_PAUSE_MESSAGE_WAITING);
lcd_pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING);
#endif
SERIAL_ECHO_START();
serialprintPGM(is_reload ? PSTR(_PMSG(MSG_FILAMENT_CHANGE_INSERT) "\n") : PSTR(_PMSG(MSG_FILAMENT_CHANGE_WAIT) "\n"));
Expand Down Expand Up @@ -510,7 +513,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
// re-heat the nozzle, re-show the continue prompt, restart idle timers, start over
if (nozzle_timed_out) {
#if HAS_LCD_MENU
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_HEAT);
lcd_pause_show_message(PAUSE_MESSAGE_HEAT);
#endif
SERIAL_ECHO_MSG(_PMSG(MSG_FILAMENT_CHANGE_HEAT));

Expand Down Expand Up @@ -597,10 +600,10 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
}

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, ADVANCED_PAUSE_MODE_PAUSE_PRINT DXC_PASS);
load_filament(slow_load_length, fast_load_length, purge_length, max_beep_count, true, nozzle_timed_out, PAUSE_MODE_PAUSE_PRINT DXC_PASS);

#if HAS_LCD_MENU
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_RESUME);
lcd_pause_show_message(PAUSE_MESSAGE_RESUME);
#endif

// Intelligent resuming
Expand Down Expand Up @@ -628,7 +631,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
planner.set_e_position_mm((destination[E_AXIS] = current_position[E_AXIS] = resume_position[E_AXIS]));

#if HAS_LCD_MENU
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
#endif

#ifdef ACTION_ON_RESUMED
Expand Down
50 changes: 26 additions & 24 deletions Marlin/src/feature/pause.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,36 @@ typedef struct {

#include "../libs/nozzle.h"

enum AdvancedPauseMode : char {
ADVANCED_PAUSE_MODE_SAME,
ADVANCED_PAUSE_MODE_PAUSE_PRINT,
ADVANCED_PAUSE_MODE_LOAD_FILAMENT,
ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT
enum PauseMode : char {
PAUSE_MODE_SAME,
PAUSE_MODE_PAUSE_PRINT,
PAUSE_MODE_LOAD_FILAMENT,
PAUSE_MODE_UNLOAD_FILAMENT
};

enum AdvancedPauseMessage : char {
ADVANCED_PAUSE_MESSAGE_INIT,
ADVANCED_PAUSE_MESSAGE_WAITING,
ADVANCED_PAUSE_MESSAGE_UNLOAD,
ADVANCED_PAUSE_MESSAGE_INSERT,
ADVANCED_PAUSE_MESSAGE_LOAD,
ADVANCED_PAUSE_MESSAGE_PURGE,
ADVANCED_PAUSE_MESSAGE_OPTION,
ADVANCED_PAUSE_MESSAGE_RESUME,
ADVANCED_PAUSE_MESSAGE_STATUS,
ADVANCED_PAUSE_MESSAGE_HEAT,
ADVANCED_PAUSE_MESSAGE_HEATING
enum PauseMessage : char {
PAUSE_MESSAGE_PAUSING,
PAUSE_MESSAGE_CHANGING,
PAUSE_MESSAGE_WAITING,
PAUSE_MESSAGE_UNLOAD,
PAUSE_MESSAGE_INSERT,
PAUSE_MESSAGE_LOAD,
PAUSE_MESSAGE_PURGE,
PAUSE_MESSAGE_OPTION,
PAUSE_MESSAGE_RESUME,
PAUSE_MESSAGE_STATUS,
PAUSE_MESSAGE_HEAT,
PAUSE_MESSAGE_HEATING
};

enum AdvancedPauseMenuResponse : char {
ADVANCED_PAUSE_RESPONSE_WAIT_FOR,
ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE,
ADVANCED_PAUSE_RESPONSE_RESUME_PRINT
enum PauseMenuResponse : char {
PAUSE_RESPONSE_WAIT_FOR,
PAUSE_RESPONSE_EXTRUDE_MORE,
PAUSE_RESPONSE_RESUME_PRINT
};

extern AdvancedPauseMenuResponse advanced_pause_menu_response;
extern PauseMode pause_mode;
extern PauseMenuResponse pause_menu_response;

extern fil_change_settings_t fc_settings[EXTRUDERS];

Expand All @@ -88,8 +90,8 @@ void wait_for_confirmation(const bool is_reload=false, const int8_t max_beep_cou
void resume_print(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=ADVANCED_PAUSE_PURGE_LENGTH, const int8_t max_beep_count=0 DXC_PARAMS);

bool load_filament(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=0, const int8_t max_beep_count=0, const bool show_lcd=false,
const bool pause_for_user=false, const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT DXC_PARAMS);
const bool pause_for_user=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT DXC_PARAMS);

bool unload_filament(const float &unload_length, const bool show_lcd=false, const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT);
bool unload_filament(const float &unload_length, const bool show_lcd=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT);

#endif // ADVANCED_PAUSE_FEATURE
8 changes: 4 additions & 4 deletions Marlin/src/gcode/feature/fwretract/M207-M209.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ void GcodeSuite::M207() {
/**
* M208: Set firmware un-retraction values
*
* S[+units] retract_recover_length (in addition to M207 S*)
* W[+units] swap_retract_recover_length (multi-extruder)
* S[+units] retract_recover_extra (in addition to M207 S*)
* W[+units] swap_retract_recover_extra (multi-extruder)
* F[units/min] retract_recover_feedrate_mm_s
* R[units/min] swap_retract_recover_feedrate_mm_s
*/
void GcodeSuite::M208() {
if (parser.seen('S')) fwretract.settings.retract_recover_length = parser.value_axis_units(E_AXIS);
if (parser.seen('S')) fwretract.settings.retract_recover_extra = parser.value_axis_units(E_AXIS);
if (parser.seen('F')) fwretract.settings.retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
if (parser.seen('R')) fwretract.settings.swap_retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
if (parser.seen('W')) fwretract.settings.swap_retract_recover_length = parser.value_axis_units(E_AXIS);
if (parser.seen('W')) fwretract.settings.swap_retract_recover_extra = parser.value_axis_units(E_AXIS);
}

#if ENABLED(FWRETRACT_AUTORETRACT)
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/gcode/feature/pause/M125.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#endif

/**
* M125: Store current position and move to filament change position.
* M125: Store current position and move to parking position.
* Called on pause (by M25) to prevent material leaking onto the
* object. On resume (M24) the head will be moved back and the
* print will resume.
Expand Down Expand Up @@ -79,14 +79,14 @@ void GcodeSuite::M125() {
#endif

#if HAS_LCD_MENU
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT, ADVANCED_PAUSE_MODE_PAUSE_PRINT);
lcd_pause_show_message(PAUSE_MESSAGE_PAUSING, PAUSE_MODE_PAUSE_PRINT);
const bool show_lcd = parser.seenval('P');
#else
constexpr bool show_lcd = false;
#endif

if (pause_print(retract, park_point, 0, show_lcd)) {
if (!sd_printing || show_lcd ) {
if (!sd_printing || show_lcd) {
wait_for_confirmation(false, 0);
resume_print(0, 0, PAUSE_PARK_RETRACT_LENGTH, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/feature/pause/M600.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void GcodeSuite::M600() {

// Show initial "wait for start" message
#if HAS_LCD_MENU && DISABLED(MMU2_MENUS)
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT, ADVANCED_PAUSE_MODE_PAUSE_PRINT, target_extruder);
lcd_pause_show_message(PAUSE_MESSAGE_CHANGING, PAUSE_MODE_PAUSE_PRINT, target_extruder);
#endif

#if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
Expand Down
Loading

0 comments on commit 9a515cb

Please sign in to comment.