Skip to content

Commit

Permalink
PLR: heat bed while waiting for user confirmation.
Browse files Browse the repository at this point in the history
  • Loading branch information
vovodroid committed Jan 16, 2024
1 parent 7455776 commit d7a52ea
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions Marlin/src/feature/powerloss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/feature/powerloss.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/gcode/feature/powerloss/M1000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d7a52ea

Please sign in to comment.