|
@@ -7831,76 +7831,59 @@ void clamp_to_software_endstops(float target[3]) {
|
7831
|
7831
|
#if ENABLED(MESH_BED_LEVELING)
|
7832
|
7832
|
|
7833
|
7833
|
// This function is used to split lines on mesh borders so each segment is only part of one mesh area
|
7834
|
|
-void mesh_buffer_line(float x, float y, float z, const float e, float fr_mm_s, const uint8_t& extruder, uint8_t x_splits = 0xff, uint8_t y_splits = 0xff) {
|
7835
|
|
- if (!mbl.active()) {
|
7836
|
|
- planner.buffer_line(x, y, z, e, fr_mm_s, extruder);
|
7837
|
|
- set_current_to_destination();
|
7838
|
|
- return;
|
7839
|
|
- }
|
7840
|
|
- int pcx = mbl.cell_index_x(RAW_CURRENT_POSITION(X_AXIS)),
|
7841
|
|
- pcy = mbl.cell_index_y(RAW_CURRENT_POSITION(Y_AXIS)),
|
7842
|
|
- cx = mbl.cell_index_x(RAW_POSITION(x, X_AXIS)),
|
7843
|
|
- cy = mbl.cell_index_y(RAW_POSITION(y, Y_AXIS));
|
7844
|
|
- NOMORE(pcx, MESH_NUM_X_POINTS - 2);
|
7845
|
|
- NOMORE(pcy, MESH_NUM_Y_POINTS - 2);
|
7846
|
|
- NOMORE(cx, MESH_NUM_X_POINTS - 2);
|
7847
|
|
- NOMORE(cy, MESH_NUM_Y_POINTS - 2);
|
7848
|
|
- if (pcx == cx && pcy == cy) {
|
|
7834
|
+void mesh_line_to_destination(float fr_mm_m, uint8_t x_splits = 0xff, uint8_t y_splits = 0xff) {
|
|
7835
|
+ int cx1 = mbl.cell_index_x(RAW_CURRENT_POSITION(X_AXIS)),
|
|
7836
|
+ cy1 = mbl.cell_index_y(RAW_CURRENT_POSITION(Y_AXIS)),
|
|
7837
|
+ cx2 = mbl.cell_index_x(RAW_POSITION(destination[X_AXIS], X_AXIS)),
|
|
7838
|
+ cy2 = mbl.cell_index_y(RAW_POSITION(destination[Y_AXIS], Y_AXIS));
|
|
7839
|
+ NOMORE(cx1, MESH_NUM_X_POINTS - 2);
|
|
7840
|
+ NOMORE(cy1, MESH_NUM_Y_POINTS - 2);
|
|
7841
|
+ NOMORE(cx2, MESH_NUM_X_POINTS - 2);
|
|
7842
|
+ NOMORE(cy2, MESH_NUM_Y_POINTS - 2);
|
|
7843
|
+
|
|
7844
|
+ if (cx1 == cx2 && cy1 == cy2) {
|
7849
|
7845
|
// Start and end on same mesh square
|
7850
|
|
- planner.buffer_line(x, y, z, e, fr_mm_s, extruder);
|
|
7846
|
+ line_to_destination(fr_mm_m);
|
7851
|
7847
|
set_current_to_destination();
|
7852
|
7848
|
return;
|
7853
|
7849
|
}
|
7854
|
|
- float nx, ny, nz, ne, normalized_dist;
|
7855
|
|
- if (cx > pcx && TEST(x_splits, cx)) {
|
7856
|
|
- nx = mbl.get_probe_x(cx) + home_offset[X_AXIS];
|
7857
|
|
- normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
|
7858
|
|
- ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
|
7859
|
|
- nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|
7860
|
|
- ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
|
7861
|
|
- CBI(x_splits, cx);
|
7862
|
|
- }
|
7863
|
|
- else if (cx < pcx && TEST(x_splits, pcx)) {
|
7864
|
|
- nx = mbl.get_probe_x(pcx) + home_offset[X_AXIS];
|
7865
|
|
- normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
|
7866
|
|
- ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
|
7867
|
|
- nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|
7868
|
|
- ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
|
7869
|
|
- CBI(x_splits, pcx);
|
7870
|
|
- }
|
7871
|
|
- else if (cy > pcy && TEST(y_splits, cy)) {
|
7872
|
|
- ny = mbl.get_probe_y(cy) + home_offset[Y_AXIS];
|
7873
|
|
- normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
|
7874
|
|
- nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
|
7875
|
|
- nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|
7876
|
|
- ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
|
7877
|
|
- CBI(y_splits, cy);
|
7878
|
|
- }
|
7879
|
|
- else if (cy < pcy && TEST(y_splits, pcy)) {
|
7880
|
|
- ny = mbl.get_probe_y(pcy) + home_offset[Y_AXIS];
|
7881
|
|
- normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
|
7882
|
|
- nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
|
7883
|
|
- nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
|
7884
|
|
- ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
|
7885
|
|
- CBI(y_splits, pcy);
|
|
7850
|
+
|
|
7851
|
+ #define MBL_SEGMENT_END(A) (current_position[A ##_AXIS] + (destination[A ##_AXIS] - current_position[A ##_AXIS]) * normalized_dist)
|
|
7852
|
+
|
|
7853
|
+ float normalized_dist, end[NUM_AXIS];
|
|
7854
|
+
|
|
7855
|
+ // Split at the left/front border of the right/top square
|
|
7856
|
+ int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
|
|
7857
|
+ if (cx2 != cx1 && TEST(x_splits, gcx)) {
|
|
7858
|
+ memcpy(end, destination, sizeof(end));
|
|
7859
|
+ destination[X_AXIS] = mbl.get_probe_x(gcx) + home_offset[X_AXIS] + position_shift[X_AXIS];
|
|
7860
|
+ normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
|
|
7861
|
+ destination[Y_AXIS] = MBL_SEGMENT_END(Y);
|
|
7862
|
+ CBI(x_splits, gcx);
|
|
7863
|
+ }
|
|
7864
|
+ else if (cy2 != cy1 && TEST(y_splits, gcy)) {
|
|
7865
|
+ memcpy(end, destination, sizeof(end));
|
|
7866
|
+ destination[Y_AXIS] = mbl.get_probe_y(gcy) + home_offset[Y_AXIS] + position_shift[Y_AXIS];
|
|
7867
|
+ normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
|
|
7868
|
+ destination[X_AXIS] = MBL_SEGMENT_END(X);
|
|
7869
|
+ CBI(y_splits, gcy);
|
7886
|
7870
|
}
|
7887
|
7871
|
else {
|
7888
|
7872
|
// Already split on a border
|
7889
|
|
- planner.buffer_line(x, y, z, e, fr_mm_s, extruder);
|
|
7873
|
+ line_to_destination(fr_mm_m);
|
7890
|
7874
|
set_current_to_destination();
|
7891
|
7875
|
return;
|
7892
|
7876
|
}
|
|
7877
|
+
|
|
7878
|
+ destination[Z_AXIS] = MBL_SEGMENT_END(Z);
|
|
7879
|
+ destination[E_AXIS] = MBL_SEGMENT_END(E);
|
|
7880
|
+
|
7893
|
7881
|
// Do the split and look for more borders
|
7894
|
|
- destination[X_AXIS] = nx;
|
7895
|
|
- destination[Y_AXIS] = ny;
|
7896
|
|
- destination[Z_AXIS] = nz;
|
7897
|
|
- destination[E_AXIS] = ne;
|
7898
|
|
- mesh_buffer_line(nx, ny, nz, ne, fr_mm_s, extruder, x_splits, y_splits);
|
7899
|
|
- destination[X_AXIS] = x;
|
7900
|
|
- destination[Y_AXIS] = y;
|
7901
|
|
- destination[Z_AXIS] = z;
|
7902
|
|
- destination[E_AXIS] = e;
|
7903
|
|
- mesh_buffer_line(x, y, z, e, fr_mm_s, extruder, x_splits, y_splits);
|
|
7882
|
+ mesh_line_to_destination(fr_mm_m, x_splits, y_splits);
|
|
7883
|
+
|
|
7884
|
+ // Restore destination from stack
|
|
7885
|
+ memcpy(destination, end, sizeof(end));
|
|
7886
|
+ mesh_line_to_destination(fr_mm_m, x_splits, y_splits);
|
7904
|
7887
|
}
|
7905
|
7888
|
#endif // MESH_BED_LEVELING
|
7906
|
7889
|
|
|
@@ -7997,11 +7980,13 @@ void mesh_buffer_line(float x, float y, float z, const float e, float fr_mm_s, c
|
7997
|
7980
|
}
|
7998
|
7981
|
else {
|
7999
|
7982
|
#if ENABLED(MESH_BED_LEVELING)
|
8000
|
|
- mesh_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], MMM_TO_MMS_SCALED(feedrate_mm_m), active_extruder);
|
8001
|
|
- return false;
|
8002
|
|
- #else
|
8003
|
|
- line_to_destination(MMM_SCALED(feedrate_mm_m));
|
|
7983
|
+ if (mbl.active()) {
|
|
7984
|
+ mesh_line_to_destination(MMM_SCALED(feedrate_mm_m));
|
|
7985
|
+ return false;
|
|
7986
|
+ }
|
|
7987
|
+ else
|
8004
|
7988
|
#endif
|
|
7989
|
+ line_to_destination(MMM_SCALED(feedrate_mm_m));
|
8005
|
7990
|
}
|
8006
|
7991
|
return true;
|
8007
|
7992
|
}
|