Browse Source

Shortened mesh_plan_buffer_line()

pull/1/head
Edward Patel 9 years ago
parent
commit
c87faa69ed
  1. 95
      Marlin/Marlin_main.cpp

95
Marlin/Marlin_main.cpp

@ -5331,57 +5331,48 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
piy = MIN(piy, MESH_NUM_Y_POINTS-2); piy = MIN(piy, MESH_NUM_Y_POINTS-2);
ix = MIN(ix, MESH_NUM_X_POINTS-2); ix = MIN(ix, MESH_NUM_X_POINTS-2);
iy = MIN(iy, MESH_NUM_Y_POINTS-2); iy = MIN(iy, MESH_NUM_Y_POINTS-2);
if (ix > pix && (x_splits)&(1<<ix)) { if (pix == ix && piy == iy) {
float nx = mbl.get_x(ix); // Start and end on same mesh square
float normalized_dist = (nx - current_position[X_AXIS])/(x - current_position[X_AXIS]); plan_buffer_line(x, y, z, e, feed_rate, extruder);
float ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist; for(int8_t i=0; i < NUM_AXIS; i++) {
float ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist; current_position[i] = destination[i];
x_splits ^= 1 << ix; }
destination[X_AXIS] = nx;
destination[Y_AXIS] = ny;
destination[E_AXIS] = ne;
mesh_plan_buffer_line(nx, ny, z, ne, feed_rate, extruder, x_splits, y_splits);
destination[X_AXIS] = x;
destination[Y_AXIS] = y;
destination[E_AXIS] = e;
mesh_plan_buffer_line(x, y, z, e, feed_rate, extruder, x_splits, y_splits);
return;
} else if (ix < pix && (x_splits)&(1<<pix)) {
float nx = mbl.get_x(pix);
float normalized_dist = (nx - current_position[X_AXIS])/(x - current_position[X_AXIS]);
float ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
float ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
x_splits ^= 1 << pix;
destination[X_AXIS] = nx;
destination[Y_AXIS] = ny;
destination[E_AXIS] = ne;
mesh_plan_buffer_line(nx, ny, z, ne, feed_rate, extruder, x_splits, y_splits);
destination[X_AXIS] = x;
destination[Y_AXIS] = y;
destination[E_AXIS] = e;
mesh_plan_buffer_line(x, y, z, e, feed_rate, extruder, x_splits, y_splits);
return; return;
} else if (iy > piy && (y_splits)&(1<<iy)) { }
float ny = mbl.get_y(iy); float nx, ny, ne, normalized_dist;
float normalized_dist = (ny - current_position[Y_AXIS])/(y - current_position[Y_AXIS]); if (ix > pix && (x_splits) & BIT(ix)) {
float nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist; nx = mbl.get_x(ix);
float ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist; normalized_dist = (nx - current_position[X_AXIS])/(x - current_position[X_AXIS]);
y_splits ^= 1 << iy; ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
destination[X_AXIS] = nx; ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
destination[Y_AXIS] = ny; x_splits ^= BIT(ix);
destination[E_AXIS] = ne; } else if (ix < pix && (x_splits) & BIT(pix)) {
mesh_plan_buffer_line(nx, ny, z, ne, feed_rate, extruder, x_splits, y_splits); nx = mbl.get_x(pix);
destination[X_AXIS] = x; normalized_dist = (nx - current_position[X_AXIS])/(x - current_position[X_AXIS]);
destination[Y_AXIS] = y; ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
destination[E_AXIS] = e; ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
mesh_plan_buffer_line(x, y, z, e, feed_rate, extruder, x_splits, y_splits); x_splits ^= BIT(pix);
} else if (iy > piy && (y_splits) & BIT(iy)) {
ny = mbl.get_y(iy);
normalized_dist = (ny - current_position[Y_AXIS])/(y - current_position[Y_AXIS]);
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
y_splits ^= BIT(iy);
} else if (iy < piy && (y_splits) & BIT(piy)) {
ny = mbl.get_y(piy);
normalized_dist = (ny - current_position[Y_AXIS])/(y - current_position[Y_AXIS]);
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
y_splits ^= BIT(piy);
} else {
// Already split on a border
plan_buffer_line(x, y, z, e, feed_rate, extruder);
for(int8_t i=0; i < NUM_AXIS; i++) {
current_position[i] = destination[i];
}
return; return;
} else if (iy < piy && (y_splits)&(1<<piy)) { }
float ny = mbl.get_y(piy); // Do the split and look for more borders
float normalized_dist = (ny - current_position[Y_AXIS])/(y - current_position[Y_AXIS]);
float nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
float ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
y_splits ^= 1 << piy;
destination[X_AXIS] = nx; destination[X_AXIS] = nx;
destination[Y_AXIS] = ny; destination[Y_AXIS] = ny;
destination[E_AXIS] = ne; destination[E_AXIS] = ne;
@ -5390,12 +5381,6 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
destination[Y_AXIS] = y; destination[Y_AXIS] = y;
destination[E_AXIS] = e; destination[E_AXIS] = e;
mesh_plan_buffer_line(x, y, z, e, feed_rate, extruder, x_splits, y_splits); mesh_plan_buffer_line(x, y, z, e, feed_rate, extruder, x_splits, y_splits);
return;
}
plan_buffer_line(x, y, z, e, feed_rate, extruder);
for(int8_t i=0; i < NUM_AXIS; i++) {
current_position[i] = destination[i];
}
} }
#endif // MESH_BED_LEVELING #endif // MESH_BED_LEVELING

Loading…
Cancel
Save