Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
wavexx committed Mar 29, 2022
1 parent 1ae6494 commit 81c89b4
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
@@ -496,7 +496,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();
18 changes: 14 additions & 4 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
@@ -3720,6 +3720,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];
@@ -3742,8 +3743,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;

@@ -3756,7 +3760,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
@@ -11891,7 +11897,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);

@@ -11900,6 +11907,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();
@@ -11932,6 +11940,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();
@@ -11966,6 +11975,7 @@ void M600_wait_for_user(float HotendTempBckp) {

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

void M600_load_filament_movements()
2 changes: 1 addition & 1 deletion Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
@@ -5579,7 +5579,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;
8 changes: 4 additions & 4 deletions Firmware/ultralcd.h
Original file line number Diff line number Diff line change
@@ -190,12 +190,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();

0 comments on commit 81c89b4

Please sign in to comment.