Commit 4af24b14 authored by MagoKimbra's avatar MagoKimbra

Fix M600

parent d5c9f507
...@@ -5521,54 +5521,62 @@ inline void gcode_M503() { ...@@ -5521,54 +5521,62 @@ inline void gcode_M503() {
#ifdef FILAMENTCHANGEENABLE #ifdef FILAMENTCHANGEENABLE
/** /**
* M600: Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] * M600: Pause for filament change
*
* E[mm] - Retract the filament this far (negative value)
* Z[mm] - Move the Z axis by this distance
* X[mm] - Move to this X position, with Y
* Y[mm] - Move to this Y position, with X
* L[mm] - Retract distance for removal (manual reload)
*
* Default values are used for omitted arguments.
*
*/ */
inline void gcode_M600() { inline void gcode_M600() {
float target[NUM_AXIS], fr60 = feedrate / 60; float fr60 = feedrate / 60;
filament_changing = true; filament_changing = true;
for (int i = 0; i < NUM_AXIS; i++) for (int i = 0; i < NUM_AXIS; i++)
target[i] = lastpos[i] = current_position[i]; lastpos[i] = destination[i] = current_position[i];
#ifdef DELTA #ifdef DELTA
#define BASICPLAN plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], fr60, active_extruder, active_driver); #define RUNPLAN calculate_delta(destination); \
#define RUNPLAN calculate_delta(target); BASICPLAN plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], fr60, active_extruder, active_driver);
#else #else
#define BASICPLAN plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], fr60, active_extruder, active_driver); #define RUNPLAN line_to_destination();
#define RUNPLAN BASICPLAN
#endif #endif
//retract by E //retract by E
if (code_seen('E')) target[E_AXIS] += code_value(); if (code_seen('E')) destination[E_AXIS] += code_value();
#ifdef FILAMENTCHANGE_FIRSTRETRACT #ifdef FILAMENTCHANGE_FIRSTRETRACT
else target[E_AXIS] += FILAMENTCHANGE_FIRSTRETRACT; else destination[E_AXIS] += FILAMENTCHANGE_FIRSTRETRACT;
#endif #endif
RUNPLAN; RUNPLAN;
//lift Z //lift Z
if (code_seen('Z')) target[Z_AXIS] += code_value(); if (code_seen('Z')) destination[Z_AXIS] += code_value();
#ifdef FILAMENTCHANGE_ZADD #ifdef FILAMENTCHANGE_ZADD
else target[Z_AXIS] += FILAMENTCHANGE_ZADD; else destination[Z_AXIS] += FILAMENTCHANGE_ZADD;
#endif #endif
RUNPLAN; RUNPLAN;
//move xy //move xy
if (code_seen('X')) target[X_AXIS] = code_value(); if (code_seen('X')) destination[X_AXIS] = code_value();
#ifdef FILAMENTCHANGE_XPOS #ifdef FILAMENTCHANGE_XPOS
else target[X_AXIS] = FILAMENTCHANGE_XPOS; else destination[X_AXIS] = FILAMENTCHANGE_XPOS;
#endif #endif
if (code_seen('Y')) target[Y_AXIS] = code_value(); if (code_seen('Y')) destination[Y_AXIS] = code_value();
#ifdef FILAMENTCHANGE_YPOS #ifdef FILAMENTCHANGE_YPOS
else target[Y_AXIS] = FILAMENTCHANGE_YPOS; else destination[Y_AXIS] = FILAMENTCHANGE_YPOS;
#endif #endif
RUNPLAN; RUNPLAN;
if (code_seen('L')) target[E_AXIS] += code_value(); if (code_seen('L')) destination[E_AXIS] += code_value();
#ifdef FILAMENTCHANGE_FINALRETRACT #ifdef FILAMENTCHANGE_FINALRETRACT
else target[E_AXIS] += FILAMENTCHANGE_FINALRETRACT; else destination[E_AXIS] += FILAMENTCHANGE_FINALRETRACT;
#endif #endif
RUNPLAN; RUNPLAN;
...@@ -5629,34 +5637,38 @@ inline void gcode_M503() { ...@@ -5629,34 +5637,38 @@ inline void gcode_M503() {
} }
//return to normal //return to normal
if (code_seen('L')) target[E_AXIS] -= code_value(); if (code_seen('L')) destination[E_AXIS] -= code_value();
#ifdef FILAMENTCHANGE_FINALRETRACT #ifdef FILAMENTCHANGE_FINALRETRACT
else target[E_AXIS] -= FILAMENTCHANGE_FINALRETRACT; else destination[E_AXIS] -= FILAMENTCHANGE_FINALRETRACT;
#endif #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]); plan_set_e_position(current_position[E_AXIS]);
RUNPLAN; // should do nothing RUNPLAN; // should do nothing
lcd_reset_alert_level(); lcd_reset_alert_level();
// HOME X & Y & Z(only Delta)
//gcode_G28(true); Devo trovare un'altra soluzione
#ifdef DELTA #ifdef DELTA
calculate_delta(lastpos); calculate_delta(lastpos);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], fr60, active_extruder, active_driver); //move xyz back plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], fr60, active_extruder, active_driver); //move xyz back
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder, active_driver); //final unretract plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder, active_driver); //final unretract
#else #else
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], fr60, active_extruder, active_driver); //move xy back // Move XY to starting position, then Z, then E
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], fr60, active_extruder, active_driver); //move z back destination[X_AXIS] = lastpos[X_AXIS];
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder, active_driver); //final unretract 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 #endif
#ifdef FILAMENT_RUNOUT_SENSOR #ifdef FILAMENT_RUNOUT_SENSOR
filrunoutEnqueued = false; filrunoutEnqueued = false;
#endif #endif
filament_changing = false;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment