Browse Source

Save recovery info on SD pause

Scott Lahteine 5 years ago
parent
commit
cecc238f68

+ 3
- 3
Marlin/src/feature/power_loss_recovery.cpp View File

@@ -118,7 +118,7 @@ void PrintJobRecovery::load() {
118 118
 /**
119 119
  * Save the current machine state to the power-loss recovery file
120 120
  */
121
-void PrintJobRecovery::save(const bool force/*=false*/) {
121
+void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*=true*/) {
122 122
 
123 123
   #if SAVE_INFO_INTERVAL_MS > 0
124 124
     static millis_t next_save_ms; // = 0
@@ -182,8 +182,8 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
182 182
     #endif
183 183
 
184 184
     // Commands in the queue
185
+    info.commands_in_queue = save_queue ? commands_in_queue : 0;
185 186
     info.cmd_queue_index_r = cmd_queue_index_r;
186
-    info.commands_in_queue = commands_in_queue;
187 187
     COPY(info.command_queue, command_queue);
188 188
 
189 189
     // Elapsed print job time
@@ -332,7 +332,7 @@ void PrintJobRecovery::resume() {
332 332
   gcode.process_subcommands_now(cmd);
333 333
 
334 334
   // Process commands from the old pending queue
335
-  uint8_t r = info.cmd_queue_index_r, c = info.commands_in_queue;
335
+  uint8_t c = info.commands_in_queue, r = info.cmd_queue_index_r;
336 336
   for (; c--; r = (r + 1) % BUFSIZE)
337 337
     gcode.process_subcommands_now(info.command_queue[r]);
338 338
 

+ 2
- 1
Marlin/src/feature/power_loss_recovery.h View File

@@ -64,7 +64,7 @@ typedef struct {
64 64
   #endif
65 65
 
66 66
   // Command queue
67
-  uint8_t cmd_queue_index_r, commands_in_queue;
67
+  uint8_t commands_in_queue, cmd_queue_index_r;
68 68
   char command_queue[BUFSIZE][MAX_CMD_SIZE];
69 69
 
70 70
   // SD Filename and position
@@ -104,6 +104,7 @@ class PrintJobRecovery {
104 104
       #else
105 105
         false
106 106
       #endif
107
+      , const bool save_queue=true
107 108
     );
108 109
 
109 110
   static inline bool valid() { return info.valid_head && info.valid_head == info.valid_foot; }

+ 7
- 0
Marlin/src/lcd/menu/menu_main.cpp View File

@@ -37,7 +37,14 @@
37 37
   #include "../../gcode/queue.h"
38 38
   #include "../../module/printcounter.h"
39 39
 
40
+  #if ENABLED(POWER_LOSS_RECOVERY)
41
+    #include "../../feature/power_loss_recovery.h"
42
+  #endif
43
+
40 44
   void lcd_sdcard_pause() {
45
+    #if ENABLED(POWER_LOSS_RECOVERY)
46
+      if (recovery.enabled) recovery.save(true, false);
47
+    #endif
41 48
     card.pauseSDPrint();
42 49
     print_job_timer.pause();
43 50
     #if ENABLED(PARK_HEAD_ON_PAUSE)

Loading…
Cancel
Save