|
|
@ -376,16 +376,16 @@ uint8_t marlin_debug_flags = DEBUG_NONE;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Cartesian Current Position
|
|
|
|
* Cartesian Current Position
|
|
|
|
* Used to track the native machine position as moves are queued.
|
|
|
|
* Used to track the native machine position as moves are queued.
|
|
|
|
* Used by 'line_to_current_position' to do a move after changing it.
|
|
|
|
* Used by 'buffer_line_to_current_position' to do a move after changing it.
|
|
|
|
* Used by 'SYNC_PLAN_POSITION_KINEMATIC' to update 'planner.position'.
|
|
|
|
* Used by 'SYNC_PLAN_POSITION_KINEMATIC' to update 'planner.position'.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
float current_position[XYZE] = { 0.0 };
|
|
|
|
float current_position[XYZE] = { 0.0 };
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Cartesian Destination
|
|
|
|
* Cartesian Destination
|
|
|
|
* A temporary position, usually applied to 'current_position'.
|
|
|
|
* The destination for a move, filled in by G-code movement commands,
|
|
|
|
|
|
|
|
* and expected by functions like 'prepare_move_to_destination'.
|
|
|
|
* Set with 'gcode_get_destination' or 'set_destination_from_current'.
|
|
|
|
* Set with 'gcode_get_destination' or 'set_destination_from_current'.
|
|
|
|
* 'line_to_destination' sets 'current_position' to 'destination'.
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
float destination[XYZE] = { 0.0 };
|
|
|
|
float destination[XYZE] = { 0.0 };
|
|
|
|
|
|
|
|
|
|
|
@ -1633,7 +1633,7 @@ inline float get_homing_bump_feedrate(const AxisEnum axis) {
|
|
|
|
* Move the planner to the current position from wherever it last moved
|
|
|
|
* Move the planner to the current position from wherever it last moved
|
|
|
|
* (or from wherever it has been told it is located).
|
|
|
|
* (or from wherever it has been told it is located).
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
inline void line_to_current_position() {
|
|
|
|
inline void buffer_line_to_current_position() {
|
|
|
|
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, active_extruder);
|
|
|
|
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, active_extruder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1641,10 +1641,9 @@ inline void line_to_current_position() {
|
|
|
|
* Move the planner to the position stored in the destination array, which is
|
|
|
|
* Move the planner to the position stored in the destination array, which is
|
|
|
|
* used by G0/G1/G2/G3/G5 and many other functions to set a destination.
|
|
|
|
* used by G0/G1/G2/G3/G5 and many other functions to set a destination.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
inline void line_to_destination(const float fr_mm_s) {
|
|
|
|
inline void buffer_line_to_destination(const float fr_mm_s) {
|
|
|
|
planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], fr_mm_s, active_extruder);
|
|
|
|
planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], fr_mm_s, active_extruder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inline void line_to_destination() { line_to_destination(feedrate_mm_s); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void set_current_from_destination() { COPY(current_position, destination); }
|
|
|
|
inline void set_current_from_destination() { COPY(current_position, destination); }
|
|
|
|
inline void set_destination_from_current() { COPY(destination, current_position); }
|
|
|
|
inline void set_destination_from_current() { COPY(destination, current_position); }
|
|
|
@ -1772,19 +1771,19 @@ void do_blocking_move_to(const float &rx, const float &ry, const float &rz, cons
|
|
|
|
if (current_position[Z_AXIS] < rz) {
|
|
|
|
if (current_position[Z_AXIS] < rz) {
|
|
|
|
feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
|
|
|
|
feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
|
|
|
|
current_position[Z_AXIS] = rz;
|
|
|
|
current_position[Z_AXIS] = rz;
|
|
|
|
line_to_current_position();
|
|
|
|
buffer_line_to_current_position();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
|
|
|
|
feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
|
|
|
|
current_position[X_AXIS] = rx;
|
|
|
|
current_position[X_AXIS] = rx;
|
|
|
|
current_position[Y_AXIS] = ry;
|
|
|
|
current_position[Y_AXIS] = ry;
|
|
|
|
line_to_current_position();
|
|
|
|
buffer_line_to_current_position();
|
|
|
|
|
|
|
|
|
|
|
|
// If Z needs to lower, do it after moving XY
|
|
|
|
// If Z needs to lower, do it after moving XY
|
|
|
|
if (current_position[Z_AXIS] > rz) {
|
|
|
|
if (current_position[Z_AXIS] > rz) {
|
|
|
|
feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
|
|
|
|
feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
|
|
|
|
current_position[Z_AXIS] = rz;
|
|
|
|
current_position[Z_AXIS] = rz;
|
|
|
|
line_to_current_position();
|
|
|
|
buffer_line_to_current_position();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -3933,7 +3932,7 @@ inline void gcode_G4() {
|
|
|
|
// Move all carriages together linearly until an endstop is hit.
|
|
|
|
// Move all carriages together linearly until an endstop is hit.
|
|
|
|
current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (DELTA_HEIGHT + home_offset[Z_AXIS] + 10);
|
|
|
|
current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (DELTA_HEIGHT + home_offset[Z_AXIS] + 10);
|
|
|
|
feedrate_mm_s = homing_feedrate(X_AXIS);
|
|
|
|
feedrate_mm_s = homing_feedrate(X_AXIS);
|
|
|
|
line_to_current_position();
|
|
|
|
buffer_line_to_current_position();
|
|
|
|
stepper.synchronize();
|
|
|
|
stepper.synchronize();
|
|
|
|
|
|
|
|
|
|
|
|
// If an endstop was not hit, then damage can occur if homing is continued.
|
|
|
|
// If an endstop was not hit, then damage can occur if homing is continued.
|
|
|
@ -4264,27 +4263,20 @@ void home_all_axes() { gcode_G28(true); }
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
inline void _manual_goto_xy(const float &rx, const float &ry) {
|
|
|
|
inline void _manual_goto_xy(const float &rx, const float &ry) {
|
|
|
|
const float old_feedrate_mm_s = feedrate_mm_s;
|
|
|
|
|
|
|
|
#if MANUAL_PROBE_HEIGHT > 0
|
|
|
|
#if MANUAL_PROBE_HEIGHT > 0
|
|
|
|
const float prev_z = current_position[Z_AXIS];
|
|
|
|
const float prev_z = current_position[Z_AXIS];
|
|
|
|
feedrate_mm_s = homing_feedrate(Z_AXIS);
|
|
|
|
do_blocking_move_to_z(MANUAL_PROBE_HEIGHT, homing_feedrate(Z_AXIS));
|
|
|
|
current_position[Z_AXIS] = MANUAL_PROBE_HEIGHT;
|
|
|
|
|
|
|
|
line_to_current_position();
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
feedrate_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
|
|
|
|
do_blocking_move_to_xy(rx, ry, MMM_TO_MMS(XY_PROBE_SPEED));
|
|
|
|
current_position[X_AXIS] = rx;
|
|
|
|
|
|
|
|
current_position[Y_AXIS] = ry;
|
|
|
|
|
|
|
|
line_to_current_position();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if MANUAL_PROBE_HEIGHT > 0
|
|
|
|
#if MANUAL_PROBE_HEIGHT > 0
|
|
|
|
feedrate_mm_s = homing_feedrate(Z_AXIS);
|
|
|
|
do_blocking_move_to_z(prev_z, homing_feedrate(Z_AXIS));
|
|
|
|
current_position[Z_AXIS] = prev_z; // move back to the previous Z.
|
|
|
|
|
|
|
|
line_to_current_position();
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
feedrate_mm_s = old_feedrate_mm_s;
|
|
|
|
current_position[X_AXIS] = rx;
|
|
|
|
stepper.synchronize();
|
|
|
|
current_position[Y_AXIS] = ry;
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
|
|
|
|
#if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
|
|
|
|
lcd_wait_for_move = false;
|
|
|
|
lcd_wait_for_move = false;
|
|
|
@ -4314,7 +4306,7 @@ void home_all_axes() { gcode_G28(true); }
|
|
|
|
#if ENABLED(MESH_G28_REST_ORIGIN)
|
|
|
|
#if ENABLED(MESH_G28_REST_ORIGIN)
|
|
|
|
current_position[Z_AXIS] = Z_MIN_POS;
|
|
|
|
current_position[Z_AXIS] = Z_MIN_POS;
|
|
|
|
set_destination_from_current();
|
|
|
|
set_destination_from_current();
|
|
|
|
line_to_destination(homing_feedrate(Z_AXIS));
|
|
|
|
buffer_line_to_destination(homing_feedrate(Z_AXIS));
|
|
|
|
stepper.synchronize();
|
|
|
|
stepper.synchronize();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -4406,7 +4398,7 @@ void home_all_axes() { gcode_G28(true); }
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
// One last "return to the bed" (as originally coded) at completion
|
|
|
|
// One last "return to the bed" (as originally coded) at completion
|
|
|
|
current_position[Z_AXIS] = Z_MIN_POS + MANUAL_PROBE_HEIGHT;
|
|
|
|
current_position[Z_AXIS] = Z_MIN_POS + MANUAL_PROBE_HEIGHT;
|
|
|
|
line_to_current_position();
|
|
|
|
buffer_line_to_current_position();
|
|
|
|
stepper.synchronize();
|
|
|
|
stepper.synchronize();
|
|
|
|
|
|
|
|
|
|
|
|
// After recording the last point, activate home and activate
|
|
|
|
// After recording the last point, activate home and activate
|
|
|
@ -6563,17 +6555,13 @@ inline void gcode_M17() {
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
#define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder)
|
|
|
|
#define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder)
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S)
|
|
|
|
#define RUNPLAN(RATE_MM_S) buffer_line_to_destination(RATE_MM_S)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
void do_pause_e_move(const float &length, const float fr) {
|
|
|
|
void do_pause_e_move(const float &length, const float fr) {
|
|
|
|
current_position[E_AXIS] += length;
|
|
|
|
current_position[E_AXIS] += length;
|
|
|
|
set_destination_from_current();
|
|
|
|
set_destination_from_current();
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
RUNPLAN(fr);
|
|
|
|
planner.buffer_line_kinematic(destination, fr, active_extruder);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
line_to_destination(fr);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
stepper.synchronize();
|
|
|
|
stepper.synchronize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -12596,7 +12584,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|
|
|
* Prepare a mesh-leveled linear move in a Cartesian setup,
|
|
|
|
* Prepare a mesh-leveled linear move in a Cartesian setup,
|
|
|
|
* splitting the move where it crosses mesh borders.
|
|
|
|
* splitting the move where it crosses mesh borders.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void mesh_line_to_destination(float fr_mm_s, uint8_t x_splits = 0xFF, uint8_t y_splits = 0xFF) {
|
|
|
|
void mesh_line_to_destination(const float fr_mm_s, uint8_t x_splits = 0xFF, uint8_t y_splits = 0xFF) {
|
|
|
|
int cx1 = mbl.cell_index_x(current_position[X_AXIS]),
|
|
|
|
int cx1 = mbl.cell_index_x(current_position[X_AXIS]),
|
|
|
|
cy1 = mbl.cell_index_y(current_position[Y_AXIS]),
|
|
|
|
cy1 = mbl.cell_index_y(current_position[Y_AXIS]),
|
|
|
|
cx2 = mbl.cell_index_x(destination[X_AXIS]),
|
|
|
|
cx2 = mbl.cell_index_x(destination[X_AXIS]),
|
|
|
@ -12608,7 +12596,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|
|
|
|
|
|
|
|
|
|
|
if (cx1 == cx2 && cy1 == cy2) {
|
|
|
|
if (cx1 == cx2 && cy1 == cy2) {
|
|
|
|
// Start and end on same mesh square
|
|
|
|
// Start and end on same mesh square
|
|
|
|
line_to_destination(fr_mm_s);
|
|
|
|
buffer_line_to_destination(fr_mm_s);
|
|
|
|
set_current_from_destination();
|
|
|
|
set_current_from_destination();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -12635,7 +12623,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
// Already split on a border
|
|
|
|
// Already split on a border
|
|
|
|
line_to_destination(fr_mm_s);
|
|
|
|
buffer_line_to_destination(fr_mm_s);
|
|
|
|
set_current_from_destination();
|
|
|
|
set_current_from_destination();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -12659,7 +12647,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|
|
|
* Prepare a bilinear-leveled linear move on Cartesian,
|
|
|
|
* Prepare a bilinear-leveled linear move on Cartesian,
|
|
|
|
* splitting the move where it crosses grid borders.
|
|
|
|
* splitting the move where it crosses grid borders.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void bilinear_line_to_destination(float fr_mm_s, uint16_t x_splits = 0xFFFF, uint16_t y_splits = 0xFFFF) {
|
|
|
|
void bilinear_line_to_destination(const float fr_mm_s, uint16_t x_splits = 0xFFFF, uint16_t y_splits = 0xFFFF) {
|
|
|
|
int cx1 = CELL_INDEX(X, current_position[X_AXIS]),
|
|
|
|
int cx1 = CELL_INDEX(X, current_position[X_AXIS]),
|
|
|
|
cy1 = CELL_INDEX(Y, current_position[Y_AXIS]),
|
|
|
|
cy1 = CELL_INDEX(Y, current_position[Y_AXIS]),
|
|
|
|
cx2 = CELL_INDEX(X, destination[X_AXIS]),
|
|
|
|
cx2 = CELL_INDEX(X, destination[X_AXIS]),
|
|
|
@ -12671,7 +12659,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|
|
|
|
|
|
|
|
|
|
|
if (cx1 == cx2 && cy1 == cy2) {
|
|
|
|
if (cx1 == cx2 && cy1 == cy2) {
|
|
|
|
// Start and end on same mesh square
|
|
|
|
// Start and end on same mesh square
|
|
|
|
line_to_destination(fr_mm_s);
|
|
|
|
buffer_line_to_destination(fr_mm_s);
|
|
|
|
set_current_from_destination();
|
|
|
|
set_current_from_destination();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -12698,7 +12686,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
// Already split on a border
|
|
|
|
// Already split on a border
|
|
|
|
line_to_destination(fr_mm_s);
|
|
|
|
buffer_line_to_destination(fr_mm_s);
|
|
|
|
set_current_from_destination();
|
|
|
|
set_current_from_destination();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -12878,7 +12866,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // HAS_MESH
|
|
|
|
#endif // HAS_MESH
|
|
|
|
|
|
|
|
|
|
|
|
line_to_destination(MMS_SCALED(feedrate_mm_s));
|
|
|
|
buffer_line_to_destination(MMS_SCALED(feedrate_mm_s));
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|