Replace target with destination in M600
This commit is contained in:
parent
4ce9ddbb74
commit
97ec224d72
1 changed files with 31 additions and 24 deletions
|
@ -4890,55 +4890,57 @@ inline void gcode_M503() {
|
|||
* M600: Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
|
||||
*/
|
||||
inline void gcode_M600() {
|
||||
float target[NUM_AXIS], lastpos[NUM_AXIS], fr60 = feedrate / 60;
|
||||
|
||||
if (degHotend(active_extruder) < extrude_min_temp) {
|
||||
SERIAL_ERROR_START;
|
||||
SERIAL_ERRORLNPGM(MSG_TOO_COLD_FOR_M600);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i=0; i<NUM_AXIS; i++)
|
||||
target[i] = lastpos[i] = current_position[i];
|
||||
float lastpos[NUM_AXIS], fr60 = feedrate / 60;
|
||||
|
||||
for (int i=0; i<NUM_AXIS; i++)
|
||||
lastpos[i] = destination[i] = current_position[i];
|
||||
|
||||
#define BASICPLAN plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], fr60, active_extruder);
|
||||
#ifdef DELTA
|
||||
#define RUNPLAN calculate_delta(target); BASICPLAN
|
||||
#define RUNPLAN calculate_delta(destination); \
|
||||
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], fr60, active_extruder);
|
||||
#else
|
||||
#define RUNPLAN BASICPLAN
|
||||
#define RUNPLAN line_to_destination();
|
||||
#endif
|
||||
|
||||
//retract by E
|
||||
if (code_seen('E')) target[E_AXIS] += code_value();
|
||||
if (code_seen('E')) destination[E_AXIS] += code_value();
|
||||
#ifdef FILAMENTCHANGE_FIRSTRETRACT
|
||||
else target[E_AXIS] += FILAMENTCHANGE_FIRSTRETRACT;
|
||||
else destination[E_AXIS] += FILAMENTCHANGE_FIRSTRETRACT;
|
||||
#endif
|
||||
|
||||
RUNPLAN;
|
||||
|
||||
//lift Z
|
||||
if (code_seen('Z')) target[Z_AXIS] += code_value();
|
||||
if (code_seen('Z')) destination[Z_AXIS] += code_value();
|
||||
#ifdef FILAMENTCHANGE_ZADD
|
||||
else target[Z_AXIS] += FILAMENTCHANGE_ZADD;
|
||||
else destination[Z_AXIS] += FILAMENTCHANGE_ZADD;
|
||||
#endif
|
||||
|
||||
RUNPLAN;
|
||||
|
||||
//move xy
|
||||
if (code_seen('X')) target[X_AXIS] = code_value();
|
||||
if (code_seen('X')) destination[X_AXIS] = code_value();
|
||||
#ifdef FILAMENTCHANGE_XPOS
|
||||
else target[X_AXIS] = FILAMENTCHANGE_XPOS;
|
||||
else destination[X_AXIS] = FILAMENTCHANGE_XPOS;
|
||||
#endif
|
||||
|
||||
if (code_seen('Y')) target[Y_AXIS] = code_value();
|
||||
if (code_seen('Y')) destination[Y_AXIS] = code_value();
|
||||
#ifdef FILAMENTCHANGE_YPOS
|
||||
else target[Y_AXIS] = FILAMENTCHANGE_YPOS;
|
||||
else destination[Y_AXIS] = FILAMENTCHANGE_YPOS;
|
||||
#endif
|
||||
|
||||
RUNPLAN;
|
||||
|
||||
if (code_seen('L')) target[E_AXIS] += code_value();
|
||||
if (code_seen('L')) destination[E_AXIS] += code_value();
|
||||
#ifdef FILAMENTCHANGE_FINALRETRACT
|
||||
else target[E_AXIS] += FILAMENTCHANGE_FINALRETRACT;
|
||||
else destination[E_AXIS] += FILAMENTCHANGE_FINALRETRACT;
|
||||
#endif
|
||||
|
||||
RUNPLAN;
|
||||
|
@ -4972,12 +4974,12 @@ inline void gcode_M503() {
|
|||
#endif
|
||||
|
||||
//return to normal
|
||||
if (code_seen('L')) target[E_AXIS] -= code_value();
|
||||
if (code_seen('L')) destination[E_AXIS] -= code_value();
|
||||
#ifdef FILAMENTCHANGE_FINALRETRACT
|
||||
else target[E_AXIS] -= FILAMENTCHANGE_FINALRETRACT;
|
||||
else destination[E_AXIS] -= FILAMENTCHANGE_FINALRETRACT;
|
||||
#endif
|
||||
|
||||
current_position[E_AXIS] = target[E_AXIS]; //the long retract of L is compensated by manual filament feeding
|
||||
current_position[E_AXIS] = destination[E_AXIS]; //the long retract of L is compensated by manual filament feeding
|
||||
plan_set_e_position(current_position[E_AXIS]);
|
||||
|
||||
RUNPLAN; //should do nothing
|
||||
|
@ -4986,12 +4988,17 @@ inline void gcode_M503() {
|
|||
|
||||
#ifdef DELTA
|
||||
calculate_delta(lastpos);
|
||||
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move xyz back
|
||||
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract
|
||||
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], fr60, active_extruder);
|
||||
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder);
|
||||
#else
|
||||
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move xy back
|
||||
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move z back
|
||||
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract
|
||||
// Move XY to starting position, then Z, then E
|
||||
destination[X_AXIS] = lastpos[X_AXIS];
|
||||
destination[Y_AXIS] = lastpos[Y_AXIS];
|
||||
line_to_destination();
|
||||
destination[Z_AXIS] = lastpos[Z_AXIS];
|
||||
line_to_destination();
|
||||
destination[E_AXIS] = lastpos[E_AXIS];
|
||||
line_to_destination();
|
||||
#endif
|
||||
|
||||
#ifdef FILAMENT_RUNOUT_SENSOR
|
||||
|
|
Reference in a new issue