diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 245f65c9ef..6398f4161b 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -410,9 +410,11 @@ const unsigned int dropsegments=5; //everything with less than this number of st #ifdef FWRETRACT #define MIN_RETRACT 0.1 //minimum extruded mm to accept a automatic gcode retraction attempt #define RETRACT_LENGTH 3 //default retract length (positive mm) + #define RETRACT_LENGTH_SWAP 13 //default swap retract length (positive mm), for extruder change #define RETRACT_FEEDRATE 45 //default feedrate for retracting (mm/s) #define RETRACT_ZLIFT 0 //default retract Z-lift #define RETRACT_RECOVER_LENGTH 0 //default additional recover length (mm, added to retract length when recovering) + #define RETRACT_RECOVER_LENGTH_SWAP 0 //default additional swap recover length (mm, added to retract length when recovering from extruder change) #define RETRACT_RECOVER_FEEDRATE 8 //default feedrate for recovering from retraction (mm/s) #endif diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index e7282092e5..062b6d43c4 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -231,9 +231,9 @@ extern unsigned char fanSpeedSoftPwm; #ifdef FWRETRACT extern bool autoretract_enabled; -extern bool retracted; -extern float retract_length, retract_feedrate, retract_zlift; -extern float retract_recover_length, retract_recover_feedrate; +extern bool retracted[EXTRUDERS]; +extern float retract_length, retract_length_swap, retract_feedrate, retract_zlift; +extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate; #endif extern unsigned long starttime; diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index c90f429f4d..2f8cf78e01 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -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 @@ -1697,7 +1732,7 @@ void process_commands() case 23: //M23 - Select file starpos = (strchr(strchr_pointer + 4,'*')); if(starpos!=NULL) - *(starpos-1)='\0'; + *(starpos)='\0'; card.openFile(strchr_pointer + 4,true); break; case 24: //M24 - Start SD print @@ -1720,7 +1755,7 @@ void process_commands() if(starpos != NULL){ char* npos = strchr(cmdbuffer[bufindr], 'N'); strchr_pointer = strchr(npos,' ') + 1; - *(starpos-1) = '\0'; + *(starpos) = '\0'; } card.openFile(strchr_pointer+4,false); break; @@ -1735,7 +1770,7 @@ void process_commands() if(starpos != NULL){ char* npos = strchr(cmdbuffer[bufindr], 'N'); strchr_pointer = strchr(npos,' ') + 1; - *(starpos-1) = '\0'; + *(starpos) = '\0'; } card.removeFile(strchr_pointer + 4); } @@ -1757,7 +1792,7 @@ void process_commands() namestartpos++; //to skip the '!' if(starpos!=NULL) - *(starpos-1)='\0'; + *(starpos)='\0'; bool call_procedure=(code_seen('P')); @@ -1780,7 +1815,7 @@ void process_commands() if(starpos != NULL){ char* npos = strchr(cmdbuffer[bufindr], 'N'); strchr_pointer = strchr(npos,' ') + 1; - *(starpos-1) = '\0'; + *(starpos) = '\0'; } card.openLogFile(strchr_pointer+5); break; @@ -2200,7 +2235,7 @@ void process_commands() case 117: // M117 display message starpos = (strchr(strchr_pointer + 5,'*')); if(starpos!=NULL) - *(starpos-1)='\0'; + *(starpos)='\0'; lcd_setstatus(strchr_pointer + 5); break; case 114: // M114 @@ -2398,8 +2433,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); diff --git a/Marlin/language.h b/Marlin/language.h index c032aca89e..8522018bf1 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -171,9 +171,11 @@ #define MSG_KILLED "KILLED. " #define MSG_STOPPED "STOPPED. " #define MSG_CONTROL_RETRACT "Retract mm" + #define MSG_CONTROL_RETRACT_SWAP "Swap Re.mm" #define MSG_CONTROL_RETRACTF "Retract V" #define MSG_CONTROL_RETRACT_ZLIFT "Hop mm" #define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "S UnRet+mm" #define MSG_CONTROL_RETRACT_RECOVERF "UnRet V" #define MSG_AUTORETRACT "AutoRetr." #define MSG_FILAMENTCHANGE "Change filament" @@ -371,9 +373,11 @@ #define MSG_STOPPED "Zatrzymany. " #define MSG_STEPPER_RELEASED "Zwolniony." #define MSG_CONTROL_RETRACT "Wycofaj mm" + #define MSG_CONTROL_RETRACT_SWAP "Z Wycof. mm" #define MSG_CONTROL_RETRACTF "Wycofaj V" #define MSG_CONTROL_RETRACT_ZLIFT "Skok Z mm:" #define MSG_CONTROL_RETRACT_RECOVER "Cof. wycof. +mm" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Z Cof. wyc. +mm" #define MSG_CONTROL_RETRACT_RECOVERF "Cof. wycof. V" #define MSG_AUTORETRACT "Auto. wycofanie" #define MSG_FILAMENTCHANGE "Zmien filament" @@ -572,9 +576,11 @@ #define MSG_STOPPED "STOPPE." #define MSG_STEPPER_RELEASED "RELACHE." #define MSG_CONTROL_RETRACT "Retraction mm" + #define MSG_CONTROL_RETRACT_SWAP "Ech. Retr. mm" #define MSG_CONTROL_RETRACTF "Retraction V" #define MSG_CONTROL_RETRACT_ZLIFT "Hop mm" #define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Ech. UnRet +mm" #define MSG_CONTROL_RETRACT_RECOVERF "UnRet V" #define MSG_AUTORETRACT "Retract. Auto." #define MSG_FILAMENTCHANGE "Changer filament" @@ -774,9 +780,11 @@ #define MSG_STOPPED "GESTOPPT" #define MSG_STEPPER_RELEASED "Stepper frei" #define MSG_CONTROL_RETRACT "Retract mm" + #define MSG_CONTROL_RETRACT_SWAP "Wechs. Retract mm" #define MSG_CONTROL_RETRACTF "Retract V" #define MSG_CONTROL_RETRACT_ZLIFT "Hop mm" #define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Wechs. UnRet +mm" #define MSG_CONTROL_RETRACT_RECOVERF "UnRet V" #define MSG_AUTORETRACT "AutoRetr." #define MSG_FILAMENTCHANGE "Filament wechseln" @@ -972,9 +980,11 @@ #define MSG_KILLED "PARADA DE EMERG." #define MSG_STOPPED "PARADA" #define MSG_CONTROL_RETRACT "Retraer mm" + #define MSG_CONTROL_RETRACT_SWAP "Interc. Retraer mm" #define MSG_CONTROL_RETRACTF "Retraer V" #define MSG_CONTROL_RETRACT_ZLIFT "Levantar mm" #define MSG_CONTROL_RETRACT_RECOVER "DesRet +mm" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Interc. DesRet +mm" #define MSG_CONTROL_RETRACT_RECOVERF "DesRet V" #define MSG_AUTORETRACT "AutoRetr." #define MSG_FILAMENTCHANGE "Cambiar filamento" @@ -1179,9 +1189,11 @@ #define MSG_KILLED "УБИТО." #define MSG_STOPPED "ОСТАНОВЛЕНО." #define MSG_CONTROL_RETRACT "Откат mm:" + #define MSG_CONTROL_RETRACT_SWAP "своп Откат mm:" #define MSG_CONTROL_RETRACTF "Откат V:" #define MSG_CONTROL_RETRACT_ZLIFT "Прыжок mm:" #define MSG_CONTROL_RETRACT_RECOVER "Возврат +mm:" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "своп Возврат +mm:" #define MSG_CONTROL_RETRACT_RECOVERF "Возврат V:" #define MSG_AUTORETRACT "АвтоОткат:" #define MSG_FILAMENTCHANGE "Change filament" @@ -1376,9 +1388,11 @@ #define MSG_KILLED "UCCISO. " #define MSG_STOPPED "ARRESTATO. " #define MSG_CONTROL_RETRACT "Ritrai mm" + #define MSG_CONTROL_RETRACT_SWAP "Scamb. Ritrai mm" #define MSG_CONTROL_RETRACTF "Ritrai V" #define MSG_CONTROL_RETRACT_ZLIFT "Salta mm" #define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Scamb. UnRet +mm" #define MSG_CONTROL_RETRACT_RECOVERF "UnRet V" #define MSG_AUTORETRACT "AutoArretramento" #define MSG_FILAMENTCHANGE "Cambia filamento" @@ -1581,9 +1595,11 @@ #define MSG_STOPPED "PARADA. " #define MSG_STEPPER_RELEASED "Lancado." #define MSG_CONTROL_RETRACT " Retrair mm:" + #define MSG_CONTROL_RETRACT_SWAP "Troca Retrair mm:" #define MSG_CONTROL_RETRACTF " Retrair V:" #define MSG_CONTROL_RETRACT_ZLIFT " Levantar mm:" #define MSG_CONTROL_RETRACT_RECOVER " DesRet +mm:" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Troca DesRet +mm:" #define MSG_CONTROL_RETRACT_RECOVERF " DesRet V:" #define MSG_AUTORETRACT " AutoRetr.:" #define MSG_FILAMENTCHANGE "Change filament" @@ -1781,9 +1797,11 @@ #define MSG_KILLED "KILLED. " #define MSG_STOPPED "STOPPED. " #define MSG_CONTROL_RETRACT "Veda mm" + #define MSG_CONTROL_RETRACT_SWAP "Va. Veda mm" #define MSG_CONTROL_RETRACTF "Veda V" #define MSG_CONTROL_RETRACT_ZLIFT "Z mm" #define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Va. UnRet +mm" #define MSG_CONTROL_RETRACT_RECOVERF "UnRet V" #define MSG_AUTORETRACT "AutoVeto." #define MSG_FILAMENTCHANGE "Change filament" @@ -1979,9 +1997,11 @@ #define MSG_KILLED "ATURADA D'EMERCH." #define MSG_STOPPED "ATURADA." #define MSG_CONTROL_RETRACT "Retraer mm" + #define MSG_CONTROL_RETRACT_SWAP "Swap Retraer mm" #define MSG_CONTROL_RETRACTF "Retraer F" #define MSG_CONTROL_RETRACT_ZLIFT "Devantar mm" #define MSG_CONTROL_RETRACT_RECOVER "DesRet +mm" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Swap DesRet +mm" #define MSG_CONTROL_RETRACT_RECOVERF "DesRet F" #define MSG_AUTORETRACT "AutoRetr." #define MSG_FILAMENTCHANGE "Cambear" @@ -2185,9 +2205,11 @@ #define MSG_KILLED "AFGEBROKEN. " #define MSG_STOPPED "GESTOPT. " #define MSG_CONTROL_RETRACT "Retract mm" + #define MSG_CONTROL_RETRACT_SWAP "Ruil Retract mm" #define MSG_CONTROL_RETRACTF "Retract F" #define MSG_CONTROL_RETRACT_ZLIFT "Hop mm" #define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Ruil UnRet +mm" #define MSG_CONTROL_RETRACT_RECOVERF "UnRet F" #define MSG_AUTORETRACT "AutoRetr." #define MSG_FILAMENTCHANGE "Verv. Filament" @@ -2384,9 +2406,11 @@ #define MSG_KILLED "PARADA DE EMERG. " #define MSG_STOPPED "ATURAT. " #define MSG_CONTROL_RETRACT "Retreure mm" + #define MSG_CONTROL_RETRACT_SWAP "Swap Retreure mm" #define MSG_CONTROL_RETRACTF "Retreure F" #define MSG_CONTROL_RETRACT_ZLIFT "Aixecar mm" #define MSG_CONTROL_RETRACT_RECOVER "DesRet +mm" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Swap DesRet +mm" #define MSG_CONTROL_RETRACT_RECOVERF "DesRet F" #define MSG_AUTORETRACT "AutoRetr." #define MSG_FILAMENTCHANGE "Canviar filament" @@ -2582,9 +2606,11 @@ #define MSG_KILLED "LARRIALDI GELDIA" #define MSG_STOPPED "GELDITUTA. " #define MSG_CONTROL_RETRACT "Atzera egin mm" + #define MSG_CONTROL_RETRACT_SWAP "Swap Atzera egin mm" #define MSG_CONTROL_RETRACTF "Atzera egin V" #define MSG_CONTROL_RETRACT_ZLIFT "Igo mm" #define MSG_CONTROL_RETRACT_RECOVER "Atzera egin +mm" + #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Swap Atzera egin +mm" #define MSG_CONTROL_RETRACT_RECOVERF "Atzera egin V" #define MSG_AUTORETRACT "Atzera egin" #define MSG_FILAMENTCHANGE "Aldatu filament." diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 470d6eccb5..0abc355003 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -904,9 +904,15 @@ static void lcd_control_retract_menu() MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); MENU_ITEM_EDIT(bool, MSG_AUTORETRACT, &autoretract_enabled); MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT, &retract_length, 0, 100); + #if EXTRUDERS > 1 + MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_SWAP, &retract_length_swap, 0, 100); + #endif MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACTF, &retract_feedrate, 1, 999); MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_ZLIFT, &retract_zlift, 0, 999); MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER, &retract_recover_length, 0, 100); + #if EXTRUDERS > 1 + MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER_SWAP, &retract_recover_length_swap, 0, 100); + #endif MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &retract_recover_feedrate, 1, 999); END_MENU(); }