Browse Source

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

Scott Lahteine 2 years ago
parent
commit
c4873a64ec
No account linked to committer's email address

+ 53
- 0
Marlin/src/core/types.h View File

@@ -76,6 +76,59 @@ struct IF<true, L, R> { typedef L type; };
76 76
 
77 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 133
 // Enumerated axis indices
81 134
 //

+ 2
- 2
Marlin/src/feature/fancheck.cpp View File

@@ -34,7 +34,7 @@
34 34
 #if HAS_AUTO_FAN && EXTRUDER_AUTO_FAN_SPEED != 255 && DISABLED(FOURWIRES_FANS)
35 35
   bool FanCheck::measuring = false;
36 36
 #endif
37
-bool FanCheck::tacho_state[TACHO_COUNT];
37
+Flags<TACHO_COUNT> FanCheck::tacho_state;
38 38
 uint16_t FanCheck::edge_counter[TACHO_COUNT];
39 39
 uint8_t FanCheck::rps[TACHO_COUNT];
40 40
 FanCheck::TachoError FanCheck::error = FanCheck::TachoError::NONE;
@@ -103,7 +103,7 @@ void FanCheck::update_tachometers() {
103 103
 
104 104
     if (status != tacho_state[f]) {
105 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 View File

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

+ 6
- 6
Marlin/src/feature/fwretract.cpp View File

@@ -45,7 +45,7 @@ FWRetract fwretract; // Single instance - this calls the constructor
45 45
 // private:
46 46
 
47 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 49
 #endif
50 50
 
51 51
 // public:
@@ -56,7 +56,7 @@ fwretract_settings_t FWRetract::settings;             // M207 S F Z W, M208 S F
56 56
   bool FWRetract::autoretract_enabled;                // M209 S - Autoretract switch
57 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 61
 float FWRetract::current_retract[EXTRUDERS],          // Retract value used by planner
62 62
       FWRetract::current_hop;
@@ -73,9 +73,9 @@ void FWRetract::reset() {
73 73
   settings.swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
74 74
   current_hop = 0.0;
75 75
 
76
+  retracted.reset();
76 77
   EXTRUDER_LOOP() {
77
-    retracted[e] = false;
78
-    E_TERN_(retracted_swap[e] = false);
78
+    E_TERN_(retracted_swap.clear(e));
79 79
     current_retract[e] = 0.0;
80 80
   }
81 81
 }
@@ -173,11 +173,11 @@ void FWRetract::retract(const bool retracting E_OPTARG(bool swapping/*=false*/))
173 173
 
174 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 178
   // If swap retract/recover update the retracted_swap flag too
179 179
   #if HAS_MULTI_EXTRUDER
180
-    if (swapping) retracted_swap[active_extruder] = retracting;
180
+    if (swapping) retracted_swap.set(active_extruder, retracting);
181 181
   #endif
182 182
 
183 183
   /* // debugging

+ 3
- 5
Marlin/src/feature/fwretract.h View File

@@ -43,7 +43,7 @@ typedef struct {
43 43
 class FWRetract {
44 44
 private:
45 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 47
   #endif
48 48
 
49 49
 public:
@@ -55,7 +55,7 @@ public:
55 55
     static constexpr bool autoretract_enabled = false;
56 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 59
   static float current_retract[EXTRUDERS],         // Retract value used by planner
60 60
                current_hop;                        // Hop value used by planner
61 61
 
@@ -63,9 +63,7 @@ public:
63 63
 
64 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 68
   static void enable_autoretract(const bool enable) {
71 69
     #if ENABLED(FWRETRACT_AUTORETRACT)

+ 1
- 1
Marlin/src/feature/powerloss.cpp View File

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

+ 4
- 4
Marlin/src/gcode/control/M17_M18_M84.cpp View File

@@ -33,8 +33,8 @@
33 33
 #include "../../core/debug_out.h"
34 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 38
   #if HAS_EXTRUDERS
39 39
     if (parser.seen('E')) {
40 40
       if (E_TERN0(parser.has_value())) {
@@ -61,7 +61,7 @@ inline axis_flags_t selected_axis_bits() {
61 61
 }
62 62
 
63 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 65
   const ena_mask_t was_enabled = stepper.axis_enabled.bits,
66 66
                   shall_enable = to_enable.bits & ~was_enabled;
67 67
 
@@ -147,7 +147,7 @@ void GcodeSuite::M17() {
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 151
   ena_mask_t still_enabled = to_disable.bits & stepper.axis_enabled.bits;
152 152
 
153 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 View File

@@ -44,7 +44,7 @@
44 44
 #include "../../core/debug_out.h"
45 45
 
46 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 48
 static uint8_t tram_index = 0;
49 49
 static int8_t reference_index; // = 0
50 50
 
@@ -61,7 +61,10 @@ static bool probe_single_point() {
61 61
   move_to_tramming_wait_pos();
62 62
 
63 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 70
 static void _menu_single_probe() {
@@ -95,7 +98,7 @@ void goto_tramming_wizard() {
95 98
   ui.defer_status_screen();
96 99
 
97 100
   // Initialize measured point flags
98
-  ZERO(z_isvalid);
101
+  z_isvalid.reset();
99 102
   reference_index = -1;
100 103
 
101 104
   // Inject G28, wait for homing to complete,

+ 18
- 17
Marlin/src/module/settings.cpp View File

@@ -178,11 +178,12 @@
178 178
 #endif
179 179
 
180 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 188
 #undef _EN_ITEM
188 189
 
@@ -430,10 +431,10 @@ typedef struct SettingsDataStruct {
430 431
   //
431 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 440
   // LIN_ADVANCE
@@ -1220,7 +1221,7 @@ void MarlinSettings::postprocess() {
1220 1221
     {
1221 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 1226
       #if HAS_TRINAMIC_CONFIG
1226 1227
         #if AXIS_IS_TMC(X)
@@ -1300,7 +1301,7 @@ void MarlinSettings::postprocess() {
1300 1301
       _FIELD_TEST(tmc_hybrid_threshold);
1301 1302
 
1302 1303
       #if ENABLED(HYBRID_THRESHOLD)
1303
-        tmc_hybrid_threshold_t tmc_hybrid_threshold{0};
1304
+        per_stepper_uint32_t tmc_hybrid_threshold{0};
1304 1305
         TERN_(X_HAS_STEALTHCHOP,  tmc_hybrid_threshold.X =  stepperX.get_pwm_thrs());
1305 1306
         TERN_(Y_HAS_STEALTHCHOP,  tmc_hybrid_threshold.Y =  stepperY.get_pwm_thrs());
1306 1307
         TERN_(Z_HAS_STEALTHCHOP,  tmc_hybrid_threshold.Z =  stepperZ.get_pwm_thrs());
@@ -1325,7 +1326,7 @@ void MarlinSettings::postprocess() {
1325 1326
         TERN_(E7_HAS_STEALTHCHOP, tmc_hybrid_threshold.E7 = stepperE7.get_pwm_thrs());
1326 1327
       #else
1327 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 1330
           NUM_AXIS_LIST(.X = 100, .Y = 100, .Z = 3, .I = 3, .J = 3, .K = 3, .U = 3, .V = 3, .W = 3),
1330 1331
           .X2 = 100, .Y2 = 100, .Z2 = 3, .Z3 = 3, .Z4 = 3
1331 1332
           REPEAT(E_STEPPERS, _EN_ITEM)
@@ -1339,7 +1340,7 @@ void MarlinSettings::postprocess() {
1339 1340
     // TMC StallGuard threshold
1340 1341
     //
1341 1342
     {
1342
-      tmc_sgt_t tmc_sgt{0};
1343
+      mot_stepper_int16_t tmc_sgt{0};
1343 1344
       #if USE_SENSORLESS
1344 1345
         NUM_AXIS_CODE(
1345 1346
           TERN_(X_SENSORLESS, tmc_sgt.X = stepperX.homing_threshold()),
@@ -1367,7 +1368,7 @@ void MarlinSettings::postprocess() {
1367 1368
     {
1368 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 1372
       TERN_(X_HAS_STEALTHCHOP,  tmc_stealth_enabled.X  = stepperX.get_stored_stealthChop());
1372 1373
       TERN_(Y_HAS_STEALTHCHOP,  tmc_stealth_enabled.Y  = stepperY.get_stored_stealthChop());
1373 1374
       TERN_(Z_HAS_STEALTHCHOP,  tmc_stealth_enabled.Z  = stepperZ.get_stored_stealthChop());
@@ -2168,7 +2169,7 @@ void MarlinSettings::postprocess() {
2168 2169
       {
2169 2170
         _FIELD_TEST(tmc_stepper_current);
2170 2171
 
2171
-        tmc_stepper_current_t currents;
2172
+        per_stepper_uint16_t currents;
2172 2173
         EEPROM_READ(currents);
2173 2174
 
2174 2175
         #if HAS_TRINAMIC_CONFIG
@@ -2247,7 +2248,7 @@ void MarlinSettings::postprocess() {
2247 2248
 
2248 2249
       // TMC Hybrid Threshold
2249 2250
       {
2250
-        tmc_hybrid_threshold_t tmc_hybrid_threshold;
2251
+        per_stepper_uint32_t tmc_hybrid_threshold;
2251 2252
         _FIELD_TEST(tmc_hybrid_threshold);
2252 2253
         EEPROM_READ(tmc_hybrid_threshold);
2253 2254
 
@@ -2283,7 +2284,7 @@ void MarlinSettings::postprocess() {
2283 2284
       // TMC StallGuard threshold.
2284 2285
       //
2285 2286
       {
2286
-        tmc_sgt_t tmc_sgt;
2287
+        mot_stepper_int16_t tmc_sgt;
2287 2288
         _FIELD_TEST(tmc_sgt);
2288 2289
         EEPROM_READ(tmc_sgt);
2289 2290
         #if USE_SENSORLESS
@@ -2312,7 +2313,7 @@ void MarlinSettings::postprocess() {
2312 2313
       {
2313 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 2317
         EEPROM_READ(tmc_stealth_enabled);
2317 2318
 
2318 2319
         #if HAS_TRINAMIC_CONFIG

+ 1
- 1
Marlin/src/module/stepper.cpp View File

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

+ 2
- 2
Marlin/src/module/stepper.h View File

@@ -261,7 +261,7 @@ typedef struct {
261 261
   };
262 262
   constexpr ena_mask_t linear_bits() { return _BV(NUM_AXES) - 1; }
263 263
   constexpr ena_mask_t e_bits() { return (_BV(EXTRUDERS) - 1) << NUM_AXES; }
264
-} axis_flags_t;
264
+} stepper_flags_t;
265 265
 
266 266
 // All the stepper enable pins
267 267
 constexpr pin_t ena_pins[] = {
@@ -596,7 +596,7 @@ class Stepper {
596 596
       static void refresh_motor_power();
597 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 601
     static bool axis_is_enabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) {
602 602
       return TEST(axis_enabled.bits, INDEX_OF_AXIS(axis, eindex));

+ 4
- 4
Marlin/src/module/temperature.cpp View File

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

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

+ 1
- 1
Marlin/src/module/tool_change.h View File

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

Loading…
Cancel
Save