Save recovery info on SD pause
This commit is contained in:
parent
439a3e8463
commit
cecc238f68
@ -118,7 +118,7 @@ void PrintJobRecovery::load() {
|
||||
/**
|
||||
* Save the current machine state to the power-loss recovery file
|
||||
*/
|
||||
void PrintJobRecovery::save(const bool force/*=false*/) {
|
||||
void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*=true*/) {
|
||||
|
||||
#if SAVE_INFO_INTERVAL_MS > 0
|
||||
static millis_t next_save_ms; // = 0
|
||||
@ -182,8 +182,8 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
|
||||
#endif
|
||||
|
||||
// Commands in the queue
|
||||
info.commands_in_queue = save_queue ? commands_in_queue : 0;
|
||||
info.cmd_queue_index_r = cmd_queue_index_r;
|
||||
info.commands_in_queue = commands_in_queue;
|
||||
COPY(info.command_queue, command_queue);
|
||||
|
||||
// Elapsed print job time
|
||||
@ -332,7 +332,7 @@ void PrintJobRecovery::resume() {
|
||||
gcode.process_subcommands_now(cmd);
|
||||
|
||||
// Process commands from the old pending queue
|
||||
uint8_t r = info.cmd_queue_index_r, c = info.commands_in_queue;
|
||||
uint8_t c = info.commands_in_queue, r = info.cmd_queue_index_r;
|
||||
for (; c--; r = (r + 1) % BUFSIZE)
|
||||
gcode.process_subcommands_now(info.command_queue[r]);
|
||||
|
||||
|
@ -64,7 +64,7 @@ typedef struct {
|
||||
#endif
|
||||
|
||||
// Command queue
|
||||
uint8_t cmd_queue_index_r, commands_in_queue;
|
||||
uint8_t commands_in_queue, cmd_queue_index_r;
|
||||
char command_queue[BUFSIZE][MAX_CMD_SIZE];
|
||||
|
||||
// SD Filename and position
|
||||
@ -104,6 +104,7 @@ class PrintJobRecovery {
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
, const bool save_queue=true
|
||||
);
|
||||
|
||||
static inline bool valid() { return info.valid_head && info.valid_head == info.valid_foot; }
|
||||
|
@ -37,7 +37,14 @@
|
||||
#include "../../gcode/queue.h"
|
||||
#include "../../module/printcounter.h"
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#include "../../feature/power_loss_recovery.h"
|
||||
#endif
|
||||
|
||||
void lcd_sdcard_pause() {
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
if (recovery.enabled) recovery.save(true, false);
|
||||
#endif
|
||||
card.pauseSDPrint();
|
||||
print_job_timer.pause();
|
||||
#if ENABLED(PARK_HEAD_ON_PAUSE)
|
||||
|
Loading…
Reference in New Issue
Block a user