Fix mixing extruder filament change (#13803)

This commit is contained in:
Thomas Moore
2019-05-01 22:55:58 -04:00
committed by Scott Lahteine
parent bf54251a10
commit ee243e4edf
15 changed files with 182 additions and 52 deletions

View File

@@ -982,9 +982,21 @@ void prepare_move_to_destination() {
}
#endif // PREVENT_COLD_EXTRUSION
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
if (ABS(destination[E_AXIS] - current_position[E_AXIS]) * planner.e_factor[active_extruder] > (EXTRUDE_MAXLENGTH)) {
current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
SERIAL_ECHO_MSG(MSG_ERR_LONG_EXTRUDE_STOP);
const float e_delta = ABS(destination[E_AXIS] - current_position[E_AXIS]) * planner.e_factor[active_extruder];
if (e_delta > (EXTRUDE_MAXLENGTH)) {
#if ENABLED(MIXING_EXTRUDER)
bool ignore_e = false;
float collector[MIXING_STEPPERS];
mixer.refresh_collector(1.0, mixer.get_current_vtool(), collector);
MIXER_STEPPER_LOOP(e)
if (e_delta * collector[e] > (EXTRUDE_MAXLENGTH)) { ignore_e = true; break; }
#else
constexpr bool ignore_e = true;
#endif
if (ignore_e) {
current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
SERIAL_ECHO_MSG(MSG_ERR_LONG_EXTRUDE_STOP);
}
}
#endif // PREVENT_LENGTHY_EXTRUDE
}

View File

@@ -1767,13 +1767,26 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
}
#endif // PREVENT_COLD_EXTRUSION
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
if (ABS(de * e_factor[extruder]) > (int32_t)settings.axis_steps_per_mm[E_AXIS_N(extruder)] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
#if HAS_POSITION_FLOAT
position_float[E_AXIS] = target_float[E_AXIS];
const float e_steps = ABS(de * e_factor[extruder]);
const float max_e_steps = settings.axis_steps_per_mm[E_AXIS_N(extruder)] * (EXTRUDE_MAXLENGTH);
if (e_steps > max_e_steps) {
#if ENABLED(MIXING_EXTRUDER)
bool ignore_e = false;
float collector[MIXING_STEPPERS];
mixer.refresh_collector(1.0, mixer.get_current_vtool(), collector);
MIXER_STEPPER_LOOP(e)
if (e_steps * collector[e] > max_e_steps) { ignore_e = true; break; }
#else
constexpr bool ignore_e = true;
#endif
de = 0; // no difference
SERIAL_ECHO_MSG(MSG_ERR_LONG_EXTRUDE_STOP);
if (ignore_e) {
position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
#if HAS_POSITION_FLOAT
position_float[E_AXIS] = target_float[E_AXIS];
#endif
de = 0; // no difference
SERIAL_ECHO_MSG(MSG_ERR_LONG_EXTRUDE_STOP);
}
}
#endif // PREVENT_LENGTHY_EXTRUDE
}

View File

@@ -2825,6 +2825,7 @@ void Temperature::isr() {
) {
#if TEMP_BED_RESIDENCY_TIME > 0
millis_t residency_start_ms = 0;
bool first_loop = true;
// Loop until the temperature has stabilized
#define TEMP_BED_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_BED_RESIDENCY_TIME) * 1000UL))
#else
@@ -2833,7 +2834,7 @@ void Temperature::isr() {
#endif
float target_temp = -1, old_temp = 9999;
bool wants_to_cool = false, first_loop = true;
bool wants_to_cool = false;
wait_for_heatup = true;
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
@@ -2917,7 +2918,9 @@ void Temperature::isr() {
}
#endif
first_loop = false;
#if TEMP_BED_RESIDENCY_TIME > 0
first_loop = false;
#endif
} while (wait_for_heatup && TEMP_BED_CONDITIONS);