|
@@ -231,10 +231,13 @@ int EtoPPressure=0;
|
231
|
231
|
#endif
|
232
|
232
|
|
233
|
233
|
#ifdef FWRETRACT
|
234
|
|
- bool autoretract_enabled=true;
|
|
234
|
+ bool autoretract_enabled=false;
|
235
|
235
|
bool retracted=false;
|
236
|
|
- float retract_length=3, retract_feedrate=17*60, retract_zlift=0.8;
|
237
|
|
- float retract_recover_length=0, retract_recover_feedrate=8*60;
|
|
236
|
+ float retract_length = RETRACT_LENGTH;
|
|
237
|
+ float retract_feedrate = RETRACT_FEEDRATE;
|
|
238
|
+ float retract_zlift = RETRACT_ZLIFT;
|
|
239
|
+ float retract_recover_length = RETRACT_RECOVER_LENGTH;
|
|
240
|
+ float retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
|
238
|
241
|
#endif
|
239
|
242
|
|
240
|
243
|
#ifdef ULTIPANEL
|
|
@@ -1085,6 +1088,42 @@ void refresh_cmd_timeout(void)
|
1085
|
1088
|
previous_millis_cmd = millis();
|
1086
|
1089
|
}
|
1087
|
1090
|
|
|
1091
|
+#ifdef FWRETRACT
|
|
1092
|
+ void retract(bool retracting) {
|
|
1093
|
+ if(retracting && !retracted) {
|
|
1094
|
+ destination[X_AXIS]=current_position[X_AXIS];
|
|
1095
|
+ destination[Y_AXIS]=current_position[Y_AXIS];
|
|
1096
|
+ destination[Z_AXIS]=current_position[Z_AXIS];
|
|
1097
|
+ destination[E_AXIS]=current_position[E_AXIS];
|
|
1098
|
+ current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
|
|
1099
|
+ plan_set_e_position(current_position[E_AXIS]);
|
|
1100
|
+ float oldFeedrate = feedrate;
|
|
1101
|
+ feedrate=retract_feedrate;
|
|
1102
|
+ retracted=true;
|
|
1103
|
+ prepare_move();
|
|
1104
|
+ current_position[Z_AXIS]-=retract_zlift;
|
|
1105
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1106
|
+ prepare_move();
|
|
1107
|
+ feedrate = oldFeedrate;
|
|
1108
|
+ } else if(!retracting && retracted) {
|
|
1109
|
+ destination[X_AXIS]=current_position[X_AXIS];
|
|
1110
|
+ destination[Y_AXIS]=current_position[Y_AXIS];
|
|
1111
|
+ destination[Z_AXIS]=current_position[Z_AXIS];
|
|
1112
|
+ destination[E_AXIS]=current_position[E_AXIS];
|
|
1113
|
+ current_position[Z_AXIS]+=retract_zlift;
|
|
1114
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1115
|
+ //prepare_move();
|
|
1116
|
+ current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder];
|
|
1117
|
+ plan_set_e_position(current_position[E_AXIS]);
|
|
1118
|
+ float oldFeedrate = feedrate;
|
|
1119
|
+ feedrate=retract_recover_feedrate;
|
|
1120
|
+ retracted=false;
|
|
1121
|
+ prepare_move();
|
|
1122
|
+ feedrate = oldFeedrate;
|
|
1123
|
+ }
|
|
1124
|
+ } //retract
|
|
1125
|
+#endif //FWRETRACT
|
|
1126
|
+
|
1088
|
1127
|
void process_commands()
|
1089
|
1128
|
{
|
1090
|
1129
|
unsigned long codenum; //throw away variable
|
|
@@ -1100,6 +1139,18 @@ void process_commands()
|
1100
|
1139
|
case 1: // G1
|
1101
|
1140
|
if(Stopped == false) {
|
1102
|
1141
|
get_coordinates(); // For X Y Z E F
|
|
1142
|
+ #ifdef FWRETRACT
|
|
1143
|
+ if(autoretract_enabled)
|
|
1144
|
+ if( !(code_seen(X_AXIS) || code_seen(Y_AXIS) || code_seen(Z_AXIS)) && code_seen(E_AXIS)) {
|
|
1145
|
+ float echange=destination[E_AXIS]-current_position[E_AXIS];
|
|
1146
|
+ if((echange<-MIN_RETRACT && !retracted) || (echange>MIN_RETRACT && retracted)) { //move appears to be an attempt to attract or recover
|
|
1147
|
+ current_position[E_AXIS] = destination[E_AXIS]; //hide the slicer-generated retract/recover from calculations
|
|
1148
|
+ plan_set_e_position(current_position[E_AXIS]); //AND from the planner
|
|
1149
|
+ retract(!retracted);
|
|
1150
|
+ return;
|
|
1151
|
+ }
|
|
1152
|
+ }
|
|
1153
|
+ #endif //FWRETRACT
|
1103
|
1154
|
prepare_move();
|
1104
|
1155
|
//ClearToSend();
|
1105
|
1156
|
return;
|
|
@@ -1134,39 +1185,10 @@ void process_commands()
|
1134
|
1185
|
break;
|
1135
|
1186
|
#ifdef FWRETRACT
|
1136
|
1187
|
case 10: // G10 retract
|
1137
|
|
- if(!retracted)
|
1138
|
|
- {
|
1139
|
|
- destination[X_AXIS]=current_position[X_AXIS];
|
1140
|
|
- destination[Y_AXIS]=current_position[Y_AXIS];
|
1141
|
|
- destination[Z_AXIS]=current_position[Z_AXIS];
|
1142
|
|
- current_position[Z_AXIS]-=retract_zlift;
|
1143
|
|
- destination[E_AXIS]=current_position[E_AXIS];
|
1144
|
|
- current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
|
1145
|
|
- plan_set_e_position(current_position[E_AXIS]);
|
1146
|
|
- float oldFeedrate = feedrate;
|
1147
|
|
- feedrate=retract_feedrate;
|
1148
|
|
- retracted=true;
|
1149
|
|
- prepare_move();
|
1150
|
|
- feedrate = oldFeedrate;
|
1151
|
|
- }
|
1152
|
|
-
|
|
1188
|
+ retract(true);
|
1153
|
1189
|
break;
|
1154
|
1190
|
case 11: // G11 retract_recover
|
1155
|
|
- if(retracted)
|
1156
|
|
- {
|
1157
|
|
- destination[X_AXIS]=current_position[X_AXIS];
|
1158
|
|
- destination[Y_AXIS]=current_position[Y_AXIS];
|
1159
|
|
- destination[Z_AXIS]=current_position[Z_AXIS];
|
1160
|
|
- current_position[Z_AXIS]+=retract_zlift;
|
1161
|
|
- destination[E_AXIS]=current_position[E_AXIS];
|
1162
|
|
- current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder];
|
1163
|
|
- plan_set_e_position(current_position[E_AXIS]);
|
1164
|
|
- float oldFeedrate = feedrate;
|
1165
|
|
- feedrate=retract_recover_feedrate;
|
1166
|
|
- retracted=false;
|
1167
|
|
- prepare_move();
|
1168
|
|
- feedrate = oldFeedrate;
|
1169
|
|
- }
|
|
1191
|
+ retract(false);
|
1170
|
1192
|
break;
|
1171
|
1193
|
#endif //FWRETRACT
|
1172
|
1194
|
case 28: //G28 Home all Axis one at a time
|
|
@@ -3022,42 +3044,6 @@ void get_coordinates()
|
3022
|
3044
|
next_feedrate = code_value();
|
3023
|
3045
|
if(next_feedrate > 0.0) feedrate = next_feedrate;
|
3024
|
3046
|
}
|
3025
|
|
- #ifdef FWRETRACT
|
3026
|
|
- if(autoretract_enabled)
|
3027
|
|
- if( !(seen[X_AXIS] || seen[Y_AXIS] || seen[Z_AXIS]) && seen[E_AXIS])
|
3028
|
|
- {
|
3029
|
|
- float echange=destination[E_AXIS]-current_position[E_AXIS];
|
3030
|
|
- if(echange<-MIN_RETRACT) //retract
|
3031
|
|
- {
|
3032
|
|
- if(!retracted)
|
3033
|
|
- {
|
3034
|
|
-
|
3035
|
|
- destination[Z_AXIS]+=retract_zlift; //not sure why chaninging current_position negatively does not work.
|
3036
|
|
- //if slicer retracted by echange=-1mm and you want to retract 3mm, corrrectede=-2mm additionally
|
3037
|
|
- float correctede=-echange-retract_length;
|
3038
|
|
- //to generate the additional steps, not the destination is changed, but inversely the current position
|
3039
|
|
- current_position[E_AXIS]+=-correctede;
|
3040
|
|
- feedrate=retract_feedrate;
|
3041
|
|
- retracted=true;
|
3042
|
|
- }
|
3043
|
|
-
|
3044
|
|
- }
|
3045
|
|
- else
|
3046
|
|
- if(echange>MIN_RETRACT) //retract_recover
|
3047
|
|
- {
|
3048
|
|
- if(retracted)
|
3049
|
|
- {
|
3050
|
|
- //current_position[Z_AXIS]+=-retract_zlift;
|
3051
|
|
- //if slicer retracted_recovered by echange=+1mm and you want to retract_recover 3mm, corrrectede=2mm additionally
|
3052
|
|
- float correctede=-echange+1*retract_length+retract_recover_length; //total unretract=retract_length+retract_recover_length[surplus]
|
3053
|
|
- current_position[E_AXIS]+=correctede; //to generate the additional steps, not the destination is changed, but inversely the current position
|
3054
|
|
- feedrate=retract_recover_feedrate;
|
3055
|
|
- retracted=false;
|
3056
|
|
- }
|
3057
|
|
- }
|
3058
|
|
-
|
3059
|
|
- }
|
3060
|
|
- #endif //FWRETRACT
|
3061
|
3047
|
}
|
3062
|
3048
|
|
3063
|
3049
|
void get_arc_coordinates()
|