瀏覽代碼

🧑‍💻 General and Axis-based bitfield flags (#23989)

Scott Lahteine 3 年之前
父節點
當前提交
c4873a64ec
沒有連結到貢獻者的電子郵件帳戶。

+ 53
- 0
Marlin/src/core/types.h 查看文件

76
 
76
 
77
 #define AXIS_COLLISION(L) (AXIS4_NAME == L || AXIS5_NAME == L || AXIS6_NAME == L || AXIS7_NAME == L || AXIS8_NAME == L || AXIS9_NAME == L)
77
 #define AXIS_COLLISION(L) (AXIS4_NAME == L || AXIS5_NAME == L || AXIS6_NAME == L || AXIS7_NAME == L || AXIS8_NAME == L || AXIS9_NAME == L)
78
 
78
 
79
+// General Flags for some number of states
80
+template<size_t N>
81
+struct Flags {
82
+  typedef typename IF<(N>8), uint16_t, uint8_t>::type bits_t;
83
+  typedef struct { bool b0:1, b1:1, b2:1, b3:1, b4:1, b5:1, b6:1, b7:1; } N8;
84
+  typedef struct { bool b0:1, b1:1, b2:1, b3:1, b4:1, b5:1, b6:1, b7:1, b8:1, b9:1, b10:1, b11:1, b12:1, b13:1, b14:1, b15:1; } N16;
85
+  union {
86
+    bits_t b;
87
+    typename IF<(N>8), N16, N8>::type flag;
88
+  };
89
+  void reset()                             { b = 0; }
90
+  void set(const int n, const bool onoff)  { onoff ? set(n) : clear(n); }
91
+  void set(const int n)                    { b |=  (bits_t)_BV(n); }
92
+  void clear(const int n)                  { b &= ~(bits_t)_BV(n); }
93
+  bool test(const int n) const             { return TEST(b, n); }
94
+        bool operator[](const int n)       { return test(n); }
95
+  const bool operator[](const int n) const { return test(n); }
96
+  const int size() const                   { return sizeof(b); }
97
+};
98
+
99
+// Specialization for a single bool flag
100
+template<>
101
+struct Flags<1> {
102
+  bool b;
103
+  void reset()                            { b = false; }
104
+  void set(const int n, const bool onoff) { onoff ? set(n) : clear(n); }
105
+  void set(const int)                     { b = true; }
106
+  void clear(const int)                   { b = false; }
107
+  bool test(const int) const              { return b; }
108
+        bool operator[](const int)        { return b; }
109
+  const bool operator[](const int) const  { return b; }
110
+  const int size() const                  { return sizeof(b); }
111
+};
112
+
113
+typedef Flags<8> flags_8_t;
114
+typedef Flags<16> flags_16_t;
115
+
116
+// Flags for some axis states, with per-axis aliases xyzijkuvwe
117
+typedef struct AxisFlags {
118
+  union {
119
+    struct Flags<LOGICAL_AXES> flags;
120
+    struct { bool LOGICAL_AXIS_LIST(e:1, x:1, y:1, z:1, i:1, j:1, k:1, u:1, v:1, w:1); };
121
+  };
122
+  void reset()                             { flags.reset(); }
123
+  void set(const int n)                    { flags.set(n); }
124
+  void set(const int n, const bool onoff)  { flags.set(n, onoff); }
125
+  void clear(const int n)                  { flags.clear(n); }
126
+  bool test(const int n) const             { return flags.test(n); }
127
+        bool operator[](const int n)       { return flags[n]; }
128
+  const bool operator[](const int n) const { return flags[n]; }
129
+  const int size() const                   { return sizeof(flags); }
130
+} axis_flags_t;
131
+
79
 //
132
 //
80
 // Enumerated axis indices
133
 // Enumerated axis indices
81
 //
134
 //

+ 2
- 2
Marlin/src/feature/fancheck.cpp 查看文件

34
 #if HAS_AUTO_FAN && EXTRUDER_AUTO_FAN_SPEED != 255 && DISABLED(FOURWIRES_FANS)
34
 #if HAS_AUTO_FAN && EXTRUDER_AUTO_FAN_SPEED != 255 && DISABLED(FOURWIRES_FANS)
35
   bool FanCheck::measuring = false;
35
   bool FanCheck::measuring = false;
36
 #endif
36
 #endif
37
-bool FanCheck::tacho_state[TACHO_COUNT];
37
+Flags<TACHO_COUNT> FanCheck::tacho_state;
38
 uint16_t FanCheck::edge_counter[TACHO_COUNT];
38
 uint16_t FanCheck::edge_counter[TACHO_COUNT];
39
 uint8_t FanCheck::rps[TACHO_COUNT];
39
 uint8_t FanCheck::rps[TACHO_COUNT];
40
 FanCheck::TachoError FanCheck::error = FanCheck::TachoError::NONE;
40
 FanCheck::TachoError FanCheck::error = FanCheck::TachoError::NONE;
103
 
103
 
104
     if (status != tacho_state[f]) {
104
     if (status != tacho_state[f]) {
105
       if (measuring) ++edge_counter[f];
105
       if (measuring) ++edge_counter[f];
106
-      tacho_state[f] = status;
106
+      tacho_state.set(f, status);
107
     }
107
     }
108
   }
108
   }
109
 }
109
 }

+ 1
- 1
Marlin/src/feature/fancheck.h 查看文件

51
     #else
51
     #else
52
       static constexpr bool measuring = true;
52
       static constexpr bool measuring = true;
53
     #endif
53
     #endif
54
-    static bool tacho_state[TACHO_COUNT];
54
+    static Flags<TACHO_COUNT> tacho_state;
55
     static uint16_t edge_counter[TACHO_COUNT];
55
     static uint16_t edge_counter[TACHO_COUNT];
56
     static uint8_t rps[TACHO_COUNT];
56
     static uint8_t rps[TACHO_COUNT];
57
     static TachoError error;
57
     static TachoError error;

+ 6
- 6
Marlin/src/feature/fwretract.cpp 查看文件

45
 // private:
45
 // private:
46
 
46
 
47
 #if HAS_MULTI_EXTRUDER
47
 #if HAS_MULTI_EXTRUDER
48
-  bool FWRetract::retracted_swap[EXTRUDERS];          // Which extruders are swap-retracted
48
+  Flags<EXTRUDERS> FWRetract::retracted_swap;         // Which extruders are swap-retracted
49
 #endif
49
 #endif
50
 
50
 
51
 // public:
51
 // public:
56
   bool FWRetract::autoretract_enabled;                // M209 S - Autoretract switch
56
   bool FWRetract::autoretract_enabled;                // M209 S - Autoretract switch
57
 #endif
57
 #endif
58
 
58
 
59
-bool FWRetract::retracted[EXTRUDERS];                 // Which extruders are currently retracted
59
+Flags<EXTRUDERS> FWRetract::retracted;                // Which extruders are currently retracted
60
 
60
 
61
 float FWRetract::current_retract[EXTRUDERS],          // Retract value used by planner
61
 float FWRetract::current_retract[EXTRUDERS],          // Retract value used by planner
62
       FWRetract::current_hop;
62
       FWRetract::current_hop;
73
   settings.swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
73
   settings.swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
74
   current_hop = 0.0;
74
   current_hop = 0.0;
75
 
75
 
76
+  retracted.reset();
76
   EXTRUDER_LOOP() {
77
   EXTRUDER_LOOP() {
77
-    retracted[e] = false;
78
-    E_TERN_(retracted_swap[e] = false);
78
+    E_TERN_(retracted_swap.clear(e));
79
     current_retract[e] = 0.0;
79
     current_retract[e] = 0.0;
80
   }
80
   }
81
 }
81
 }
173
 
173
 
174
   TERN_(RETRACT_SYNC_MIXING, mixer.T(old_mixing_tool));   // Restore original mixing tool
174
   TERN_(RETRACT_SYNC_MIXING, mixer.T(old_mixing_tool));   // Restore original mixing tool
175
 
175
 
176
-  retracted[active_extruder] = retracting;                // Active extruder now retracted / recovered
176
+  retracted.set(active_extruder, retracting);             // Active extruder now retracted / recovered
177
 
177
 
178
   // If swap retract/recover update the retracted_swap flag too
178
   // If swap retract/recover update the retracted_swap flag too
179
   #if HAS_MULTI_EXTRUDER
179
   #if HAS_MULTI_EXTRUDER
180
-    if (swapping) retracted_swap[active_extruder] = retracting;
180
+    if (swapping) retracted_swap.set(active_extruder, retracting);
181
   #endif
181
   #endif
182
 
182
 
183
   /* // debugging
183
   /* // debugging

+ 3
- 5
Marlin/src/feature/fwretract.h 查看文件

43
 class FWRetract {
43
 class FWRetract {
44
 private:
44
 private:
45
   #if HAS_MULTI_EXTRUDER
45
   #if HAS_MULTI_EXTRUDER
46
-    static bool retracted_swap[EXTRUDERS];         // Which extruders are swap-retracted
46
+    static Flags<EXTRUDERS> retracted_swap;        // Which extruders are swap-retracted
47
   #endif
47
   #endif
48
 
48
 
49
 public:
49
 public:
55
     static constexpr bool autoretract_enabled = false;
55
     static constexpr bool autoretract_enabled = false;
56
   #endif
56
   #endif
57
 
57
 
58
-  static bool retracted[EXTRUDERS];                // Which extruders are currently retracted
58
+  static Flags<EXTRUDERS> retracted;               // Which extruders are currently retracted
59
   static float current_retract[EXTRUDERS],         // Retract value used by planner
59
   static float current_retract[EXTRUDERS],         // Retract value used by planner
60
                current_hop;                        // Hop value used by planner
60
                current_hop;                        // Hop value used by planner
61
 
61
 
63
 
63
 
64
   static void reset();
64
   static void reset();
65
 
65
 
66
-  static void refresh_autoretract() {
67
-    EXTRUDER_LOOP() retracted[e] = false;
68
-  }
66
+  static void refresh_autoretract() { retracted.reset(); }
69
 
67
 
70
   static void enable_autoretract(const bool enable) {
68
   static void enable_autoretract(const bool enable) {
71
     #if ENABLED(FWRETRACT_AUTORETRACT)
69
     #if ENABLED(FWRETRACT_AUTORETRACT)

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

514
     EXTRUDER_LOOP() {
514
     EXTRUDER_LOOP() {
515
       if (info.retract[e] != 0.0) {
515
       if (info.retract[e] != 0.0) {
516
         fwretract.current_retract[e] = info.retract[e];
516
         fwretract.current_retract[e] = info.retract[e];
517
-        fwretract.retracted[e] = true;
517
+        fwretract.retracted.set(e);
518
       }
518
       }
519
     }
519
     }
520
     fwretract.current_hop = info.retract_hop;
520
     fwretract.current_hop = info.retract_hop;

+ 4
- 4
Marlin/src/gcode/control/M17_M18_M84.cpp 查看文件

33
 #include "../../core/debug_out.h"
33
 #include "../../core/debug_out.h"
34
 #include "../../libs/hex_print.h"
34
 #include "../../libs/hex_print.h"
35
 
35
 
36
-inline axis_flags_t selected_axis_bits() {
37
-  axis_flags_t selected{0};
36
+inline stepper_flags_t selected_axis_bits() {
37
+  stepper_flags_t selected{0};
38
   #if HAS_EXTRUDERS
38
   #if HAS_EXTRUDERS
39
     if (parser.seen('E')) {
39
     if (parser.seen('E')) {
40
       if (E_TERN0(parser.has_value())) {
40
       if (E_TERN0(parser.has_value())) {
61
 }
61
 }
62
 
62
 
63
 // Enable specified axes and warn about other affected axes
63
 // Enable specified axes and warn about other affected axes
64
-void do_enable(const axis_flags_t to_enable) {
64
+void do_enable(const stepper_flags_t to_enable) {
65
   const ena_mask_t was_enabled = stepper.axis_enabled.bits,
65
   const ena_mask_t was_enabled = stepper.axis_enabled.bits,
66
                   shall_enable = to_enable.bits & ~was_enabled;
66
                   shall_enable = to_enable.bits & ~was_enabled;
67
 
67
 
147
   }
147
   }
148
 }
148
 }
149
 
149
 
150
-void try_to_disable(const axis_flags_t to_disable) {
150
+void try_to_disable(const stepper_flags_t to_disable) {
151
   ena_mask_t still_enabled = to_disable.bits & stepper.axis_enabled.bits;
151
   ena_mask_t still_enabled = to_disable.bits & stepper.axis_enabled.bits;
152
 
152
 
153
   DEBUG_ECHOLNPGM("Enabled: ", hex_word(stepper.axis_enabled.bits), " To Disable: ", hex_word(to_disable.bits), " | ", hex_word(still_enabled));
153
   DEBUG_ECHOLNPGM("Enabled: ", hex_word(stepper.axis_enabled.bits), " To Disable: ", hex_word(to_disable.bits), " | ", hex_word(still_enabled));

+ 6
- 3
Marlin/src/lcd/menu/menu_tramming.cpp 查看文件

44
 #include "../../core/debug_out.h"
44
 #include "../../core/debug_out.h"
45
 
45
 
46
 static float z_measured[G35_PROBE_COUNT];
46
 static float z_measured[G35_PROBE_COUNT];
47
-static bool z_isvalid[G35_PROBE_COUNT];
47
+static Flags<G35_PROBE_COUNT> z_isvalid;
48
 static uint8_t tram_index = 0;
48
 static uint8_t tram_index = 0;
49
 static int8_t reference_index; // = 0
49
 static int8_t reference_index; // = 0
50
 
50
 
61
   move_to_tramming_wait_pos();
61
   move_to_tramming_wait_pos();
62
 
62
 
63
   DEBUG_ECHOLNPGM("probe_single_point(", tram_index, ") = ", z_probed_height, "mm");
63
   DEBUG_ECHOLNPGM("probe_single_point(", tram_index, ") = ", z_probed_height, "mm");
64
-  return (z_isvalid[tram_index] = !isnan(z_probed_height));
64
+
65
+  const bool v = !isnan(z_probed_height);
66
+  z_isvalid.set(tram_index, v);
67
+  return v;
65
 }
68
 }
66
 
69
 
67
 static void _menu_single_probe() {
70
 static void _menu_single_probe() {
95
   ui.defer_status_screen();
98
   ui.defer_status_screen();
96
 
99
 
97
   // Initialize measured point flags
100
   // Initialize measured point flags
98
-  ZERO(z_isvalid);
101
+  z_isvalid.reset();
99
   reference_index = -1;
102
   reference_index = -1;
100
 
103
 
101
   // Inject G28, wait for homing to complete,
104
   // Inject G28, wait for homing to complete,

+ 18
- 17
Marlin/src/module/settings.cpp 查看文件

178
 #endif
178
 #endif
179
 
179
 
180
 #define _EN_ITEM(N) , E##N
180
 #define _EN_ITEM(N) , E##N
181
+#define _EN1_ITEM(N) , E##N:1
181
 
182
 
182
-typedef struct { uint16_t NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_stepper_current_t;
183
-typedef struct { uint32_t NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_hybrid_threshold_t;
184
-typedef struct {  int16_t NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W), X2, Y2, Z2, Z3, Z4;                              } tmc_sgt_t;
185
-typedef struct {     bool NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_stealth_enabled_t;
183
+typedef struct { uint16_t NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } per_stepper_uint16_t;
184
+typedef struct { uint32_t NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } per_stepper_uint32_t;
185
+typedef struct {  int16_t NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W), X2, Y2, Z2, Z3, Z4;                              } mot_stepper_int16_t;
186
+typedef struct {     bool NUM_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1, U:1, V:1, W:1), X2:1, Y2:1, Z2:1, Z3:1, Z4:1 REPEAT(E_STEPPERS, _EN1_ITEM); } per_stepper_bool_t;
186
 
187
 
187
 #undef _EN_ITEM
188
 #undef _EN_ITEM
188
 
189
 
430
   //
431
   //
431
   // HAS_TRINAMIC_CONFIG
432
   // HAS_TRINAMIC_CONFIG
432
   //
433
   //
433
-  tmc_stepper_current_t tmc_stepper_current;            // M906 X Y Z X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5
434
-  tmc_hybrid_threshold_t tmc_hybrid_threshold;          // M913 X Y Z X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5
435
-  tmc_sgt_t tmc_sgt;                                    // M914 X Y Z X2 Y2 Z2 Z3 Z4
436
-  tmc_stealth_enabled_t tmc_stealth_enabled;            // M569 X Y Z X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5
434
+  per_stepper_uint16_t tmc_stepper_current;             // M906 X Y Z I J K U V W X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5
435
+  per_stepper_uint32_t tmc_hybrid_threshold;            // M913 X Y Z I J K U V W X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5
436
+  mot_stepper_int16_t tmc_sgt;                          // M914 X Y Z I J K U V W X2 Y2 Z2 Z3 Z4
437
+  per_stepper_bool_t tmc_stealth_enabled;               // M569 X Y Z I J K U V W X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5
437
 
438
 
438
   //
439
   //
439
   // LIN_ADVANCE
440
   // LIN_ADVANCE
1220
     {
1221
     {
1221
       _FIELD_TEST(tmc_stepper_current);
1222
       _FIELD_TEST(tmc_stepper_current);
1222
 
1223
 
1223
-      tmc_stepper_current_t tmc_stepper_current{0};
1224
+      per_stepper_uint16_t tmc_stepper_current{0};
1224
 
1225
 
1225
       #if HAS_TRINAMIC_CONFIG
1226
       #if HAS_TRINAMIC_CONFIG
1226
         #if AXIS_IS_TMC(X)
1227
         #if AXIS_IS_TMC(X)
1300
       _FIELD_TEST(tmc_hybrid_threshold);
1301
       _FIELD_TEST(tmc_hybrid_threshold);
1301
 
1302
 
1302
       #if ENABLED(HYBRID_THRESHOLD)
1303
       #if ENABLED(HYBRID_THRESHOLD)
1303
-        tmc_hybrid_threshold_t tmc_hybrid_threshold{0};
1304
+        per_stepper_uint32_t tmc_hybrid_threshold{0};
1304
         TERN_(X_HAS_STEALTHCHOP,  tmc_hybrid_threshold.X =  stepperX.get_pwm_thrs());
1305
         TERN_(X_HAS_STEALTHCHOP,  tmc_hybrid_threshold.X =  stepperX.get_pwm_thrs());
1305
         TERN_(Y_HAS_STEALTHCHOP,  tmc_hybrid_threshold.Y =  stepperY.get_pwm_thrs());
1306
         TERN_(Y_HAS_STEALTHCHOP,  tmc_hybrid_threshold.Y =  stepperY.get_pwm_thrs());
1306
         TERN_(Z_HAS_STEALTHCHOP,  tmc_hybrid_threshold.Z =  stepperZ.get_pwm_thrs());
1307
         TERN_(Z_HAS_STEALTHCHOP,  tmc_hybrid_threshold.Z =  stepperZ.get_pwm_thrs());
1325
         TERN_(E7_HAS_STEALTHCHOP, tmc_hybrid_threshold.E7 = stepperE7.get_pwm_thrs());
1326
         TERN_(E7_HAS_STEALTHCHOP, tmc_hybrid_threshold.E7 = stepperE7.get_pwm_thrs());
1326
       #else
1327
       #else
1327
         #define _EN_ITEM(N) , .E##N =  30
1328
         #define _EN_ITEM(N) , .E##N =  30
1328
-        const tmc_hybrid_threshold_t tmc_hybrid_threshold = {
1329
+        const per_stepper_uint32_t tmc_hybrid_threshold = {
1329
           NUM_AXIS_LIST(.X = 100, .Y = 100, .Z = 3, .I = 3, .J = 3, .K = 3, .U = 3, .V = 3, .W = 3),
1330
           NUM_AXIS_LIST(.X = 100, .Y = 100, .Z = 3, .I = 3, .J = 3, .K = 3, .U = 3, .V = 3, .W = 3),
1330
           .X2 = 100, .Y2 = 100, .Z2 = 3, .Z3 = 3, .Z4 = 3
1331
           .X2 = 100, .Y2 = 100, .Z2 = 3, .Z3 = 3, .Z4 = 3
1331
           REPEAT(E_STEPPERS, _EN_ITEM)
1332
           REPEAT(E_STEPPERS, _EN_ITEM)
1339
     // TMC StallGuard threshold
1340
     // TMC StallGuard threshold
1340
     //
1341
     //
1341
     {
1342
     {
1342
-      tmc_sgt_t tmc_sgt{0};
1343
+      mot_stepper_int16_t tmc_sgt{0};
1343
       #if USE_SENSORLESS
1344
       #if USE_SENSORLESS
1344
         NUM_AXIS_CODE(
1345
         NUM_AXIS_CODE(
1345
           TERN_(X_SENSORLESS, tmc_sgt.X = stepperX.homing_threshold()),
1346
           TERN_(X_SENSORLESS, tmc_sgt.X = stepperX.homing_threshold()),
1367
     {
1368
     {
1368
       _FIELD_TEST(tmc_stealth_enabled);
1369
       _FIELD_TEST(tmc_stealth_enabled);
1369
 
1370
 
1370
-      tmc_stealth_enabled_t tmc_stealth_enabled = { false };
1371
+      per_stepper_bool_t tmc_stealth_enabled = { false };
1371
       TERN_(X_HAS_STEALTHCHOP,  tmc_stealth_enabled.X  = stepperX.get_stored_stealthChop());
1372
       TERN_(X_HAS_STEALTHCHOP,  tmc_stealth_enabled.X  = stepperX.get_stored_stealthChop());
1372
       TERN_(Y_HAS_STEALTHCHOP,  tmc_stealth_enabled.Y  = stepperY.get_stored_stealthChop());
1373
       TERN_(Y_HAS_STEALTHCHOP,  tmc_stealth_enabled.Y  = stepperY.get_stored_stealthChop());
1373
       TERN_(Z_HAS_STEALTHCHOP,  tmc_stealth_enabled.Z  = stepperZ.get_stored_stealthChop());
1374
       TERN_(Z_HAS_STEALTHCHOP,  tmc_stealth_enabled.Z  = stepperZ.get_stored_stealthChop());
2168
       {
2169
       {
2169
         _FIELD_TEST(tmc_stepper_current);
2170
         _FIELD_TEST(tmc_stepper_current);
2170
 
2171
 
2171
-        tmc_stepper_current_t currents;
2172
+        per_stepper_uint16_t currents;
2172
         EEPROM_READ(currents);
2173
         EEPROM_READ(currents);
2173
 
2174
 
2174
         #if HAS_TRINAMIC_CONFIG
2175
         #if HAS_TRINAMIC_CONFIG
2247
 
2248
 
2248
       // TMC Hybrid Threshold
2249
       // TMC Hybrid Threshold
2249
       {
2250
       {
2250
-        tmc_hybrid_threshold_t tmc_hybrid_threshold;
2251
+        per_stepper_uint32_t tmc_hybrid_threshold;
2251
         _FIELD_TEST(tmc_hybrid_threshold);
2252
         _FIELD_TEST(tmc_hybrid_threshold);
2252
         EEPROM_READ(tmc_hybrid_threshold);
2253
         EEPROM_READ(tmc_hybrid_threshold);
2253
 
2254
 
2283
       // TMC StallGuard threshold.
2284
       // TMC StallGuard threshold.
2284
       //
2285
       //
2285
       {
2286
       {
2286
-        tmc_sgt_t tmc_sgt;
2287
+        mot_stepper_int16_t tmc_sgt;
2287
         _FIELD_TEST(tmc_sgt);
2288
         _FIELD_TEST(tmc_sgt);
2288
         EEPROM_READ(tmc_sgt);
2289
         EEPROM_READ(tmc_sgt);
2289
         #if USE_SENSORLESS
2290
         #if USE_SENSORLESS
2312
       {
2313
       {
2313
         _FIELD_TEST(tmc_stealth_enabled);
2314
         _FIELD_TEST(tmc_stealth_enabled);
2314
 
2315
 
2315
-        tmc_stealth_enabled_t tmc_stealth_enabled;
2316
+        per_stepper_bool_t tmc_stealth_enabled;
2316
         EEPROM_READ(tmc_stealth_enabled);
2317
         EEPROM_READ(tmc_stealth_enabled);
2317
 
2318
 
2318
         #if HAS_TRINAMIC_CONFIG
2319
         #if HAS_TRINAMIC_CONFIG

+ 1
- 1
Marlin/src/module/stepper.cpp 查看文件

153
   #endif
153
   #endif
154
 #endif
154
 #endif
155
 
155
 
156
-axis_flags_t Stepper::axis_enabled; // {0}
156
+stepper_flags_t Stepper::axis_enabled; // {0}
157
 
157
 
158
 // private:
158
 // private:
159
 
159
 

+ 2
- 2
Marlin/src/module/stepper.h 查看文件

261
   };
261
   };
262
   constexpr ena_mask_t linear_bits() { return _BV(NUM_AXES) - 1; }
262
   constexpr ena_mask_t linear_bits() { return _BV(NUM_AXES) - 1; }
263
   constexpr ena_mask_t e_bits() { return (_BV(EXTRUDERS) - 1) << NUM_AXES; }
263
   constexpr ena_mask_t e_bits() { return (_BV(EXTRUDERS) - 1) << NUM_AXES; }
264
-} axis_flags_t;
264
+} stepper_flags_t;
265
 
265
 
266
 // All the stepper enable pins
266
 // All the stepper enable pins
267
 constexpr pin_t ena_pins[] = {
267
 constexpr pin_t ena_pins[] = {
596
       static void refresh_motor_power();
596
       static void refresh_motor_power();
597
     #endif
597
     #endif
598
 
598
 
599
-    static axis_flags_t axis_enabled;   // Axis stepper(s) ENABLED states
599
+    static stepper_flags_t axis_enabled;  // Axis stepper(s) ENABLED states
600
 
600
 
601
     static bool axis_is_enabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) {
601
     static bool axis_is_enabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) {
602
       return TEST(axis_enabled.bits, INDEX_OF_AXIS(axis, eindex));
602
       return TEST(axis_enabled.bits, INDEX_OF_AXIS(axis, eindex));

+ 4
- 4
Marlin/src/module/temperature.cpp 查看文件

1283
         static hotend_pid_t work_pid[HOTENDS];
1283
         static hotend_pid_t work_pid[HOTENDS];
1284
         static float temp_iState[HOTENDS] = { 0 },
1284
         static float temp_iState[HOTENDS] = { 0 },
1285
                      temp_dState[HOTENDS] = { 0 };
1285
                      temp_dState[HOTENDS] = { 0 };
1286
-        static bool pid_reset[HOTENDS] = { false };
1286
+        static Flags<HOTENDS> pid_reset;
1287
         const float pid_error = temp_hotend[ee].target - temp_hotend[ee].celsius;
1287
         const float pid_error = temp_hotend[ee].target - temp_hotend[ee].celsius;
1288
 
1288
 
1289
         float pid_output;
1289
         float pid_output;
1293
           || TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out)
1293
           || TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out)
1294
         ) {
1294
         ) {
1295
           pid_output = 0;
1295
           pid_output = 0;
1296
-          pid_reset[ee] = true;
1296
+          pid_reset.set(ee);
1297
         }
1297
         }
1298
         else if (pid_error > PID_FUNCTIONAL_RANGE) {
1298
         else if (pid_error > PID_FUNCTIONAL_RANGE) {
1299
           pid_output = PID_MAX;
1299
           pid_output = PID_MAX;
1300
-          pid_reset[ee] = true;
1300
+          pid_reset.set(ee);
1301
         }
1301
         }
1302
         else {
1302
         else {
1303
           if (pid_reset[ee]) {
1303
           if (pid_reset[ee]) {
1304
             temp_iState[ee] = 0.0;
1304
             temp_iState[ee] = 0.0;
1305
             work_pid[ee].Kd = 0.0;
1305
             work_pid[ee].Kd = 0.0;
1306
-            pid_reset[ee] = false;
1306
+            pid_reset.clear(ee);
1307
           }
1307
           }
1308
 
1308
 
1309
           work_pid[ee].Kd = work_pid[ee].Kd + PID_K2 * (PID_PARAM(Kd, ee) * (temp_dState[ee] - temp_hotend[ee].celsius) - work_pid[ee].Kd);
1309
           work_pid[ee].Kd = work_pid[ee].Kd + PID_K2 * (PID_PARAM(Kd, ee) * (temp_dState[ee] - temp_hotend[ee].celsius) - work_pid[ee].Kd);

+ 4
- 4
Marlin/src/module/tool_change.cpp 查看文件

46
 #endif
46
 #endif
47
 
47
 
48
 #if ENABLED(TOOLCHANGE_FS_INIT_BEFORE_SWAP)
48
 #if ENABLED(TOOLCHANGE_FS_INIT_BEFORE_SWAP)
49
-  bool toolchange_extruder_ready[EXTRUDERS];
49
+  Flags<EXTRUDERS> toolchange_extruder_ready;
50
 #endif
50
 #endif
51
 
51
 
52
 #if EITHER(MAGNETIC_PARKING_EXTRUDER, TOOL_SENSOR) \
52
 #if EITHER(MAGNETIC_PARKING_EXTRUDER, TOOL_SENSOR) \
1057
       if (new_tool == old_tool && !first_tool_is_primed && enable_first_prime) {
1057
       if (new_tool == old_tool && !first_tool_is_primed && enable_first_prime) {
1058
         tool_change_prime();
1058
         tool_change_prime();
1059
         first_tool_is_primed = true;
1059
         first_tool_is_primed = true;
1060
-        TERN_(TOOLCHANGE_FS_INIT_BEFORE_SWAP, toolchange_extruder_ready[old_tool] = true); // Primed and initialized
1060
+        TERN_(TOOLCHANGE_FS_INIT_BEFORE_SWAP, toolchange_extruder_ready.set(old_tool)); // Primed and initialized
1061
       }
1061
       }
1062
     #endif
1062
     #endif
1063
 
1063
 
1216
 
1216
 
1217
             #if ENABLED(TOOLCHANGE_FS_INIT_BEFORE_SWAP)
1217
             #if ENABLED(TOOLCHANGE_FS_INIT_BEFORE_SWAP)
1218
               if (!toolchange_extruder_ready[new_tool]) {
1218
               if (!toolchange_extruder_ready[new_tool]) {
1219
-                toolchange_extruder_ready[new_tool] = true;
1219
+                toolchange_extruder_ready.set(new_tool);
1220
                 fr = toolchange_settings.prime_speed;       // Next move is a prime
1220
                 fr = toolchange_settings.prime_speed;       // Next move is a prime
1221
                 unscaled_e_move(0, MMM_TO_MMS(fr));         // Init planner with 0 length move
1221
                 unscaled_e_move(0, MMM_TO_MMS(fr));         // Init planner with 0 length move
1222
               }
1222
               }
1401
 
1401
 
1402
     // Migrate the retracted state
1402
     // Migrate the retracted state
1403
     #if ENABLED(FWRETRACT)
1403
     #if ENABLED(FWRETRACT)
1404
-      fwretract.retracted[migration_extruder] = fwretract.retracted[active_extruder];
1404
+      fwretract.retracted.set(migration_extruder, fwretract.retracted[active_extruder]);
1405
     #endif
1405
     #endif
1406
 
1406
 
1407
     // Migrate the temperature to the new hotend
1407
     // Migrate the temperature to the new hotend

+ 1
- 1
Marlin/src/module/tool_change.h 查看文件

50
   #endif
50
   #endif
51
 
51
 
52
   #if ENABLED(TOOLCHANGE_FS_INIT_BEFORE_SWAP)
52
   #if ENABLED(TOOLCHANGE_FS_INIT_BEFORE_SWAP)
53
-    extern bool toolchange_extruder_ready[EXTRUDERS];
53
+    extern Flags<EXTRUDERS> toolchange_extruder_ready;
54
   #endif
54
   #endif
55
 
55
 
56
   #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
56
   #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)

Loading…
取消
儲存