Browse Source

Fix mixing with "unload all" compile

Scott Lahteine 5 years ago
parent
commit
87875e0de8

+ 7
- 20
Marlin/src/feature/fwretract.cpp View File

95
  */
95
  */
96
 void FWRetract::retract(const bool retracting
96
 void FWRetract::retract(const bool retracting
97
   #if EXTRUDERS > 1
97
   #if EXTRUDERS > 1
98
-    , bool swapping /* =false */
98
+    , bool swapping/*=false*/
99
   #endif
99
   #endif
100
 ) {
100
 ) {
101
   // Prevent two retracts or recovers in a row
101
   // Prevent two retracts or recovers in a row
128
     SERIAL_ECHOLNPAIR("current_hop ", current_hop);
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
   // The current position will be the destination for E and Z moves
134
   // The current position will be the destination for E and Z moves
139
   destination = current_position;
135
   destination = current_position;
148
     // Retract by moving from a faux E position back to the current E position
144
     // Retract by moving from a faux E position back to the current E position
149
     current_retract[active_extruder] = base_retract;
145
     current_retract[active_extruder] = base_retract;
150
     prepare_internal_move_to_destination(                 // set current to destination
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
     // Is a Z hop set, and has the hop not yet been done?
150
     // Is a Z hop set, and has the hop not yet been done?
177
 
170
 
178
     current_retract[active_extruder] = 0;
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
     prepare_internal_move_to_destination(fr_mm_s);        // Recover E, set_current_to_destination
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
   retracted[active_extruder] = retracting;                // Active extruder now retracted / recovered
180
   retracted[active_extruder] = retracting;                // Active extruder now retracted / recovered
194
 
181
 

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

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

+ 3
- 9
Marlin/src/feature/mixing.h View File

52
   LAST_USER_VIRTUAL_TOOL = MIXING_VIRTUAL_TOOLS - 1,
52
   LAST_USER_VIRTUAL_TOOL = MIXING_VIRTUAL_TOOLS - 1,
53
   NR_USER_VIRTUAL_TOOLS,
53
   NR_USER_VIRTUAL_TOOLS,
54
   MIXER_DIRECT_SET_TOOL = NR_USER_VIRTUAL_TOOLS,
54
   MIXER_DIRECT_SET_TOOL = NR_USER_VIRTUAL_TOOLS,
55
-  #if ENABLED(RETRACT_SYNC_MIXING)
55
+  #if HAS_MIXER_SYNC_CHANNEL
56
     MIXER_AUTORETRACT_TOOL,
56
     MIXER_AUTORETRACT_TOOL,
57
   #endif
57
   #endif
58
   NR_MIXING_VIRTUAL_TOOLS
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
 static_assert(NR_MIXING_VIRTUAL_TOOLS <= MAX_VTOOLS, "MIXING_VIRTUAL_TOOLS must be <= " STRINGIFY(MAX_VTOOLS) "!");
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
 #define MIXER_BLOCK_FIELD       mixer_comp_t b_color[MIXING_STEPPERS]
64
 #define MIXER_BLOCK_FIELD       mixer_comp_t b_color[MIXING_STEPPERS]
72
 #define MIXER_POPULATE_BLOCK()  mixer.populate_block(block->b_color)
65
 #define MIXER_POPULATE_BLOCK()  mixer.populate_block(block->b_color)
73
 #define MIXER_STEPPER_SETUP()   mixer.stepper_setup(current_block->b_color)
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
 #if ENABLED(GRADIENT_MIX)
69
 #if ENABLED(GRADIENT_MIX)
76
 
70
 

+ 6
- 4
Marlin/src/gcode/feature/pause/M701_M702.cpp View File

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

+ 4
- 0
Marlin/src/inc/Conditionals_adv.h View File

56
   #undef SHOW_TEMP_ADC_VALUES
56
   #undef SHOW_TEMP_ADC_VALUES
57
 #endif
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
 #if EITHER(DUAL_X_CARRIAGE, MULTI_NOZZLE_DUPLICATION)
63
 #if EITHER(DUAL_X_CARRIAGE, MULTI_NOZZLE_DUPLICATION)
60
   #define HAS_DUPLICATION_MODE 1
64
   #define HAS_DUPLICATION_MODE 1
61
 #endif
65
 #endif

+ 3
- 6
Marlin/src/module/planner.cpp View File

2133
   #if EXTRUDERS
2133
   #if EXTRUDERS
2134
     {
2134
     {
2135
       current_speed.e = steps_dist_mm.e * inverse_secs;
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
         // Move all mixing extruders at the specified rate
2137
         // Move all mixing extruders at the specified rate
2138
         if (mixer.get_current_vtool() == MIXER_AUTORETRACT_TOOL)
2138
         if (mixer.get_current_vtool() == MIXER_AUTORETRACT_TOOL)
2139
           current_speed.e *= MIXING_STEPPERS;
2139
           current_speed.e *= MIXING_STEPPERS;
2140
       #endif
2140
       #endif
2141
       const feedRate_t cs = ABS(current_speed.e),
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
       if (cs > max_fr) NOMORE(speed_factor, max_fr / cs);
2144
       if (cs > max_fr) NOMORE(speed_factor, max_fr / cs);
2148
     }
2145
     }
2149
   #endif
2146
   #endif

Loading…
Cancel
Save