Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PFW-1097 M600: Fix filament change behavior when print is paused #4408

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3414,7 +3414,7 @@ static void gcode_M600(const bool automatic, const float x_position, const float

//First backup current position and settings
int feedmultiplyBckp = feedmultiply;
float HotendTempBckp = degTargetHotend(active_extruder);
float HotendTempBckp = saved_extruder_temperature;
uint8_t fanSpeedBckp = fanSpeed;

memcpy(lastpos, current_position, sizeof(lastpos));
Expand All @@ -3423,9 +3423,16 @@ static void gcode_M600(const bool automatic, const float x_position, const float
fanSpeed = 0;

// Retract E
current_position[E_AXIS] += e_shift;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_RFEED);
st_synchronize();
if (!isPrintPaused)
{
current_position[E_AXIS] += e_shift;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_RFEED);
st_synchronize();
} else {
// Print is paused and the extruder may be cold
// Filament change can be issued via the Tune menu
restore_extruder_temperature_from_ram();
}

// Raise the Z axis
raise_z(z_shift);
Expand Down Expand Up @@ -3479,8 +3486,22 @@ static void gcode_M600(const bool automatic, const float x_position, const float

// Feed a little of filament to stabilize pressure
if (!automatic) {
current_position[E_AXIS] += FILAMENTCHANGE_RECFEED;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EXFEED);
if (isPrintPaused)
{
// Return to retracted state during a pause
// @todo is retraction really needed? E-position is reverted a few lines below
current_position[E_AXIS] -= default_retraction;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_RFEED);
gudnimg marked this conversation as resolved.
Show resolved Hide resolved

// Cooldown the extruder again
setTargetHotend(0);
}
else
{
// Feed a little of filament to stabilize pressure
current_position[E_AXIS] += FILAMENTCHANGE_RECFEED;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EXFEED);
}
}

// Move XY back
Expand All @@ -3501,8 +3522,8 @@ static void gcode_M600(const bool automatic, const float x_position, const float
feedmultiply = feedmultiplyBckp;
enquecommandf_P(MSG_M220, feedmultiplyBckp);
}

lcd_setstatuspgm(MSG_WELCOME);
if (isPrintPaused) lcd_setstatuspgm(_T(MSG_PRINT_PAUSED));
else lcd_setstatuspgm(MSG_WELCOME);
custom_message_type = CustomMsg::Status;
}

Expand Down
1 change: 1 addition & 0 deletions Firmware/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const char MSG_NO[] PROGMEM_I1 = ISTR("No"); ////MSG_NO c=4
const char MSG_NOZZLE[] PROGMEM_I1 = ISTR("Nozzle"); ////MSG_NOZZLE c=10
const char MSG_PAPER[] PROGMEM_I1 = ISTR("Place a sheet of paper under the nozzle during the calibration of first 4 points. If the nozzle catches the paper, power off the printer immediately."); ////MSG_PAPER c=20 r=8
const char MSG_PAUSE_PRINT[] PROGMEM_I1 = ISTR("Pause print");////MSG_PAUSE_PRINT c=18
const char MSG_PRINT_PAUSED[] PROGMEM_I1 = ISTR("Print paused");////MSG_PAUSE_PRINT c=20
const char MSG_PLACE_STEEL_SHEET[] PROGMEM_I1 = ISTR("Please place steel sheet on heatbed."); ////MSG_PLACE_STEEL_SHEET c=20 r=4
const char MSG_PLEASE_WAIT[] PROGMEM_I1 = ISTR("Please wait"); ////MSG_PLEASE_WAIT c=20
const char MSG_POWER_FAILURES[] PROGMEM_I1 = ISTR("Power failures"); ////MSG_POWER_FAILURES c=15
Expand Down
1 change: 1 addition & 0 deletions Firmware/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ extern const char MSG_NO[];
extern const char MSG_NOZZLE[];
extern const char MSG_PAPER[];
extern const char MSG_PAUSE_PRINT[];
extern const char MSG_PRINT_PAUSED[];
extern const char MSG_PLACE_STEEL_SHEET[];
extern const char MSG_PLEASE_WAIT[];
extern const char MSG_POWER_FAILURES[];
Expand Down
2 changes: 1 addition & 1 deletion Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ void lcd_commands()
if (custom_message_type != CustomMsg::M117)
{
custom_message_type = CustomMsg::Status;
lcd_setstatuspgm(_i("Print paused"));////MSG_PRINT_PAUSED c=20
lcd_setstatuspgm(_T(MSG_PRINT_PAUSED));
}
lcd_commands_type = LcdCommands::Idle;
lcd_commands_step = 0;
Expand Down
Loading