Browse Source

Merge pull request #1503 from MarcelMo/patch-2

Support for simple customisable AutoZProbing area
alexborro 9 years ago
parent
commit
227ab8c665
1 changed files with 28 additions and 14 deletions
  1. 28
    14
      Marlin/Marlin_main.cpp

+ 28
- 14
Marlin/Marlin_main.cpp View File

@@ -1720,6 +1720,7 @@ void process_commands()
1720 1720
 
1721 1721
 #ifdef ENABLE_AUTO_BED_LEVELING
1722 1722
     case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points.
1723
+    	     // Override probing area by providing [F]ront [B]ack [L]eft [R]ight Grid[P]oints values
1723 1724
         {
1724 1725
             #if Z_MIN_PIN == -1
1725 1726
             #error "You must have a Z_MIN endstop in order to enable Auto Bed Leveling feature!!! Z_MIN_PIN must point to a valid hardware pin."
@@ -1733,6 +1734,16 @@ void process_commands()
1733 1734
                 SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
1734 1735
                 break; // abort G29, since we don't know where we are
1735 1736
             }
1737
+            int left_probe_bed_position=LEFT_PROBE_BED_POSITION;
1738
+            int right_probe_bed_position=RIGHT_PROBE_BED_POSITION;
1739
+            int back_probe_bed_position=BACK_PROBE_BED_POSITION;
1740
+            int front_probe_bed_position=FRONT_PROBE_BED_POSITION;
1741
+            int auto_bed_leveling_grid_points=AUTO_BED_LEVELING_GRID_POINTS;
1742
+            if (code_seen('L')) left_probe_bed_position=(int)code_value();
1743
+            if (code_seen('R')) right_probe_bed_position=(int)code_value();
1744
+            if (code_seen('B')) back_probe_bed_position=(int)code_value();
1745
+            if (code_seen('F')) front_probe_bed_position=(int)code_value();
1746
+            if (code_seen('P')) auto_bed_leveling_grid_points=(int)code_value();
1736 1747
 
1737 1748
 #ifdef Z_PROBE_SLED
1738 1749
             dock_sled(false);
@@ -1754,8 +1765,8 @@ void process_commands()
1754 1765
 #ifdef AUTO_BED_LEVELING_GRID
1755 1766
             // probe at the points of a lattice grid
1756 1767
 
1757
-            int xGridSpacing = (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION) / (AUTO_BED_LEVELING_GRID_POINTS-1);
1758
-            int yGridSpacing = (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION) / (AUTO_BED_LEVELING_GRID_POINTS-1);
1768
+            int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points-1);
1769
+            int yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points-1);
1759 1770
 
1760 1771
 
1761 1772
             // solve the plane equation ax + by + d = z
@@ -1765,32 +1776,35 @@ void process_commands()
1765 1776
             // so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
1766 1777
 
1767 1778
             // "A" matrix of the linear system of equations
1768
-            double eqnAMatrix[AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS*3];
1779
+            double eqnAMatrix[auto_bed_leveling_grid_points*auto_bed_leveling_grid_points*3];
1780
+
1769 1781
             // "B" vector of Z points
1770
-            double eqnBVector[AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS];
1782
+            double eqnBVector[auto_bed_leveling_grid_points*auto_bed_leveling_grid_points];
1783
+
1771 1784
 
1772 1785
 
1773 1786
             int probePointCounter = 0;
1774 1787
             bool zig = true;
1775 1788
 
1776
-            for (int yProbe=FRONT_PROBE_BED_POSITION; yProbe <= BACK_PROBE_BED_POSITION; yProbe += yGridSpacing)
1789
+            for (int yProbe=front_probe_bed_position; yProbe <= back_probe_bed_position; yProbe += yGridSpacing)
1790
+
1777 1791
             {
1778 1792
               int xProbe, xInc;
1779 1793
               if (zig)
1780 1794
               {
1781
-                xProbe = LEFT_PROBE_BED_POSITION;
1782
-                //xEnd = RIGHT_PROBE_BED_POSITION;
1795
+                xProbe = left_probe_bed_position;
1796
+                //xEnd = right_probe_bed_position;
1783 1797
                 xInc = xGridSpacing;
1784 1798
                 zig = false;
1785 1799
               } else // zag
1786 1800
               {
1787
-                xProbe = RIGHT_PROBE_BED_POSITION;
1788
-                //xEnd = LEFT_PROBE_BED_POSITION;
1801
+                xProbe = right_probe_bed_position;
1802
+                //xEnd = left_probe_bed_position;
1789 1803
                 xInc = -xGridSpacing;
1790 1804
                 zig = true;
1791 1805
               }
1792 1806
 
1793
-              for (int xCount=0; xCount < AUTO_BED_LEVELING_GRID_POINTS; xCount++)
1807
+              for (int xCount=0; xCount < auto_bed_leveling_grid_points; xCount++)
1794 1808
               {
1795 1809
                 float z_before;
1796 1810
                 if (probePointCounter == 0)
@@ -1822,9 +1836,9 @@ void process_commands()
1822 1836
 
1823 1837
                 eqnBVector[probePointCounter] = measured_z;
1824 1838
 
1825
-                eqnAMatrix[probePointCounter + 0*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = xProbe;
1826
-                eqnAMatrix[probePointCounter + 1*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = yProbe;
1827
-                eqnAMatrix[probePointCounter + 2*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = 1;
1839
+                eqnAMatrix[probePointCounter + 0*auto_bed_leveling_grid_points*auto_bed_leveling_grid_points] = xProbe;
1840
+                eqnAMatrix[probePointCounter + 1*auto_bed_leveling_grid_points*auto_bed_leveling_grid_points] = yProbe;
1841
+                eqnAMatrix[probePointCounter + 2*auto_bed_leveling_grid_points*auto_bed_leveling_grid_points] = 1;
1828 1842
                 probePointCounter++;
1829 1843
                 xProbe += xInc;
1830 1844
               }
@@ -1832,7 +1846,7 @@ void process_commands()
1832 1846
             clean_up_after_endstop_move();
1833 1847
 
1834 1848
             // solve lsq problem
1835
-            double *plane_equation_coefficients = qr_solve(AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS, 3, eqnAMatrix, eqnBVector);
1849
+            double *plane_equation_coefficients = qr_solve(auto_bed_leveling_grid_points*auto_bed_leveling_grid_points, 3, eqnAMatrix, eqnBVector);
1836 1850
 
1837 1851
             SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
1838 1852
             SERIAL_PROTOCOL(plane_equation_coefficients[0]);

Loading…
Cancel
Save