From f0d14b83bc9aed3870ed28476fd9a54458fc06e8 Mon Sep 17 00:00:00 2001 From: Msq001 <760675063@qq.com> Date: Sat, 30 Mar 2019 02:40:42 +0800 Subject: [PATCH] Save/restore Relative modes in Power-Loss Recovery (#13501) --- Marlin/src/feature/power_loss_recovery.cpp | 8 ++++++++ Marlin/src/feature/power_loss_recovery.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/Marlin/src/feature/power_loss_recovery.cpp b/Marlin/src/feature/power_loss_recovery.cpp index ba434116d..a30dffa45 100644 --- a/Marlin/src/feature/power_loss_recovery.cpp +++ b/Marlin/src/feature/power_loss_recovery.cpp @@ -185,6 +185,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*= info.retract_hop = fwretract.current_hop; #endif + //relative mode + info.relative_mode = relative_mode; + info.relative_modes_e = gcode.axis_relative_modes[E_AXIS]; + // Commands in the queue info.commands_in_queue = save_queue ? commands_in_queue : 0; info.cmd_queue_index_r = cmd_queue_index_r; @@ -339,6 +343,10 @@ void PrintJobRecovery::resume() { sprintf_P(cmd, PSTR("G1 F%d"), info.feedrate); gcode.process_subcommands_now(cmd); + //relative mode + if (info.relative_mode) relative_mode = true; + if (info.relative_modes_e) gcode.axis_relative_modes[E_AXIS] = true; + // Process commands from the old pending queue uint8_t c = info.commands_in_queue, r = info.cmd_queue_index_r; for (; c--; r = (r + 1) % BUFSIZE) diff --git a/Marlin/src/feature/power_loss_recovery.h b/Marlin/src/feature/power_loss_recovery.h index dd330652e..c2f868771 100644 --- a/Marlin/src/feature/power_loss_recovery.h +++ b/Marlin/src/feature/power_loss_recovery.h @@ -76,6 +76,9 @@ typedef struct { #endif #endif + // Relative mode + bool relative_mode, relative_modes_e; + // Command queue uint8_t commands_in_queue, cmd_queue_index_r; char command_queue[BUFSIZE][MAX_CMD_SIZE];