Przeglądaj źródła

Patch up bilinear_z_offset

Scott Lahteine 8 lat temu
rodzic
commit
d066610514
2 zmienionych plików z 35 dodań i 16 usunięć
  1. 6
    1
      Marlin/Conditionals_post.h
  2. 29
    15
      Marlin/Marlin_main.cpp

+ 6
- 1
Marlin/Conditionals_post.h Wyświetl plik

@@ -648,8 +648,13 @@
648 648
   #define ABL_GRID   (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR))
649 649
   #define HAS_ABL    (ABL_PLANAR || ABL_GRID)
650 650
 
651
-  #define HAS_PROBING_PROCEDURE (HAS_ABL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))
652 651
   #define PLANNER_LEVELING      (HAS_ABL || ENABLED(MESH_BED_LEVELING))
652
+  #define HAS_PROBING_PROCEDURE (HAS_ABL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))
653
+
654
+  #if HAS_PROBING_PROCEDURE
655
+    #define PROBE_BED_WIDTH abs(RIGHT_PROBE_BED_POSITION - (LEFT_PROBE_BED_POSITION))
656
+    #define PROBE_BED_HEIGHT abs(BACK_PROBE_BED_POSITION - (FRONT_PROBE_BED_POSITION))
657
+  #endif
653 658
 
654 659
   /**
655 660
    * Buzzer/Speaker

+ 29
- 15
Marlin/Marlin_main.cpp Wyświetl plik

@@ -7997,36 +7997,50 @@ void ok_to_send() {
7997 7997
           ratio_y = y / bilinear_grid_spacing[Y_AXIS];
7998 7998
 
7999 7999
     // Whole unit is the grid box index
8000
-    int gridx = constrain(int(ratio_x), 0, ABL_GRID_POINTS_X - 2),
8001
-        gridy = constrain(int(ratio_y), 0, ABL_GRID_POINTS_Y - 2);
8000
+    const int gridx = constrain(floor(ratio_x), 0, ABL_GRID_POINTS_X - 2),
8001
+              gridy = constrain(floor(ratio_y), 0, ABL_GRID_POINTS_Y - 2),
8002
+              nextx = gridx + (x < PROBE_BED_WIDTH ? 1 : 0),
8003
+              nexty = gridy + (y < PROBE_BED_HEIGHT ? 1 : 0);
8002 8004
 
8003 8005
     // Subtract whole to get the ratio within the grid box
8004
-    ratio_x -= gridx, ratio_y -= gridy;
8006
+    ratio_x = constrain(ratio_x - gridx, 0.0, 1.0);
8007
+    ratio_y = constrain(ratio_y - gridy, 0.0, 1.0);
8005 8008
 
8006
-          // Z at the box corners
8007
-    const float z1 = bed_level_grid[gridx][gridy],         // left-front
8008
-                z2 = bed_level_grid[gridx][gridy + 1],     // left-back
8009
-                z3 = bed_level_grid[gridx + 1][gridy],     // right-front
8010
-                z4 = bed_level_grid[gridx + 1][gridy + 1], // right-back
8009
+    // Z at the box corners
8010
+    const float z1 = bed_level_grid[gridx][gridy],  // left-front
8011
+                z2 = bed_level_grid[gridx][nexty],  // left-back
8012
+                z3 = bed_level_grid[nextx][gridy],  // right-front
8013
+                z4 = bed_level_grid[nextx][nexty],  // right-back
8011 8014
 
8015
+                // Bilinear interpolate
8012 8016
                 L = z1 + (z2 - z1) * ratio_y,   // Linear interp. LF -> LB
8013
-                R = z3 + (z4 - z3) * ratio_y;   // Linear interp. RF -> RB
8017
+                R = z3 + (z4 - z3) * ratio_y,   // Linear interp. RF -> RB
8018
+                offset = L + ratio_x * (R - L);
8014 8019
 
8015 8020
     /*
8016
-      SERIAL_ECHOPAIR("gridx=", gridx);
8017
-      SERIAL_ECHOPAIR(" gridy=", gridy);
8021
+    static float last_offset = 0;
8022
+    if (fabs(last_offset - offset) > 0.2) {
8023
+      SERIAL_ECHOPGM("Sudden Shift at ");
8024
+      SERIAL_ECHOPAIR("x=", x);
8025
+      SERIAL_ECHOPAIR(" / ", bilinear_grid_spacing[X_AXIS]);
8026
+      SERIAL_ECHOLNPAIR(" -> gridx=", gridx);
8027
+      SERIAL_ECHOPAIR(" y=", y);
8028
+      SERIAL_ECHOPAIR(" / ", bilinear_grid_spacing[Y_AXIS]);
8029
+      SERIAL_ECHOLNPAIR(" -> gridy=", gridy);
8018 8030
       SERIAL_ECHOPAIR(" ratio_x=", ratio_x);
8019
-      SERIAL_ECHOPAIR(" ratio_y=", ratio_y);
8031
+      SERIAL_ECHOLNPAIR(" ratio_y=", ratio_y);
8020 8032
       SERIAL_ECHOPAIR(" z1=", z1);
8021 8033
       SERIAL_ECHOPAIR(" z2=", z2);
8022 8034
       SERIAL_ECHOPAIR(" z3=", z3);
8023
-      SERIAL_ECHOPAIR(" z4=", z4);
8035
+      SERIAL_ECHOLNPAIR(" z4=", z4);
8024 8036
       SERIAL_ECHOPAIR(" L=", L);
8025 8037
       SERIAL_ECHOPAIR(" R=", R);
8026
-      SERIAL_ECHOPAIR(" offset=", L + ratio_x * (R - L));
8038
+      SERIAL_ECHOLNPAIR(" offset=", offset);
8039
+    }
8040
+    last_offset = offset;
8027 8041
     //*/
8028 8042
 
8029
-    return L + ratio_x * (R - L);
8043
+    return offset;
8030 8044
   }
8031 8045
 
8032 8046
 #endif // AUTO_BED_LEVELING_BILINEAR

Ładowanie…
Anuluj
Zapisz