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
 /**
118
 /**
119
  * Save the current machine state to the power-loss recovery file
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
   #if SAVE_INFO_INTERVAL_MS > 0
123
   #if SAVE_INFO_INTERVAL_MS > 0
124
     static millis_t next_save_ms; // = 0
124
     static millis_t next_save_ms; // = 0
182
     #endif
182
     #endif
183
 
183
 
184
     // Commands in the queue
184
     // Commands in the queue
185
+    info.commands_in_queue = save_queue ? commands_in_queue : 0;
185
     info.cmd_queue_index_r = cmd_queue_index_r;
186
     info.cmd_queue_index_r = cmd_queue_index_r;
186
-    info.commands_in_queue = commands_in_queue;
187
     COPY(info.command_queue, command_queue);
187
     COPY(info.command_queue, command_queue);
188
 
188
 
189
     // Elapsed print job time
189
     // Elapsed print job time
332
   gcode.process_subcommands_now(cmd);
332
   gcode.process_subcommands_now(cmd);
333
 
333
 
334
   // Process commands from the old pending queue
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
   for (; c--; r = (r + 1) % BUFSIZE)
336
   for (; c--; r = (r + 1) % BUFSIZE)
337
     gcode.process_subcommands_now(info.command_queue[r]);
337
     gcode.process_subcommands_now(info.command_queue[r]);
338
 
338
 

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

64
   #endif
64
   #endif
65
 
65
 
66
   // Command queue
66
   // Command queue
67
-  uint8_t cmd_queue_index_r, commands_in_queue;
67
+  uint8_t commands_in_queue, cmd_queue_index_r;
68
   char command_queue[BUFSIZE][MAX_CMD_SIZE];
68
   char command_queue[BUFSIZE][MAX_CMD_SIZE];
69
 
69
 
70
   // SD Filename and position
70
   // SD Filename and position
104
       #else
104
       #else
105
         false
105
         false
106
       #endif
106
       #endif
107
+      , const bool save_queue=true
107
     );
108
     );
108
 
109
 
109
   static inline bool valid() { return info.valid_head && info.valid_head == info.valid_foot; }
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
   #include "../../gcode/queue.h"
37
   #include "../../gcode/queue.h"
38
   #include "../../module/printcounter.h"
38
   #include "../../module/printcounter.h"
39
 
39
 
40
+  #if ENABLED(POWER_LOSS_RECOVERY)
41
+    #include "../../feature/power_loss_recovery.h"
42
+  #endif
43
+
40
   void lcd_sdcard_pause() {
44
   void lcd_sdcard_pause() {
45
+    #if ENABLED(POWER_LOSS_RECOVERY)
46
+      if (recovery.enabled) recovery.save(true, false);
47
+    #endif
41
     card.pauseSDPrint();
48
     card.pauseSDPrint();
42
     print_job_timer.pause();
49
     print_job_timer.pause();
43
     #if ENABLED(PARK_HEAD_ON_PAUSE)
50
     #if ENABLED(PARK_HEAD_ON_PAUSE)

Loading…
Cancel
Save