Skip to content

Commit

Permalink
Perform the extra purge on M600 if a cooldown happened
Browse files Browse the repository at this point in the history
Not doing the extra purge is sensible if the swap is performed fast
enough, but if an extruder cooldown happened while waiting for the user
in M600 this is no longer true and the tip might have softened.

Do an extra purge in such cases.

Add some comments and rename UnloadType::User into ::Purge to make the
distinction between the various modes clear.
  • Loading branch information
wavexx committed Jun 29, 2021
1 parent c2acb94 commit 973aafb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Firmware/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ void proc_commands();

void M600_load_filament();
void M600_load_filament_movements();
void M600_wait_for_user(float HotendTempBckp);
bool M600_wait_for_user(float HotendTempBckp);
void M600_check_state(float nozzle_temp);
void load_filament_final_feed();
void marlin_wait_for_click();
Expand Down
18 changes: 14 additions & 4 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3749,6 +3749,7 @@ static void gcode_M600(bool automatic, bool runout, float x_position, float y_po
int feedmultiplyBckp = feedmultiply;
float HotendTempBckp = degTargetHotend(active_extruder);
int fanSpeedBckp = fanSpeed;
bool cooldown = false;

lastpos[X_AXIS] = current_position[X_AXIS];
lastpos[Y_AXIS] = current_position[Y_AXIS];
Expand All @@ -3771,8 +3772,11 @@ static void gcode_M600(bool automatic, bool runout, float x_position, float y_po
plan_buffer_line_curposXYZE(FILAMENTCHANGE_XYFEED);
st_synchronize();

//Beep, manage nozzle heater and wait for user to start unload filament
if(!mmu_enabled) M600_wait_for_user(HotendTempBckp);
if(!mmu_enabled)
{
//Beep, manage nozzle heater and wait for user to start unload filament
cooldown = M600_wait_for_user(HotendTempBckp);
}

lcd_change_fil_state = 0;

Expand All @@ -3785,7 +3789,9 @@ static void gcode_M600(bool automatic, bool runout, float x_position, float y_po
else
{
// unload filament for single material (used also in M702)
unload_filament(runout? UnloadType::Runout: UnloadType::Swap);
unload_filament(runout? UnloadType::Runout:
cooldown? UnloadType::Purge:
UnloadType::Swap);
}

//finish moves
Expand Down Expand Up @@ -11984,7 +11990,8 @@ void M600_check_state(float nozzle_temp)
//! If times out, active extruder temperature is set to 0.
//!
//! @param HotendTempBckp Temperature to be restored for active extruder, after user resolves MMU problem.
void M600_wait_for_user(float HotendTempBckp) {
//! @return True if the wait involved a hotend cooldown due to timeout.
bool M600_wait_for_user(float HotendTempBckp) {

KEEPALIVE_STATE(PAUSED_FOR_USER);

Expand All @@ -11993,6 +12000,7 @@ void M600_wait_for_user(float HotendTempBckp) {
uint8_t wait_for_user_state = 0;
lcd_display_message_fullscreen_P(_T(MSG_PRESS_TO_UNLOAD));
bool bFirst=true;
bool bCooldown=false;

while (!(wait_for_user_state == 0 && lcd_clicked())){
manage_heater();
Expand Down Expand Up @@ -12025,6 +12033,7 @@ void M600_wait_for_user(float HotendTempBckp) {
lcd_display_message_fullscreen_P(_i("Press the knob to preheat nozzle and continue."));////MSG_PRESS_TO_PREHEAT c=20 r=4
wait_for_user_state = 1;
setAllTargetHotends(0);
bCooldown = true;
st_synchronize();
disable_e0();
disable_e1();
Expand Down Expand Up @@ -12059,6 +12068,7 @@ void M600_wait_for_user(float HotendTempBckp) {

}
WRITE(BEEPER, LOW);
return bCooldown;
}

void M600_load_filament_movements()
Expand Down
2 changes: 1 addition & 1 deletion Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6288,7 +6288,7 @@ void unload_filament(UnloadType unload)
lcd_setstatuspgm(_T(MSG_UNLOADING_FILAMENT));

raise_z_above(unload == UnloadType::Swap? MIN_Z_FOR_SWAP: MIN_Z_FOR_UNLOAD);
if (unload == UnloadType::User)
if (unload == UnloadType::Purge)
{
// extrude slowly
current_position[E_AXIS] += FILAMENTCHANGE_UNLOADFEED;
Expand Down
8 changes: 4 additions & 4 deletions Firmware/ultralcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ void lcd_generic_preheat_menu();

enum class UnloadType : uint8_t
{
User, // user-triggered unload
Swap, // part of a M600 sequence
Runout, // triggered by runout
Purge, // user-triggered unload, perform an extra purge before unload
Swap, // part of an M600 sequence (no extra purge necessary)
Runout, // triggered by runout (extra purge not possible)
};

void unload_filament(UnloadType unload=UnloadType::User);
void unload_filament(UnloadType unload=UnloadType::Purge);


void lcd_printer_connected();
Expand Down

0 comments on commit 973aafb

Please sign in to comment.