Merge pull request #6042 from thinkyhead/rc_fix_toolchange_z
Move Z last in tool-change for SWITCHING_EXTRUDER
This commit is contained in:
commit
9b2b53f63a
2 changed files with 17 additions and 17 deletions
|
@ -7851,6 +7851,7 @@ inline void gcode_M999() {
|
|||
inline void move_extruder_servo(uint8_t e) {
|
||||
const int angles[2] = SWITCHING_EXTRUDER_SERVO_ANGLES;
|
||||
MOVE_SERVO(SWITCHING_EXTRUDER_SERVO_NR, angles[e]);
|
||||
delay(500);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -7997,25 +7998,15 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
|||
|
||||
#if ENABLED(SWITCHING_EXTRUDER)
|
||||
// <0 if the new nozzle is higher, >0 if lower. A bigger raise when lower.
|
||||
float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder],
|
||||
z_raise = 0.3 + (z_diff > 0.0 ? z_diff : 0.0);
|
||||
const float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder],
|
||||
z_raise = 0.3 + (z_diff > 0.0 ? z_diff : 0.0);
|
||||
|
||||
// Always raise by some amount (destination copied from current_position earlier)
|
||||
float save_Z = destination[Z_AXIS]; // save Z for later on
|
||||
destination[Z_AXIS] += z_raise;
|
||||
planner.buffer_line_kinematic(destination, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
||||
current_position[Z_AXIS] += z_raise;
|
||||
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
||||
stepper.synchronize();
|
||||
|
||||
move_extruder_servo(active_extruder);
|
||||
delay(500);
|
||||
|
||||
// Move back down, if needed
|
||||
if (z_raise != z_diff) {
|
||||
destination[Z_AXIS] = current_position[Z_AXIS] + z_diff;
|
||||
planner.buffer_line_kinematic(destination, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
||||
stepper.synchronize();
|
||||
}
|
||||
destination[Z_AXIS] = save_Z; // restore original Z position so the 'Move to the "old position"' is correct
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -8066,12 +8057,12 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
|||
#endif
|
||||
|
||||
// Adjustments to the current position
|
||||
float xydiff[2] = { offset_vec.x, offset_vec.y };
|
||||
const float xydiff[2] = { offset_vec.x, offset_vec.y };
|
||||
current_position[Z_AXIS] += offset_vec.z;
|
||||
|
||||
#else // !ABL_PLANAR
|
||||
|
||||
float xydiff[2] = {
|
||||
const float xydiff[2] = {
|
||||
hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
|
||||
hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder]
|
||||
};
|
||||
|
@ -8138,6 +8129,15 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
|||
prepare_move_to_destination();
|
||||
}
|
||||
|
||||
#if ENABLED(SWITCHING_EXTRUDER)
|
||||
// Move back down, if needed. (Including when the new tool is higher.)
|
||||
if (z_raise != z_diff) {
|
||||
destination[Z_AXIS] += z_diff;
|
||||
feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS];
|
||||
prepare_move_to_destination();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // (tmp_extruder != active_extruder)
|
||||
|
||||
stepper.synchronize();
|
||||
|
|
|
@ -435,7 +435,7 @@ uint16_t max_display_update_time = 0;
|
|||
}
|
||||
else if (screen == lcd_status_screen && currentScreen == lcd_main_menu && PENDING(millis(), doubleclick_expire_ms))
|
||||
screen = lcd_babystep_z;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
currentScreen = screen;
|
||||
encoderPosition = encoder;
|
||||
|
|
Reference in a new issue