Skip to content

Commit ab34971

Browse files
🐛 Fix PLR pos/sdpos (MarlinFirmware#26365)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent 46f370a commit ab34971

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

Marlin/src/feature/powerloss.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ void PrintJobRecovery::write() {
358358
* Resume the saved print job
359359
*/
360360
void PrintJobRecovery::resume() {
361-
const uint32_t resume_sdpos = info.sdpos; // Get here before the stepper ISR overwrites it
361+
// Get these fields before any moves because stepper.cpp overwrites them
362+
const xyze_pos_t resume_pos = info.current_position;
363+
const uint32_t resume_sdpos = info.sdpos;
362364

363365
// Apply the dry-run flag if enabled
364366
if (info.flag.dryrun) marlin_debug_flags |= MARLIN_DEBUG_DRYRUN;
@@ -400,7 +402,7 @@ void PrintJobRecovery::resume() {
400402
#endif
401403

402404
// Interpret the saved Z according to flags
403-
const float z_print = info.current_position.z,
405+
const float z_print = resume_pos.z,
404406
z_raised = z_print + info.zraise;
405407

406408
//
@@ -540,7 +542,7 @@ void PrintJobRecovery::resume() {
540542

541543
// Move back over to the saved XY
542544
PROCESS_SUBCOMMANDS_NOW(TS(
543-
F("G1F3000X"), p_float_t(info.current_position.x, 3), 'Y', p_float_t(info.current_position.y, 3)
545+
F("G1F3000X"), p_float_t(resume_pos.x, 3), 'Y', p_float_t(resume_pos.y, 3)
544546
));
545547

546548
// Move back down to the saved Z for printing
@@ -550,7 +552,7 @@ void PrintJobRecovery::resume() {
550552
PROCESS_SUBCOMMANDS_NOW(TS(F("G1F"), info.feedrate));
551553

552554
// Restore E position with G92.9
553-
PROCESS_SUBCOMMANDS_NOW(TS(F("G92.9E"), p_float_t(info.current_position.e, 3)));
555+
PROCESS_SUBCOMMANDS_NOW(TS(F("G92.9E"), p_float_t(resume_pos.e, 3)));
554556

555557
TERN_(GCODE_REPEAT_MARKERS, repeat = info.stored_repeat);
556558
TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset);

Marlin/src/gcode/feature/powerloss/M1000.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ inline void plr_error(FSTR_P const prefix) {
6565
* M1000: Resume from power-loss (undocumented)
6666
* - With 'S' go to the Resume/Cancel menu
6767
* ...unless the bed temperature is already above a configured minimum temperature.
68+
* - With 'C' execute a cancel selection
6869
* - With no parameters, run recovery commands
6970
*/
7071
void GcodeSuite::M1000() {

Marlin/src/gcode/queue.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ PGM_P GCodeQueue::injected_commands_P; // = nullptr
9191
*/
9292
char GCodeQueue::injected_commands[64]; // = { 0 }
9393

94+
/**
95+
* Commit the accumulated G-code command to the ring buffer,
96+
* also setting its origin info.
97+
*/
9498
void GCodeQueue::RingBuffer::commit_command(const bool skip_ok
9599
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind/*=-1*/)
96100
) {

Marlin/src/gcode/queue.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ class GCodeQueue {
8080
void advance_pos(uint8_t &p, const int inc) { if (++p >= BUFSIZE) p = 0; length += inc; }
8181

8282
void commit_command(const bool skip_ok
83-
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind = serial_index_t())
83+
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind=serial_index_t())
8484
);
8585

8686
bool enqueue(const char *cmd, const bool skip_ok=true
87-
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind = serial_index_t())
87+
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind=serial_index_t())
8888
);
8989

9090
void ok_to_send();

Marlin/src/lcd/extui/ia_creality/ia_creality_extui.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ void onSettingsLoaded(const bool success) {
342342
// Called when power-loss state is detected
343343
}
344344
void onPowerLossResume() {
345-
startprogress = 254;
346-
show_status = true;
347-
tpShowStatus = false;
348-
no_reentry = false;
345+
startprogress = 254;
346+
show_status = true;
347+
tpShowStatus = false;
348+
no_reentry = false;
349349
rts.sendData(ExchangePageBase + 76, ExchangepageAddr);
350350
}
351351
#endif

0 commit comments

Comments
 (0)