From fc943d607100e9be5d2af362e819d337b6695994 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 29 Dec 2019 17:56:24 +0100 Subject: [PATCH] Future-proof runout detection in M600 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. --- Firmware/Marlin_main.cpp | 14 ++++++++++---- Firmware/fsensor.cpp | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index c3a3c3e527..9998b62d79 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -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]; @@ -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(); @@ -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')) { @@ -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; diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index f20f647d6d..67cebfe4e3 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -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)