Merge pull request #948 from Dim3nsioneer/Marlin_v1
Implementation of FW extruder change retract
This commit is contained in:
@ -243,11 +243,29 @@ int EtoPPressure=0;
|
||||
|
||||
#ifdef FWRETRACT
|
||||
bool autoretract_enabled=false;
|
||||
bool retracted=false;
|
||||
bool retracted[EXTRUDERS]={false
|
||||
#if EXTRUDERS > 1
|
||||
, false
|
||||
#if EXTRUDERS > 2
|
||||
, false
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
bool retracted_swap[EXTRUDERS]={false
|
||||
#if EXTRUDERS > 1
|
||||
, false
|
||||
#if EXTRUDERS > 2
|
||||
, false
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
float retract_length = RETRACT_LENGTH;
|
||||
float retract_length_swap = RETRACT_LENGTH_SWAP;
|
||||
float retract_feedrate = RETRACT_FEEDRATE;
|
||||
float retract_zlift = RETRACT_ZLIFT;
|
||||
float retract_recover_length = RETRACT_RECOVER_LENGTH;
|
||||
float retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
|
||||
float retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
|
||||
#endif
|
||||
|
||||
@ -1119,23 +1137,27 @@ void refresh_cmd_timeout(void)
|
||||
}
|
||||
|
||||
#ifdef FWRETRACT
|
||||
void retract(bool retracting) {
|
||||
if(retracting && !retracted) {
|
||||
void retract(bool retracting, bool swapretract = false) {
|
||||
if(retracting && !retracted[active_extruder]) {
|
||||
destination[X_AXIS]=current_position[X_AXIS];
|
||||
destination[Y_AXIS]=current_position[Y_AXIS];
|
||||
destination[Z_AXIS]=current_position[Z_AXIS];
|
||||
destination[E_AXIS]=current_position[E_AXIS];
|
||||
current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
|
||||
if (swapretract) {
|
||||
current_position[E_AXIS]+=retract_length_swap/volumetric_multiplier[active_extruder];
|
||||
} else {
|
||||
current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
|
||||
}
|
||||
plan_set_e_position(current_position[E_AXIS]);
|
||||
float oldFeedrate = feedrate;
|
||||
feedrate=retract_feedrate*60;
|
||||
retracted=true;
|
||||
retracted[active_extruder]=true;
|
||||
prepare_move();
|
||||
current_position[Z_AXIS]-=retract_zlift;
|
||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
prepare_move();
|
||||
feedrate = oldFeedrate;
|
||||
} else if(!retracting && retracted) {
|
||||
} else if(!retracting && retracted[active_extruder]) {
|
||||
destination[X_AXIS]=current_position[X_AXIS];
|
||||
destination[Y_AXIS]=current_position[Y_AXIS];
|
||||
destination[Z_AXIS]=current_position[Z_AXIS];
|
||||
@ -1143,11 +1165,15 @@ void refresh_cmd_timeout(void)
|
||||
current_position[Z_AXIS]+=retract_zlift;
|
||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
//prepare_move();
|
||||
current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder];
|
||||
if (swapretract) {
|
||||
current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder];
|
||||
} else {
|
||||
current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder];
|
||||
}
|
||||
plan_set_e_position(current_position[E_AXIS]);
|
||||
float oldFeedrate = feedrate;
|
||||
feedrate=retract_recover_feedrate*60;
|
||||
retracted=false;
|
||||
retracted[active_extruder]=false;
|
||||
prepare_move();
|
||||
feedrate = oldFeedrate;
|
||||
}
|
||||
@ -1217,10 +1243,19 @@ void process_commands()
|
||||
break;
|
||||
#ifdef FWRETRACT
|
||||
case 10: // G10 retract
|
||||
#if EXTRUDERS > 1
|
||||
retracted_swap[active_extruder]=(code_seen('S') && code_value_long() == 1); // checks for swap retract argument
|
||||
retract(true,retracted_swap[active_extruder]);
|
||||
#else
|
||||
retract(true);
|
||||
#endif
|
||||
break;
|
||||
case 11: // G11 retract_recover
|
||||
#if EXTRUDERS > 1
|
||||
retract(false,retracted_swap[active_extruder]);
|
||||
#else
|
||||
retract(false);
|
||||
#endif
|
||||
break;
|
||||
#endif //FWRETRACT
|
||||
case 28: //G28 Home all Axis one at a time
|
||||
@ -2396,8 +2431,28 @@ void process_commands()
|
||||
int t= code_value() ;
|
||||
switch(t)
|
||||
{
|
||||
case 0: autoretract_enabled=false;retracted=false;break;
|
||||
case 1: autoretract_enabled=true;retracted=false;break;
|
||||
case 0:
|
||||
{
|
||||
autoretract_enabled=false;
|
||||
retracted[0]=false;
|
||||
#if EXTRUDERS > 1
|
||||
retracted[1]=false;
|
||||
#endif
|
||||
#if EXTRUDERS > 2
|
||||
retracted[2]=false;
|
||||
#endif
|
||||
}break;
|
||||
case 1:
|
||||
{
|
||||
autoretract_enabled=true;
|
||||
retracted[0]=false;
|
||||
#if EXTRUDERS > 1
|
||||
retracted[1]=false;
|
||||
#endif
|
||||
#if EXTRUDERS > 2
|
||||
retracted[2]=false;
|
||||
#endif
|
||||
}break;
|
||||
default:
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPGM(MSG_UNKNOWN_COMMAND);
|
||||
|
Reference in New Issue
Block a user