瀏覽代碼

Power-Loss cleanup

Scott Lahteine 4 年之前
父節點
當前提交
7e902b7e29
共有 2 個文件被更改,包括 24 次插入43 次删除
  1. 11
    11
      Marlin/src/feature/powerloss.cpp
  2. 13
    32
      Marlin/src/feature/powerloss.h

+ 11
- 11
Marlin/src/feature/powerloss.cpp 查看文件

@@ -180,10 +180,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
180 180
 
181 181
     // Machine state
182 182
     info.current_position = current_position;
183
+    info.feedrate = uint16_t(feedrate_mm_s * 60.0f);
183 184
     info.zraise = zraise;
184 185
     TERN_(HAS_HOME_OFFSET, info.home_offset = home_offset);
185 186
     TERN_(HAS_POSITION_SHIFT, info.position_shift = position_shift);
186
-    info.feedrate = uint16_t(feedrate_mm_s * 60.0f);
187 187
 
188 188
     #if HAS_MULTI_EXTRUDER
189 189
       info.active_extruder = active_extruder;
@@ -209,7 +209,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
209 209
     #endif
210 210
 
211 211
     #if HAS_LEVELING
212
-      info.leveling = planner.leveling_active;
212
+      info.flag.leveling = planner.leveling_active;
213 213
       info.fade = TERN0(ENABLE_LEVELING_FADE_HEIGHT, planner.z_fade_height);
214 214
     #endif
215 215
 
@@ -220,12 +220,12 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
220 220
       info.retract_hop = fwretract.current_hop;
221 221
     #endif
222 222
 
223
-    // Relative axis modes
224
-    info.axis_relative = gcode.axis_relative;
225
-
226 223
     // Elapsed print job time
227 224
     info.print_job_elapsed = print_job_timer.duration();
228 225
 
226
+    // Relative axis modes
227
+    info.axis_relative = gcode.axis_relative;
228
+
229 229
     // Misc. Marlin flags
230 230
     info.flag.dryrun = !!(marlin_debug_flags & MARLIN_DEBUG_DRYRUN);
231 231
     info.flag.allow_cold_extrusion = TERN0(PREVENT_COLD_EXTRUSION, thermalManager.allow_cold_extrude);
@@ -457,8 +457,8 @@ void PrintJobRecovery::resume() {
457 457
   #if HAS_LEVELING
458 458
     // Restore leveling state before 'G92 Z' to ensure
459 459
     // the Z stepper count corresponds to the native Z.
460
-    if (info.fade || info.leveling) {
461
-      sprintf_P(cmd, PSTR("M420 S%i Z%s"), int(info.leveling), dtostrf(info.fade, 1, 1, str_1));
460
+    if (info.fade || info.flag.leveling) {
461
+      sprintf_P(cmd, PSTR("M420 S%i Z%s"), int(info.flag.leveling), dtostrf(info.fade, 1, 1, str_1));
462 462
       gcode.process_subcommands_now(cmd);
463 463
     }
464 464
   #endif
@@ -507,15 +507,15 @@ void PrintJobRecovery::resume() {
507 507
   sprintf_P(cmd, PSTR("G92.9 E%s"), dtostrf(info.current_position.e, 1, 3, str_1));
508 508
   gcode.process_subcommands_now(cmd);
509 509
 
510
-  // Relative axis modes
511
-  gcode.axis_relative = info.axis_relative;
512
-
513 510
   TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset);
514 511
   TERN_(HAS_POSITION_SHIFT, position_shift = info.position_shift);
515 512
   #if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
516 513
     LOOP_XYZ(i) update_workspace_offset((AxisEnum)i);
517 514
   #endif
518 515
 
516
+  // Relative axis modes
517
+  gcode.axis_relative = info.axis_relative;
518
+
519 519
   #if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
520 520
     const uint8_t old_flags = marlin_debug_flags;
521 521
     marlin_debug_flags |= MARLIN_DEBUG_ECHO;
@@ -598,7 +598,7 @@ void PrintJobRecovery::resume() {
598 598
         #endif
599 599
 
600 600
         #if HAS_LEVELING
601
-          DEBUG_ECHOLNPAIR("leveling: ", int(info.leveling), " fade: ", info.fade);
601
+          DEBUG_ECHOLNPAIR("leveling: ", int(info.flag.leveling), " fade: ", info.fade);
602 602
         #endif
603 603
         #if ENABLED(FWRETRACT)
604 604
           DEBUG_ECHOPGM("retract: ");

+ 13
- 32
Marlin/src/feature/powerloss.h 查看文件

@@ -47,42 +47,24 @@ typedef struct {
47 47
 
48 48
   // Machine state
49 49
   xyze_pos_t current_position;
50
+  uint16_t feedrate;
50 51
   float zraise;
51 52
 
52
-  #if HAS_HOME_OFFSET
53
-    xyz_pos_t home_offset;
54
-  #endif
55
-  #if HAS_POSITION_SHIFT
56
-    xyz_pos_t position_shift;
57
-  #endif
58
-
59
-  uint16_t feedrate;
60 53
 
61
-  #if HAS_MULTI_EXTRUDER
62
-    uint8_t active_extruder;
63
-  #endif
54
+  TERN_(HAS_HOME_OFFSET,    xyz_pos_t home_offset);
55
+  TERN_(HAS_POSITION_SHIFT, xyz_pos_t position_shift);
56
+  TERN_(HAS_MULTI_EXTRUDER, uint8_t active_extruder);
64 57
 
65 58
   #if DISABLED(NO_VOLUMETRICS)
66 59
     bool volumetric_enabled;
67 60
     float filament_size[EXTRUDERS];
68 61
   #endif
69 62
 
70
-  #if HAS_HOTEND
71
-    int16_t target_temperature[HOTENDS];
72
-  #endif
63
+  TERN_(HAS_HOTEND,     int16_t target_temperature[HOTENDS]);
64
+  TERN_(HAS_HEATED_BED, int16_t target_temperature_bed);
65
+  TERN_(HAS_FAN,        uint8_t fan_speed[FAN_COUNT]);
73 66
 
74
-  #if HAS_HEATED_BED
75
-    int16_t target_temperature_bed;
76
-  #endif
77
-
78
-  #if HAS_FAN
79
-    uint8_t fan_speed[FAN_COUNT];
80
-  #endif
81
-
82
-  #if HAS_LEVELING
83
-    bool leveling;
84
-    float fade;
85
-  #endif
67
+  TERN_(HAS_LEVELING, float fade);
86 68
 
87 69
   #if ENABLED(FWRETRACT)
88 70
     float retract[EXTRUDERS], retract_hop;
@@ -92,14 +74,9 @@ typedef struct {
92 74
   #if ENABLED(MIXING_EXTRUDER)
93 75
     //uint_fast8_t selected_vtool;
94 76
     //mixer_comp_t color[NR_MIXING_VIRTUAL_TOOLS][MIXING_STEPPERS];
95
-    #if ENABLED(GRADIENT_MIX)
96
-      gradient_t gradient;
97
-    #endif
77
+    TERN_(GRADIENT_MIX, gradient_t gradient);
98 78
   #endif
99 79
 
100
-  // Relative axis modes
101
-  uint8_t axis_relative;
102
-
103 80
   // SD Filename and position
104 81
   char sd_filename[MAXPATHNAMELENGTH];
105 82
   volatile uint32_t sdpos;
@@ -107,10 +84,14 @@ typedef struct {
107 84
   // Job elapsed time
108 85
   millis_t print_job_elapsed;
109 86
 
87
+  // Relative axis modes
88
+  uint8_t axis_relative;
89
+
110 90
   // Misc. Marlin flags
111 91
   struct {
112 92
     bool dryrun:1;                // M111 S8
113 93
     bool allow_cold_extrusion:1;  // M302 P1
94
+    TERN_(HAS_LEVELING, bool leveling:1);
114 95
   } flag;
115 96
 
116 97
   uint8_t valid_foot;

Loading…
取消
儲存