Fix mixing extruder filament change (#13803)
This commit is contained in:
committed by
Scott Lahteine
parent
bf54251a10
commit
ee243e4edf
@ -132,7 +132,7 @@ void Mixer::init() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=selected_vtool*/) {
|
||||
void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=selected_vtool*/, float (&c)[MIXING_STEPPERS]/*=collector*/) {
|
||||
float csum = 0, cmax = 0;
|
||||
MIXER_STEPPER_LOOP(i) {
|
||||
const float v = color[t][i];
|
||||
@ -142,8 +142,8 @@ void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=
|
||||
//SERIAL_ECHOPAIR("Mixer::refresh_collector(", proportion, ", ", int(t), ") cmax=", cmax, " csum=", csum, " color");
|
||||
const float inv_prop = proportion / csum;
|
||||
MIXER_STEPPER_LOOP(i) {
|
||||
collector[i] = color[t][i] * inv_prop;
|
||||
//SERIAL_ECHOPAIR(" [", int(t), "][", int(i), "] = ", int(color[t][i]), " (", collector[i], ") ");
|
||||
c[i] = color[t][i] * inv_prop;
|
||||
//SERIAL_ECHOPAIR(" [", int(t), "][", int(i), "] = ", int(color[t][i]), " (", c[i], ") ");
|
||||
}
|
||||
//SERIAL_EOL();
|
||||
}
|
||||
|
@ -51,19 +51,19 @@ enum MixTool {
|
||||
FIRST_USER_VIRTUAL_TOOL = 0,
|
||||
LAST_USER_VIRTUAL_TOOL = MIXING_VIRTUAL_TOOLS - 1,
|
||||
NR_USER_VIRTUAL_TOOLS,
|
||||
#ifdef RETRACT_SYNC_MIXING
|
||||
MIXER_AUTORETRACT_TOOL = NR_USER_VIRTUAL_TOOLS,
|
||||
NR_MIXING_VIRTUAL_TOOLS
|
||||
#else
|
||||
NR_MIXING_VIRTUAL_TOOLS = NR_USER_VIRTUAL_TOOLS
|
||||
MIXER_DIRECT_SET_TOOL = NR_USER_VIRTUAL_TOOLS,
|
||||
#if ENABLED(RETRACT_SYNC_MIXING)
|
||||
MIXER_AUTORETRACT_TOOL,
|
||||
#endif
|
||||
NR_MIXING_VIRTUAL_TOOLS
|
||||
};
|
||||
|
||||
#ifdef RETRACT_SYNC_MIXING
|
||||
static_assert(NR_MIXING_VIRTUAL_TOOLS <= 254, "MIXING_VIRTUAL_TOOLS must be <= 254!");
|
||||
#if ENABLED(RETRACT_SYNC_MIXING)
|
||||
#define MAX_VTOOLS 254
|
||||
#else
|
||||
static_assert(NR_MIXING_VIRTUAL_TOOLS <= 255, "MIXING_VIRTUAL_TOOLS must be <= 255!");
|
||||
#define MAX_VTOOLS 255
|
||||
#endif
|
||||
static_assert(NR_MIXING_VIRTUAL_TOOLS <= MAX_VTOOLS, "MIXING_VIRTUAL_TOOLS must be <= " STRINGIFY(MAX_VTOOLS) "!");
|
||||
|
||||
#define MIXER_STEPPER_LOOP(VAR) \
|
||||
for (uint_fast8_t VAR = 0; VAR < MIXING_STEPPERS; VAR++)
|
||||
@ -100,7 +100,7 @@ class Mixer {
|
||||
static void init(); // Populate colors at boot time
|
||||
|
||||
static void reset_vtools();
|
||||
static void refresh_collector(const float proportion=1.0, const uint8_t t=selected_vtool);
|
||||
static void refresh_collector(const float proportion=1.0, const uint8_t t=selected_vtool, float (&c)[MIXING_STEPPERS]=collector);
|
||||
|
||||
// Used up to Planner level
|
||||
FORCE_INLINE static void set_collector(const uint8_t c, const float f) { collector[c] = MAX(f, 0.0f); }
|
||||
|
@ -302,16 +302,22 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
|
||||
*/
|
||||
bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
|
||||
const PauseMode mode/*=PAUSE_MODE_PAUSE_PRINT*/
|
||||
#if BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
|
||||
, const float &mix_multiplier/*=1.0*/
|
||||
#endif
|
||||
) {
|
||||
#if !HAS_LCD_MENU
|
||||
UNUSED(show_lcd);
|
||||
#endif
|
||||
|
||||
#if !BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
|
||||
constexpr float mix_multiplier = 1.0;
|
||||
#endif
|
||||
|
||||
if (!ensure_safe_temperature(mode)) {
|
||||
#if HAS_LCD_MENU
|
||||
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -320,13 +326,14 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
|
||||
#endif
|
||||
|
||||
// Retract filament
|
||||
do_pause_e_move(-FILAMENT_UNLOAD_RETRACT_LENGTH, PAUSE_PARK_RETRACT_FEEDRATE);
|
||||
do_pause_e_move(-(FILAMENT_UNLOAD_RETRACT_LENGTH) * mix_multiplier, (PAUSE_PARK_RETRACT_FEEDRATE) * mix_multiplier);
|
||||
|
||||
// Wait for filament to cool
|
||||
safe_delay(FILAMENT_UNLOAD_DELAY);
|
||||
|
||||
// Quickly purge
|
||||
do_pause_e_move(FILAMENT_UNLOAD_RETRACT_LENGTH + FILAMENT_UNLOAD_PURGE_LENGTH, planner.settings.max_feedrate_mm_s[E_AXIS]);
|
||||
do_pause_e_move((FILAMENT_UNLOAD_RETRACT_LENGTH + FILAMENT_UNLOAD_PURGE_LENGTH) * mix_multiplier,
|
||||
planner.settings.max_feedrate_mm_s[E_AXIS] * mix_multiplier);
|
||||
|
||||
// Unload filament
|
||||
#if FILAMENT_CHANGE_UNLOAD_ACCEL > 0
|
||||
@ -334,7 +341,7 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
|
||||
planner.settings.retract_acceleration = FILAMENT_CHANGE_UNLOAD_ACCEL;
|
||||
#endif
|
||||
|
||||
do_pause_e_move(unload_length, FILAMENT_CHANGE_UNLOAD_FEEDRATE);
|
||||
do_pause_e_move(unload_length * mix_multiplier, (FILAMENT_CHANGE_UNLOAD_FEEDRATE) * mix_multiplier);
|
||||
|
||||
#if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
|
||||
planner.settings.retract_acceleration = saved_acceleration;
|
||||
|
@ -92,6 +92,10 @@ void resume_print(const float &slow_load_length=0, const float &fast_load_length
|
||||
bool load_filament(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=0, const int8_t max_beep_count=0, const bool show_lcd=false,
|
||||
const bool pause_for_user=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT DXC_PARAMS);
|
||||
|
||||
bool unload_filament(const float &unload_length, const bool show_lcd=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT);
|
||||
bool unload_filament(const float &unload_length, const bool show_lcd=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT
|
||||
#if BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
|
||||
, const float &mix_multiplier=1.0
|
||||
#endif
|
||||
);
|
||||
|
||||
#endif // ADVANCED_PAUSE_FEATURE
|
||||
|
Reference in New Issue
Block a user