Browse Source

Save recovery info on SD pause

pull/1/head
Scott Lahteine 6 years ago
parent
commit
cecc238f68
  1. 6
      Marlin/src/feature/power_loss_recovery.cpp
  2. 3
      Marlin/src/feature/power_loss_recovery.h
  3. 7
      Marlin/src/lcd/menu/menu_main.cpp

6
Marlin/src/feature/power_loss_recovery.cpp

@ -118,7 +118,7 @@ void PrintJobRecovery::load() {
/** /**
* Save the current machine state to the power-loss recovery file * 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 #if SAVE_INFO_INTERVAL_MS > 0
static millis_t next_save_ms; // = 0 static millis_t next_save_ms; // = 0
@ -182,8 +182,8 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
#endif #endif
// Commands in the queue // Commands in the queue
info.commands_in_queue = save_queue ? commands_in_queue : 0;
info.cmd_queue_index_r = cmd_queue_index_r; info.cmd_queue_index_r = cmd_queue_index_r;
info.commands_in_queue = commands_in_queue;
COPY(info.command_queue, command_queue); COPY(info.command_queue, command_queue);
// Elapsed print job time // Elapsed print job time
@ -332,7 +332,7 @@ void PrintJobRecovery::resume() {
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
// Process commands from the old pending queue // 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) for (; c--; r = (r + 1) % BUFSIZE)
gcode.process_subcommands_now(info.command_queue[r]); gcode.process_subcommands_now(info.command_queue[r]);

3
Marlin/src/feature/power_loss_recovery.h

@ -64,7 +64,7 @@ typedef struct {
#endif #endif
// Command queue // 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]; char command_queue[BUFSIZE][MAX_CMD_SIZE];
// SD Filename and position // SD Filename and position
@ -104,6 +104,7 @@ class PrintJobRecovery {
#else #else
false false
#endif #endif
, const bool save_queue=true
); );
static inline bool valid() { return info.valid_head && info.valid_head == info.valid_foot; } static inline bool valid() { return info.valid_head && info.valid_head == info.valid_foot; }

7
Marlin/src/lcd/menu/menu_main.cpp

@ -37,7 +37,14 @@
#include "../../gcode/queue.h" #include "../../gcode/queue.h"
#include "../../module/printcounter.h" #include "../../module/printcounter.h"
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../feature/power_loss_recovery.h"
#endif
void lcd_sdcard_pause() { void lcd_sdcard_pause() {
#if ENABLED(POWER_LOSS_RECOVERY)
if (recovery.enabled) recovery.save(true, false);
#endif
card.pauseSDPrint(); card.pauseSDPrint();
print_job_timer.pause(); print_job_timer.pause();
#if ENABLED(PARK_HEAD_ON_PAUSE) #if ENABLED(PARK_HEAD_ON_PAUSE)

Loading…
Cancel
Save