Przeglądaj źródła

Fix mixing with "unload all" compile

Scott Lahteine 5 lat temu
rodzic
commit
87875e0de8

+ 7
- 20
Marlin/src/feature/fwretract.cpp Wyświetl plik

@@ -95,7 +95,7 @@ void FWRetract::reset() {
95 95
  */
96 96
 void FWRetract::retract(const bool retracting
97 97
   #if EXTRUDERS > 1
98
-    , bool swapping /* =false */
98
+    , bool swapping/*=false*/
99 99
   #endif
100 100
 ) {
101 101
   // Prevent two retracts or recovers in a row
@@ -128,12 +128,8 @@ void FWRetract::retract(const bool retracting
128 128
     SERIAL_ECHOLNPAIR("current_hop ", current_hop);
129 129
   //*/
130 130
 
131
-  const float base_retract = (
132
-                (swapping ? settings.swap_retract_length : settings.retract_length)
133
-                #if ENABLED(RETRACT_SYNC_MIXING)
134
-                  * (MIXING_STEPPERS)
135
-                #endif
136
-              );
131
+  const float base_retract = TERN(RETRACT_SYNC_MIXING, MIXING_STEPPERS, 1)
132
+                * (swapping ? settings.swap_retract_length : settings.retract_length);
137 133
 
138 134
   // The current position will be the destination for E and Z moves
139 135
   destination = current_position;
@@ -148,10 +144,7 @@ void FWRetract::retract(const bool retracting
148 144
     // Retract by moving from a faux E position back to the current E position
149 145
     current_retract[active_extruder] = base_retract;
150 146
     prepare_internal_move_to_destination(                 // set current to destination
151
-      settings.retract_feedrate_mm_s
152
-      #if ENABLED(RETRACT_SYNC_MIXING)
153
-        * (MIXING_STEPPERS)
154
-      #endif
147
+      settings.retract_feedrate_mm_s * TERN(RETRACT_SYNC_MIXING, MIXING_STEPPERS, 1)
155 148
     );
156 149
 
157 150
     // Is a Z hop set, and has the hop not yet been done?
@@ -177,18 +170,12 @@ void FWRetract::retract(const bool retracting
177 170
 
178 171
     current_retract[active_extruder] = 0;
179 172
 
180
-    const feedRate_t fr_mm_s = (
181
-      (swapping ? settings.swap_retract_recover_feedrate_mm_s : settings.retract_recover_feedrate_mm_s)
182
-      #if ENABLED(RETRACT_SYNC_MIXING)
183
-        * (MIXING_STEPPERS)
184
-      #endif
185
-    );
173
+    const feedRate_t fr_mm_s = TERN(RETRACT_SYNC_MIXING, MIXING_STEPPERS, 1)
174
+      * (swapping ? settings.swap_retract_recover_feedrate_mm_s : settings.retract_recover_feedrate_mm_s);
186 175
     prepare_internal_move_to_destination(fr_mm_s);        // Recover E, set_current_to_destination
187 176
   }
188 177
 
189
-  #if ENABLED(RETRACT_SYNC_MIXING)
190
-    mixer.T(old_mixing_tool);                             // Restore original mixing tool
191
-  #endif
178
+  TERN_(RETRACT_SYNC_MIXING, mixer.T(old_mixing_tool));   // Restore original mixing tool
192 179
 
193 180
   retracted[active_extruder] = retracting;                // Active extruder now retracted / recovered
194 181
 

+ 1
- 1
Marlin/src/feature/mixing.cpp Wyświetl plik

@@ -115,7 +115,7 @@ void Mixer::init() {
115 115
 
116 116
   reset_vtools();
117 117
 
118
-  #if ENABLED(RETRACT_SYNC_MIXING)
118
+  #if HAS_MIXER_SYNC_CHANNEL
119 119
     // AUTORETRACT_TOOL gets the same amount of all filaments
120 120
     MIXER_STEPPER_LOOP(i)
121 121
       color[MIXER_AUTORETRACT_TOOL][i] = COLOR_A_MASK;

+ 3
- 9
Marlin/src/feature/mixing.h Wyświetl plik

@@ -52,25 +52,19 @@ enum MixTool {
52 52
   LAST_USER_VIRTUAL_TOOL = MIXING_VIRTUAL_TOOLS - 1,
53 53
   NR_USER_VIRTUAL_TOOLS,
54 54
   MIXER_DIRECT_SET_TOOL = NR_USER_VIRTUAL_TOOLS,
55
-  #if ENABLED(RETRACT_SYNC_MIXING)
55
+  #if HAS_MIXER_SYNC_CHANNEL
56 56
     MIXER_AUTORETRACT_TOOL,
57 57
   #endif
58 58
   NR_MIXING_VIRTUAL_TOOLS
59 59
 };
60 60
 
61
-#if ENABLED(RETRACT_SYNC_MIXING)
62
-  #define MAX_VTOOLS 254
63
-#else
64
-  #define MAX_VTOOLS 255
65
-#endif
61
+#define MAX_VTOOLS TERN(HAS_MIXER_SYNC_CHANNEL, 254, 255)
66 62
 static_assert(NR_MIXING_VIRTUAL_TOOLS <= MAX_VTOOLS, "MIXING_VIRTUAL_TOOLS must be <= " STRINGIFY(MAX_VTOOLS) "!");
67 63
 
68
-#define MIXER_STEPPER_LOOP(VAR) \
69
-  for (uint_fast8_t VAR = 0; VAR < MIXING_STEPPERS; VAR++)
70
-
71 64
 #define MIXER_BLOCK_FIELD       mixer_comp_t b_color[MIXING_STEPPERS]
72 65
 #define MIXER_POPULATE_BLOCK()  mixer.populate_block(block->b_color)
73 66
 #define MIXER_STEPPER_SETUP()   mixer.stepper_setup(current_block->b_color)
67
+#define MIXER_STEPPER_LOOP(VAR) for (uint_fast8_t VAR = 0; VAR < MIXING_STEPPERS; VAR++)
74 68
 
75 69
 #if ENABLED(GRADIENT_MIX)
76 70
 

+ 6
- 4
Marlin/src/gcode/feature/pause/M701_M702.cpp Wyświetl plik

@@ -163,16 +163,18 @@ void GcodeSuite::M702() {
163 163
 
164 164
     #if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
165 165
       float mix_multiplier = 1.0;
166
-      if (!parser.seenval('T')) {
166
+      const bool seenT = parser.seenval('T');
167
+      if (!seenT) {
167 168
         mixer.T(MIXER_AUTORETRACT_TOOL);
168 169
         mix_multiplier = MIXING_STEPPERS;
169 170
       }
170
-      else
171
+    #else
172
+      constexpr bool seenT = true;
171 173
     #endif
172
-    {
174
+
175
+    if (seenT) {
173 176
       const int8_t target_e_stepper = get_target_e_stepper_from_command();
174 177
       if (target_e_stepper < 0) return;
175
-
176 178
       mixer.T(MIXER_DIRECT_SET_TOOL);
177 179
       MIXER_STEPPER_LOOP(i) mixer.set_collector(i, (i == (uint8_t)target_e_stepper) ? 1.0 : 0.0);
178 180
       mixer.normalize();

+ 4
- 0
Marlin/src/inc/Conditionals_adv.h Wyświetl plik

@@ -56,6 +56,10 @@
56 56
   #undef SHOW_TEMP_ADC_VALUES
57 57
 #endif
58 58
 
59
+#if ENABLED(MIXING_EXTRUDER) && (ENABLED(RETRACT_SYNC_MIXING) || BOTH(FILAMENT_LOAD_UNLOAD_GCODES, FILAMENT_UNLOAD_ALL_EXTRUDERS))
60
+  #define HAS_MIXER_SYNC_CHANNEL 1
61
+#endif
62
+
59 63
 #if EITHER(DUAL_X_CARRIAGE, MULTI_NOZZLE_DUPLICATION)
60 64
   #define HAS_DUPLICATION_MODE 1
61 65
 #endif

+ 3
- 6
Marlin/src/module/planner.cpp Wyświetl plik

@@ -2133,17 +2133,14 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2133 2133
   #if EXTRUDERS
2134 2134
     {
2135 2135
       current_speed.e = steps_dist_mm.e * inverse_secs;
2136
-      #if BOTH(MIXING_EXTRUDER, RETRACT_SYNC_MIXING)
2136
+      #if HAS_MIXER_SYNC_CHANNEL
2137 2137
         // Move all mixing extruders at the specified rate
2138 2138
         if (mixer.get_current_vtool() == MIXER_AUTORETRACT_TOOL)
2139 2139
           current_speed.e *= MIXING_STEPPERS;
2140 2140
       #endif
2141 2141
       const feedRate_t cs = ABS(current_speed.e),
2142
-                   max_fr = (settings.max_feedrate_mm_s[E_AXIS_N(extruder)]
2143
-                              #if BOTH(MIXING_EXTRUDER, RETRACT_SYNC_MIXING)
2144
-                                * MIXING_STEPPERS
2145
-                              #endif
2146
-                            );
2142
+                   max_fr = settings.max_feedrate_mm_s[E_AXIS_N(extruder)]
2143
+                            * TERN(HAS_MIXER_SYNC_CHANNEL, MIXING_STEPPERS, 1);
2147 2144
       if (cs > max_fr) NOMORE(speed_factor, max_fr / cs);
2148 2145
     }
2149 2146
   #endif

Ładowanie…
Anuluj
Zapisz