diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 1d7c1a7277f34..3715c633c677c 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1744,6 +1744,12 @@ //#define POWER_LOSS_RECOVERY #if ENABLED(POWER_LOSS_RECOVERY) #define PLR_ENABLED_DEFAULT false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500) + #if TEMP_SENSOR_BED + //#define PLR_HEAT_BED_ON_REBOOT // Turn on bed heating immediatly after reboot to mitigate object detaching/warping. + #if ENABLED(PLR_HEAT_BED_ON_REBOOT) + #define PLR_HEAT_BED_RAISE 0 //(°C) Raise bed temperature by this value improve adhesion after restart (limited by maximum allowed temerature). + #endif + #endif //#define PLR_BED_THRESHOLD BED_MAXTEMP // (°C) Skip user confirmation at or above this bed temperature (0 to disable) //#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss //#define POWER_LOSS_ZRAISE 2 // (mm) Z axis raise on resume (on power loss with UPS) diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 7c90bb684a03b..62e6e9c8cdb69 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -138,6 +138,14 @@ bool PrintJobRecovery::check() { return success; } +/** + * Cancel recovery + */ +void PrintJobRecovery::cancel() { + TERN_(PLR_HEAT_BED_ON_REBOOT, set_bed_temp(false)); + purge(); +} + /** * Delete the recovery file and clear the recovery data */ @@ -354,6 +362,14 @@ void PrintJobRecovery::write() { if (!file.close()) DEBUG_ECHOLNPGM("Power-loss file close failed."); } +#if ENABLED(PLR_HEAT_BED_ON_REBOOT) +void PrintJobRecovery::set_bed_temp(bool turn_on) { + // Set the bed temperature + const celsius_t bt = turn_on ? info.target_temperature_bed + PLR_HEAT_BED_RAISE: 0; + PROCESS_SUBCOMMANDS_NOW(TS(F("M190S"), bt)); +} +#endif + /** * Resume the saved print job */ diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 1fdc42db26ad0..0d73fafa96c15 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -184,10 +184,13 @@ class PrintJobRecovery { static void close() { file.close(); } static bool check(); + #if ENABLED(PLR_HEAT_BED_ON_REBOOT) + static void set_bed_temp(bool turn_on); + #endif static void resume(); static void purge(); - static void cancel() { purge(); } + static void cancel(); static void load(); static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false); diff --git a/Marlin/src/gcode/feature/powerloss/M1000.cpp b/Marlin/src/gcode/feature/powerloss/M1000.cpp index c735b72cedbb3..a476e7cf2e5d0 100644 --- a/Marlin/src/gcode/feature/powerloss/M1000.cpp +++ b/Marlin/src/gcode/feature/powerloss/M1000.cpp @@ -74,6 +74,7 @@ void GcodeSuite::M1000() { const bool force_resume = TERN0(HAS_PLR_BED_THRESHOLD, recovery.bed_temp_threshold && (thermalManager.degBed() >= recovery.bed_temp_threshold)); if (!force_resume && parser.seen_test('S')) { + TERN_(PLR_HEAT_BED_ON_REBOOT, recovery.set_bed_temp(true)); #if HAS_MARLINUI_MENU ui.goto_screen(menu_job_recovery); #elif HAS_DWIN_E3V2_BASIC