From a08165b5fe45ff37468ccdec5fe179bbe528b23d Mon Sep 17 00:00:00 2001 From: vovodroid Date: Sun, 6 Jul 2025 20:55:44 +0300 Subject: [PATCH] PLR: custom gcodes --- Marlin/Configuration_adv.h | 3 +++ Marlin/src/feature/powerloss.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 1cd89a9714..9576bf70bb 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1806,6 +1806,7 @@ //#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power-loss #if ENABLED(BACKUP_POWER_SUPPLY) //#define POWER_LOSS_RETRACT_LEN 10 // (mm) Length of filament to retract on fail + //#define EVENT_GCODE_BEFORE_KILL "G27P4\nM400" // Executed as last thing before kill. E.g. park bozzle to prevent blob on print #endif // Enable if Z homing is needed for proper recovery. 99.9% of the time this should be disabled! @@ -1813,6 +1814,8 @@ #if ENABLED(POWER_LOSS_RECOVER_ZHOME) //#define POWER_LOSS_ZHOME_POS { 0, 0 } // Safe XY position to home Z while avoiding objects on the bed #endif + + //#define EVENT_GCODE_ON_RESUME "M600" //G-code run just before print resumed. E.g. "change filament" to ensure proper filament load. #endif /** diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index d9af336d3a..80aa0499b5 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -339,6 +339,9 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW quickstop_stepper(); // With backup power a retract and raise can be done now retract_and_lift(zraise); + #ifdef EVENT_GCODE_BEFORE_KILL + PROCESS_SUBCOMMANDS_NOW(F(EVENT_GCODE_BEFORE_KILL)); + #endif #endif if (TERN0(DEBUG_POWER_LOSS_RECOVERY, simulated)) { @@ -602,6 +605,10 @@ void PrintJobRecovery::resume() { if (rts.print_state) rts.refreshTime(); rts.start_print_flag = false; #endif + + #ifdef EVENT_GCODE_ON_RESUME + PROCESS_SUBCOMMANDS_NOW(F(EVENT_GCODE_ON_RESUME)); + #endif } #if ENABLED(DEBUG_POWER_LOSS_RECOVERY)