Procházet zdrojové kódy

Reduce code size of mesh_buffer_line

Scott Lahteine před 9 roky
rodič
revize
697373b071
1 změnil soubory, kde provedl 11 přidání a 24 odebrání
  1. 11
    24
      Marlin/Marlin_main.cpp

+ 11
- 24
Marlin/Marlin_main.cpp Zobrazit soubor

@@ -7848,46 +7848,33 @@ void mesh_buffer_line(float x, float y, float z, const float e, float fr_mm_s, c
7848 7848
       cy = mbl.cell_index_y(RAW_POSITION(y, Y_AXIS));
7849 7849
   NOMORE(pcx, MESH_NUM_X_POINTS - 2);
7850 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 7854
   if (pcx == cx && pcy == cy) {
7854 7855
     // Start and end on same mesh square
7855 7856
     planner.buffer_line(x, y, z, e, fr_mm_s, extruder);
7856 7857
     set_current_to_destination();
7857 7858
     return;
7858 7859
   }
7860
+
7859 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 7865
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
7871 7866
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
7872 7867
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7873 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 7873
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
7887 7874
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
7888 7875
     nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist;
7889 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 7879
   else {
7893 7880
     // Already split on a border

Loading…
Zrušit
Uložit