[2.0.x] Fix Dual X Carriage tool change crash (#11447)

This commit is contained in:
Scott Lahteine
2018-08-03 20:47:29 -05:00
committed by GitHub
parent 9bae413901
commit 9c62c47579
55 changed files with 139 additions and 9 deletions

View File

@ -1483,7 +1483,7 @@ void homeaxis(const AxisEnum axis) {
if (axis == X_AXIS) {
// In Dual X mode hotend_offset[X] is T1's home position
float dual_max_x = MAX(hotend_offset[X_AXIS][1], X2_MAX_POS);
const float dual_max_x = MAX(hotend_offset[X_AXIS][1], X2_MAX_POS);
if (active_extruder != 0) {
// T1 can move from X2_MIN_POS to X2_MAX_POS or X2 home position (whichever is larger)

View File

@ -377,9 +377,6 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
#endif
}
// Save current position to destination, for use later
set_destination_from_current();
#if HAS_LEVELING
// Set current position to the physical position
const bool leveling_was_active = planner.leveling_active;
@ -388,10 +385,23 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
#if ENABLED(DUAL_X_CARRIAGE)
#if HAS_SOFTWARE_ENDSTOPS
// Update the X software endstops early
active_extruder = tmp_extruder;
update_software_endstops(X_AXIS);
active_extruder = !tmp_extruder;
#endif
// Don't move the new extruder out of bounds
if (!WITHIN(current_position[X_AXIS], soft_endstop_min[X_AXIS], soft_endstop_max[X_AXIS]))
no_move = true;
if (!no_move) set_destination_from_current();
dualx_tool_change(tmp_extruder, no_move); // Can modify no_move
#else // !DUAL_X_CARRIAGE
set_destination_from_current();
#if ENABLED(PARKING_EXTRUDER) // Dual Parking extruder
parking_extruder_tool_change(tmp_extruder, no_move);
#endif
@ -424,16 +434,16 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
#endif // !DUAL_X_CARRIAGE
#if HAS_LEVELING
// Restore leveling to re-establish the logical position
set_bed_leveling_enabled(leveling_was_active);
#endif
#if ENABLED(SWITCHING_NOZZLE)
// The newly-selected extruder Z is actually at...
current_position[Z_AXIS] -= zdiff;
#endif
#if HAS_LEVELING
// Restore leveling to re-establish the logical position
set_bed_leveling_enabled(leveling_was_active);
#endif
// Tell the planner the new "current position"
SYNC_PLAN_POSITION_KINEMATIC();
@ -477,6 +487,10 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
feedrate_mm_s = old_feedrate_mm_s;
#if HAS_SOFTWARE_ENDSTOPS && ENABLED(DUAL_X_CARRIAGE)
update_software_endstops(X_AXIS);
#endif
#else // HOTENDS <= 1
UNUSED(fr_mm_s);