Browse Source

Power Loss Recovery for volumetric extrusion (#15734)

The-Force 5 years ago
parent
commit
c6f694a247

+ 30
- 0
Marlin/src/feature/power_loss_recovery.cpp View File

@@ -183,6 +183,15 @@ void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*=
183 183
       info.active_extruder = active_extruder;
184 184
     #endif
185 185
 
186
+    #if DISABLED(NO_VOLUMETRICS)
187
+      info.volumetric_enabled = parser.volumetric_enabled;
188
+      #if EXTRUDERS > 1
189
+        for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e];
190
+      #else
191
+        if (parser.volumetric_enabled) info.filament_size = planner.filament_size[active_extruder]; 
192
+      #endif    
193
+    #endif
194
+
186 195
     #if EXTRUDERS
187 196
       HOTEND_LOOP() info.target_temperature[e] = thermalManager.temp_hotend[e].target;
188 197
     #endif
@@ -291,6 +300,27 @@ void PrintJobRecovery::resume() {
291 300
     gcode.process_subcommands_now(cmd);
292 301
   #endif
293 302
 
303
+  // Recover volumetric extrusion state
304
+  #if DISABLED(NO_VOLUMETRICS)    
305
+    #if EXTRUDERS > 1
306
+      for (int8_t e = 0; e < EXTRUDERS; e++) {
307
+        dtostrf(info.filament_size[e], 1, 3, str_1);
308
+        sprintf_P(cmd, PSTR("M200 T%i D%s"), e, str_1);
309
+        gcode.process_subcommands_now(cmd);
310
+      }
311
+      if (!info.volumetric_enabled) {
312
+        sprintf_P(cmd, PSTR("M200 T%i D0"), info.active_extruder);
313
+        gcode.process_subcommands_now(cmd);
314
+      }
315
+    #else
316
+      if (info.volumetric_enabled) {
317
+        dtostrf(info.filament_size, 1, 3, str_1);
318
+        sprintf_P(cmd, PSTR("M200 D%s"), str_1);
319
+        gcode.process_subcommands_now(cmd);
320
+      }
321
+    #endif
322
+  #endif
323
+
294 324
   #if HAS_HEATED_BED
295 325
     const int16_t bt = info.target_temperature_bed;
296 326
     if (bt) {

+ 9
- 0
Marlin/src/feature/power_loss_recovery.h View File

@@ -59,6 +59,15 @@ typedef struct {
59 59
     uint8_t active_extruder;
60 60
   #endif
61 61
 
62
+  #if DISABLED(NO_VOLUMETRICS)
63
+    bool volumetric_enabled;
64
+    #if EXTRUDERS > 1
65
+      float filament_size[EXTRUDERS]; 
66
+    #else
67
+      float filament_size; 
68
+    #endif    
69
+  #endif
70
+
62 71
   #if HOTENDS
63 72
     int16_t target_temperature[HOTENDS];
64 73
   #endif

Loading…
Cancel
Save