Selaa lähdekoodia

Reduce code size of mesh_buffer_line

Scott Lahteine 9 vuotta sitten
vanhempi
commit
697373b071
1 muutettua tiedostoa jossa 11 lisäystä ja 24 poistoa
  1. 11
    24
      Marlin/Marlin_main.cpp

+ 11
- 24
Marlin/Marlin_main.cpp Näytä tiedosto

7848
       cy = mbl.cell_index_y(RAW_POSITION(y, Y_AXIS));
7848
       cy = mbl.cell_index_y(RAW_POSITION(y, Y_AXIS));
7849
   NOMORE(pcx, MESH_NUM_X_POINTS - 2);
7849
   NOMORE(pcx, MESH_NUM_X_POINTS - 2);
7850
   NOMORE(pcy, MESH_NUM_Y_POINTS - 2);
7850
   NOMORE(pcy, MESH_NUM_Y_POINTS - 2);
7851
-  NOMORE(cx,  MESH_NUM_X_POINTS - 2);
7852
-  NOMORE(cy,  MESH_NUM_Y_POINTS - 2);
7851
+  NOMORE(cx, MESH_NUM_X_POINTS - 2);
7852
+  NOMORE(cy, MESH_NUM_Y_POINTS - 2);
7853
+
7853
   if (pcx == cx && pcy == cy) {
7854
   if (pcx == cx && pcy == cy) {
7854
     // Start and end on same mesh square
7855
     // Start and end on same mesh square
7855
     planner.buffer_line(x, y, z, e, fr_mm_s, extruder);
7856
     planner.buffer_line(x, y, z, e, fr_mm_s, extruder);
7856
     set_current_to_destination();
7857
     set_current_to_destination();
7857
     return;
7858
     return;
7858
   }
7859
   }
7860
+
7859
   float nx, ny, nz, ne, normalized_dist;
7861
   float nx, ny, nz, ne, normalized_dist;
7860
-  if (cx > pcx && TEST(x_splits, cx)) {
7861
-    nx = mbl.get_probe_x(cx) + home_offset[X_AXIS] + position_shift[X_AXIS];
7862
-    normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
7863
-    ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
7864
-    nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7865
-    ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
7866
-    CBI(x_splits, cx);
7867
-  }
7868
-  else if (cx < pcx && TEST(x_splits, pcx)) {
7869
-    nx = mbl.get_probe_x(pcx) + home_offset[X_AXIS] + position_shift[X_AXIS];
7862
+  int8_t gcx = max(pcx, cx), gcy = max(pcy, cy);
7863
+  if (cx != pcx && TEST(x_splits, gcx)) {
7864
+    nx = mbl.get_probe_x(gcx) + home_offset[X_AXIS] + position_shift[X_AXIS];
7870
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
7865
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
7871
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
7866
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
7872
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7867
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7873
     ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
7868
     ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
7874
-    CBI(x_splits, pcx);
7875
-  }
7876
-  else if (cy > pcy && TEST(y_splits, cy)) {
7877
-    ny = mbl.get_probe_y(cy) + home_offset[Y_AXIS] + position_shift[Y_AXIS];
7878
-    normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
7879
-    nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
7880
-    nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7881
-    ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
7882
-    CBI(y_splits, cy);
7869
+    CBI(x_splits, gcx);
7883
   }
7870
   }
7884
-  else if (cy < pcy && TEST(y_splits, pcy)) {
7885
-    ny = mbl.get_probe_y(pcy) + home_offset[Y_AXIS] + position_shift[Y_AXIS];
7871
+  else if (cy != pcy && TEST(y_splits, gcy)) {
7872
+    ny = mbl.get_probe_y(gcy) + home_offset[Y_AXIS] + position_shift[Y_AXIS];
7886
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
7873
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
7887
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
7874
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
7888
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7875
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7889
     ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
7876
     ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
7890
-    CBI(y_splits, pcy);
7877
+    CBI(y_splits, gcy);
7891
   }
7878
   }
7892
   else {
7879
   else {
7893
     // Already split on a border
7880
     // Already split on a border

Loading…
Peruuta
Tallenna