|
@@ -1080,6 +1080,41 @@ static void homeaxis(int axis) {
|
1080
|
1080
|
}
|
1081
|
1081
|
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
|
1082
|
1082
|
|
|
1083
|
+#ifdef FWRETRACT
|
|
1084
|
+ void retract(bool retracting) {
|
|
1085
|
+ if(retracting && !retracted) {
|
|
1086
|
+ destination[X_AXIS]=current_position[X_AXIS];
|
|
1087
|
+ destination[Y_AXIS]=current_position[Y_AXIS];
|
|
1088
|
+ destination[Z_AXIS]=current_position[Z_AXIS];
|
|
1089
|
+ destination[E_AXIS]=current_position[E_AXIS];
|
|
1090
|
+ current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
|
|
1091
|
+ plan_set_e_position(current_position[E_AXIS]);
|
|
1092
|
+ float oldFeedrate = feedrate;
|
|
1093
|
+ feedrate=retract_feedrate;
|
|
1094
|
+ retracted=true;
|
|
1095
|
+ prepare_move();
|
|
1096
|
+ current_position[Z_AXIS]-=retract_zlift;
|
|
1097
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1098
|
+ prepare_move();
|
|
1099
|
+ feedrate = oldFeedrate;
|
|
1100
|
+ } else if(!retracting && retracted) {
|
|
1101
|
+ destination[X_AXIS]=current_position[X_AXIS];
|
|
1102
|
+ destination[Y_AXIS]=current_position[Y_AXIS];
|
|
1103
|
+ destination[Z_AXIS]=current_position[Z_AXIS];
|
|
1104
|
+ destination[E_AXIS]=current_position[E_AXIS];
|
|
1105
|
+ current_position[Z_AXIS]+=retract_zlift;
|
|
1106
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1107
|
+ //prepare_move();
|
|
1108
|
+ current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder];
|
|
1109
|
+ plan_set_e_position(current_position[E_AXIS]);
|
|
1110
|
+ float oldFeedrate = feedrate;
|
|
1111
|
+ feedrate=retract_recover_feedrate;
|
|
1112
|
+ retracted=false;
|
|
1113
|
+ prepare_move();
|
|
1114
|
+ feedrate = oldFeedrate;
|
|
1115
|
+ }
|
|
1116
|
+ } //retract
|
|
1117
|
+#endif //FWRETRACT
|
1083
|
1118
|
void process_commands()
|
1084
|
1119
|
{
|
1085
|
1120
|
unsigned long codenum; //throw away variable
|
|
@@ -1095,6 +1130,18 @@ void process_commands()
|
1095
|
1130
|
case 1: // G1
|
1096
|
1131
|
if(Stopped == false) {
|
1097
|
1132
|
get_coordinates(); // For X Y Z E F
|
|
1133
|
+ #ifdef FWRETRACT
|
|
1134
|
+ if(autoretract_enabled)
|
|
1135
|
+ if( !(code_seen(X_AXIS) || code_seen(Y_AXIS) || code_seen(Z_AXIS)) && code_seen(E_AXIS)) {
|
|
1136
|
+ float echange=destination[E_AXIS]-current_position[E_AXIS];
|
|
1137
|
+ if((echange<-MIN_RETRACT && !retracted) || (echange>MIN_RETRACT && retracted)) { //move appears to be an attempt to attract or recover
|
|
1138
|
+ current_position[E_AXIS] = destination[E_AXIS]; //hide the slicer-generated retract/recover from calculations
|
|
1139
|
+ plan_set_e_position(current_position[E_AXIS]); //AND from the planner
|
|
1140
|
+ retract(!retracted);
|
|
1141
|
+ return;
|
|
1142
|
+ }
|
|
1143
|
+ }
|
|
1144
|
+ #endif //FWRETRACT
|
1098
|
1145
|
prepare_move();
|
1099
|
1146
|
//ClearToSend();
|
1100
|
1147
|
return;
|
|
@@ -1129,43 +1176,10 @@ void process_commands()
|
1129
|
1176
|
break;
|
1130
|
1177
|
#ifdef FWRETRACT
|
1131
|
1178
|
case 10: // G10 retract
|
1132
|
|
- if(!retracted)
|
1133
|
|
- {
|
1134
|
|
- destination[X_AXIS]=current_position[X_AXIS];
|
1135
|
|
- destination[Y_AXIS]=current_position[Y_AXIS];
|
1136
|
|
- destination[Z_AXIS]=current_position[Z_AXIS];
|
1137
|
|
- destination[E_AXIS]=current_position[E_AXIS];
|
1138
|
|
- current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
|
1139
|
|
- plan_set_e_position(current_position[E_AXIS]);
|
1140
|
|
- float oldFeedrate = feedrate;
|
1141
|
|
- feedrate=retract_feedrate;
|
1142
|
|
- retracted=true;
|
1143
|
|
- prepare_move();
|
1144
|
|
- current_position[Z_AXIS]-=retract_zlift;
|
1145
|
|
- plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1146
|
|
- prepare_move();
|
1147
|
|
- feedrate = oldFeedrate;
|
1148
|
|
- }
|
1149
|
|
-
|
|
1179
|
+ retract(true);
|
1150
|
1180
|
break;
|
1151
|
1181
|
case 11: // G11 retract_recover
|
1152
|
|
- if(retracted)
|
1153
|
|
- {
|
1154
|
|
- destination[X_AXIS]=current_position[X_AXIS];
|
1155
|
|
- destination[Y_AXIS]=current_position[Y_AXIS];
|
1156
|
|
- destination[Z_AXIS]=current_position[Z_AXIS];
|
1157
|
|
- destination[E_AXIS]=current_position[E_AXIS];
|
1158
|
|
- current_position[Z_AXIS]+=retract_zlift;
|
1159
|
|
- plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1160
|
|
- //prepare_move();
|
1161
|
|
- current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder];
|
1162
|
|
- plan_set_e_position(current_position[E_AXIS]);
|
1163
|
|
- float oldFeedrate = feedrate;
|
1164
|
|
- feedrate=retract_recover_feedrate;
|
1165
|
|
- retracted=false;
|
1166
|
|
- prepare_move();
|
1167
|
|
- feedrate = oldFeedrate;
|
1168
|
|
- }
|
|
1182
|
+ retract(false);
|
1169
|
1183
|
break;
|
1170
|
1184
|
#endif //FWRETRACT
|
1171
|
1185
|
case 28: //G28 Home all Axis one at a time
|
|
@@ -3020,42 +3034,6 @@ void get_coordinates()
|
3020
|
3034
|
next_feedrate = code_value();
|
3021
|
3035
|
if(next_feedrate > 0.0) feedrate = next_feedrate;
|
3022
|
3036
|
}
|
3023
|
|
- #ifdef FWRETRACT
|
3024
|
|
- if(autoretract_enabled)
|
3025
|
|
- if( !(seen[X_AXIS] || seen[Y_AXIS] || seen[Z_AXIS]) && seen[E_AXIS])
|
3026
|
|
- {
|
3027
|
|
- float echange=destination[E_AXIS]-current_position[E_AXIS];
|
3028
|
|
- if(echange<-MIN_RETRACT) //retract
|
3029
|
|
- {
|
3030
|
|
- if(!retracted)
|
3031
|
|
- {
|
3032
|
|
-
|
3033
|
|
- destination[Z_AXIS]+=retract_zlift; //not sure why chaninging current_position negatively does not work.
|
3034
|
|
- //if slicer retracted by echange=-1mm and you want to retract 3mm, corrrectede=-2mm additionally
|
3035
|
|
- float correctede=-echange-retract_length;
|
3036
|
|
- //to generate the additional steps, not the destination is changed, but inversely the current position
|
3037
|
|
- current_position[E_AXIS]+=-correctede;
|
3038
|
|
- feedrate=retract_feedrate;
|
3039
|
|
- retracted=true;
|
3040
|
|
- }
|
3041
|
|
-
|
3042
|
|
- }
|
3043
|
|
- else
|
3044
|
|
- if(echange>MIN_RETRACT) //retract_recover
|
3045
|
|
- {
|
3046
|
|
- if(retracted)
|
3047
|
|
- {
|
3048
|
|
- //current_position[Z_AXIS]+=-retract_zlift;
|
3049
|
|
- //if slicer retracted_recovered by echange=+1mm and you want to retract_recover 3mm, corrrectede=2mm additionally
|
3050
|
|
- float correctede=-echange+1*retract_length+retract_recover_length; //total unretract=retract_length+retract_recover_length[surplus]
|
3051
|
|
- current_position[E_AXIS]+=correctede; //to generate the additional steps, not the destination is changed, but inversely the current position
|
3052
|
|
- feedrate=retract_recover_feedrate;
|
3053
|
|
- retracted=false;
|
3054
|
|
- }
|
3055
|
|
- }
|
3056
|
|
-
|
3057
|
|
- }
|
3058
|
|
- #endif //FWRETRACT
|
3059
|
3037
|
}
|
3060
|
3038
|
|
3061
|
3039
|
void get_arc_coordinates()
|