|
@@ -4890,55 +4890,57 @@ inline void gcode_M503() {
|
4890
|
4890
|
* M600: Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
|
4891
|
4891
|
*/
|
4892
|
4892
|
inline void gcode_M600() {
|
4893
|
|
- float target[NUM_AXIS], lastpos[NUM_AXIS], fr60 = feedrate / 60;
|
|
4893
|
+
|
4894
|
4894
|
if (degHotend(active_extruder) < extrude_min_temp) {
|
4895
|
4895
|
SERIAL_ERROR_START;
|
4896
|
4896
|
SERIAL_ERRORLNPGM(MSG_TOO_COLD_FOR_M600);
|
4897
|
4897
|
return;
|
4898
|
4898
|
}
|
4899
|
4899
|
|
|
4900
|
+ float lastpos[NUM_AXIS], fr60 = feedrate / 60;
|
|
4901
|
+
|
4900
|
4902
|
for (int i=0; i<NUM_AXIS; i++)
|
4901
|
|
- target[i] = lastpos[i] = current_position[i];
|
|
4903
|
+ lastpos[i] = destination[i] = current_position[i];
|
4902
|
4904
|
|
4903
|
|
- #define BASICPLAN plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], fr60, active_extruder);
|
4904
|
4905
|
#ifdef DELTA
|
4905
|
|
- #define RUNPLAN calculate_delta(target); BASICPLAN
|
|
4906
|
+ #define RUNPLAN calculate_delta(destination); \
|
|
4907
|
+ plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], fr60, active_extruder);
|
4906
|
4908
|
#else
|
4907
|
|
- #define RUNPLAN BASICPLAN
|
|
4909
|
+ #define RUNPLAN line_to_destination();
|
4908
|
4910
|
#endif
|
4909
|
4911
|
|
4910
|
4912
|
//retract by E
|
4911
|
|
- if (code_seen('E')) target[E_AXIS] += code_value();
|
|
4913
|
+ if (code_seen('E')) destination[E_AXIS] += code_value();
|
4912
|
4914
|
#ifdef FILAMENTCHANGE_FIRSTRETRACT
|
4913
|
|
- else target[E_AXIS] += FILAMENTCHANGE_FIRSTRETRACT;
|
|
4915
|
+ else destination[E_AXIS] += FILAMENTCHANGE_FIRSTRETRACT;
|
4914
|
4916
|
#endif
|
4915
|
4917
|
|
4916
|
4918
|
RUNPLAN;
|
4917
|
4919
|
|
4918
|
4920
|
//lift Z
|
4919
|
|
- if (code_seen('Z')) target[Z_AXIS] += code_value();
|
|
4921
|
+ if (code_seen('Z')) destination[Z_AXIS] += code_value();
|
4920
|
4922
|
#ifdef FILAMENTCHANGE_ZADD
|
4921
|
|
- else target[Z_AXIS] += FILAMENTCHANGE_ZADD;
|
|
4923
|
+ else destination[Z_AXIS] += FILAMENTCHANGE_ZADD;
|
4922
|
4924
|
#endif
|
4923
|
4925
|
|
4924
|
4926
|
RUNPLAN;
|
4925
|
4927
|
|
4926
|
4928
|
//move xy
|
4927
|
|
- if (code_seen('X')) target[X_AXIS] = code_value();
|
|
4929
|
+ if (code_seen('X')) destination[X_AXIS] = code_value();
|
4928
|
4930
|
#ifdef FILAMENTCHANGE_XPOS
|
4929
|
|
- else target[X_AXIS] = FILAMENTCHANGE_XPOS;
|
|
4931
|
+ else destination[X_AXIS] = FILAMENTCHANGE_XPOS;
|
4930
|
4932
|
#endif
|
4931
|
4933
|
|
4932
|
|
- if (code_seen('Y')) target[Y_AXIS] = code_value();
|
|
4934
|
+ if (code_seen('Y')) destination[Y_AXIS] = code_value();
|
4933
|
4935
|
#ifdef FILAMENTCHANGE_YPOS
|
4934
|
|
- else target[Y_AXIS] = FILAMENTCHANGE_YPOS;
|
|
4936
|
+ else destination[Y_AXIS] = FILAMENTCHANGE_YPOS;
|
4935
|
4937
|
#endif
|
4936
|
4938
|
|
4937
|
4939
|
RUNPLAN;
|
4938
|
4940
|
|
4939
|
|
- if (code_seen('L')) target[E_AXIS] += code_value();
|
|
4941
|
+ if (code_seen('L')) destination[E_AXIS] += code_value();
|
4940
|
4942
|
#ifdef FILAMENTCHANGE_FINALRETRACT
|
4941
|
|
- else target[E_AXIS] += FILAMENTCHANGE_FINALRETRACT;
|
|
4943
|
+ else destination[E_AXIS] += FILAMENTCHANGE_FINALRETRACT;
|
4942
|
4944
|
#endif
|
4943
|
4945
|
|
4944
|
4946
|
RUNPLAN;
|
|
@@ -4972,12 +4974,12 @@ inline void gcode_M503() {
|
4972
|
4974
|
#endif
|
4973
|
4975
|
|
4974
|
4976
|
//return to normal
|
4975
|
|
- if (code_seen('L')) target[E_AXIS] -= code_value();
|
|
4977
|
+ if (code_seen('L')) destination[E_AXIS] -= code_value();
|
4976
|
4978
|
#ifdef FILAMENTCHANGE_FINALRETRACT
|
4977
|
|
- else target[E_AXIS] -= FILAMENTCHANGE_FINALRETRACT;
|
|
4979
|
+ else destination[E_AXIS] -= FILAMENTCHANGE_FINALRETRACT;
|
4978
|
4980
|
#endif
|
4979
|
4981
|
|
4980
|
|
- current_position[E_AXIS] = target[E_AXIS]; //the long retract of L is compensated by manual filament feeding
|
|
4982
|
+ current_position[E_AXIS] = destination[E_AXIS]; //the long retract of L is compensated by manual filament feeding
|
4981
|
4983
|
plan_set_e_position(current_position[E_AXIS]);
|
4982
|
4984
|
|
4983
|
4985
|
RUNPLAN; //should do nothing
|
|
@@ -4986,12 +4988,17 @@ inline void gcode_M503() {
|
4986
|
4988
|
|
4987
|
4989
|
#ifdef DELTA
|
4988
|
4990
|
calculate_delta(lastpos);
|
4989
|
|
- plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move xyz back
|
4990
|
|
- plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract
|
|
4991
|
+ plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], fr60, active_extruder);
|
|
4992
|
+ plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder);
|
4991
|
4993
|
#else
|
4992
|
|
- plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move xy back
|
4993
|
|
- plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move z back
|
4994
|
|
- plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract
|
|
4994
|
+ // Move XY to starting position, then Z, then E
|
|
4995
|
+ destination[X_AXIS] = lastpos[X_AXIS];
|
|
4996
|
+ destination[Y_AXIS] = lastpos[Y_AXIS];
|
|
4997
|
+ line_to_destination();
|
|
4998
|
+ destination[Z_AXIS] = lastpos[Z_AXIS];
|
|
4999
|
+ line_to_destination();
|
|
5000
|
+ destination[E_AXIS] = lastpos[E_AXIS];
|
|
5001
|
+ line_to_destination();
|
4995
|
5002
|
#endif
|
4996
|
5003
|
|
4997
|
5004
|
#ifdef FILAMENT_RUNOUT_SENSOR
|