Skip to content

Commit

Permalink
Future-proof runout detection in M600
Browse files Browse the repository at this point in the history
No longer use saved_printing, since in newer versions M600 no longer
executes within a paused state. Introduce a new internal code 'R'
to do the same.
  • Loading branch information
wavexx committed Dec 29, 2019
1 parent 160410e commit fc943d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3054,7 +3054,7 @@ static T gcode_M600_filament_change_z_shift()
#endif
}

static void gcode_M600(bool automatic, float x_position, float y_position, float z_shift, float e_shift, float /*e_shift_late*/)
static void gcode_M600(bool automatic, bool runout, float x_position, float y_position, float z_shift, float e_shift, float /*e_shift_late*/)
{
st_synchronize();
float lastpos[4];
Expand Down Expand Up @@ -3097,7 +3097,7 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float

// Unload filament
if (mmu_enabled) extr_unload(); //unload just current filament for multimaterial printers (used also in M702)
else unload_filament(saved_printing); //unload filament for single material (used also in M702)
else unload_filament(runout); //unload filament for single material (used also in M702)
//finish moves
st_synchronize();

Expand Down Expand Up @@ -7167,7 +7167,8 @@ SERIAL_PROTOCOLPGM("\n\n");
float e_shift_init = 0;
float e_shift_late = 0;
bool automatic = false;

bool runout = false;

//Retract extruder
if(code_seen('E'))
{
Expand Down Expand Up @@ -7225,8 +7226,13 @@ SERIAL_PROTOCOLPGM("\n\n");

if (mmu_enabled && code_seen("AUTO"))
automatic = true;
if (code_seen('R'))
{
// Code 'R' is supported internally to indicate filament change due to a runout condition
runout = true;
}

gcode_M600(automatic, x_position, y_position, z_shift, e_shift_init, e_shift_late);
gcode_M600(automatic, runout, x_position, y_position, z_shift, e_shift_init, e_shift_late);

}
break;
Expand Down
2 changes: 1 addition & 1 deletion Firmware/fsensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ void fsensor_enque_M600(){
eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1);
enquecommand_front_P(PSTR("PRUSA fsensor_recover"));
fsensor_m600_enqueued = true;
enquecommand_front_P((PSTR("M600")));
enquecommand_front_P((PSTR("M600 R")));
}

//! @brief filament sensor update (perform M600 on filament runout)
Expand Down

0 comments on commit fc943d6

Please sign in to comment.