Browse Source

Cleanup after vim and vigor

Scott Lahteine 7 years ago
parent
commit
89165326b4
2 changed files with 76 additions and 77 deletions
  1. 1
    1
      Marlin/src/feature/bedlevel/ubl/ubl.h
  2. 75
    76
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

+ 1
- 1
Marlin/src/feature/bedlevel/ubl/ubl.h View File

@@ -83,7 +83,7 @@ class unified_bed_leveling {
83 83
     #if ENABLED(NEWPANEL)
84 84
       static void move_z_with_encoder(const float &multiplier);
85 85
       static float measure_point_with_encoder();
86
-      static float measure_business_card_thickness(float);
86
+      static float measure_business_card_thickness(float in_height);
87 87
       static void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
88 88
       static void fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map);
89 89
     #endif

+ 75
- 76
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

@@ -51,7 +51,7 @@
51 51
 
52 52
   #if ENABLED(NEWPANEL)
53 53
     void lcd_return_to_status();
54
-    extern void _lcd_ubl_output_map_lcd();
54
+    void _lcd_ubl_output_map_lcd();
55 55
   #endif
56 56
 
57 57
   extern float meshedit_done;
@@ -96,8 +96,8 @@
96 96
    *                    previous measurements.
97 97
    *
98 98
    *   C                G29 P2 C tells the Manual Probe subsystem to not use the current nozzle
99
-   *                    location in its search for the closest unmeasured Mesh Point.  Instead, attempt to
100
-   *                    start at one end of the uprobed points and Continue sequentually.
99
+   *                    location in its search for the closest unmeasured Mesh Point. Instead, attempt to
100
+   *                    start at one end of the uprobed points and Continue sequentially.
101 101
    *
102 102
    *                    G29 P3 C specifies the Constant for the fill. Otherwise, uses a "reasonable" value.
103 103
    *
@@ -1038,12 +1038,12 @@
1038 1038
 
1039 1039
   static uint8_t ubl_state_at_invocation = 0;
1040 1040
 
1041
-  #if ENABLED(UBL_DEVEL_DEBUGGING)
1041
+  #ifdef UBL_DEVEL_DEBUGGING
1042 1042
     static uint8_t ubl_state_recursion_chk = 0;
1043 1043
   #endif
1044 1044
 
1045 1045
   void unified_bed_leveling::save_ubl_active_state_and_disable() {
1046
-    #if ENABLED(UBL_DEVEL_DEBUGGING)
1046
+    #ifdef UBL_DEVEL_DEBUGGING
1047 1047
       ubl_state_recursion_chk++;
1048 1048
       if (ubl_state_recursion_chk != 1) {
1049 1049
         SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
@@ -1059,7 +1059,7 @@
1059 1059
   }
1060 1060
 
1061 1061
   void unified_bed_leveling::restore_ubl_active_state_and_leave() {
1062
-    #if ENABLED(UBL_DEVEL_DEBUGGING)
1062
+    #ifdef UBL_DEVEL_DEBUGGING
1063 1063
       if (--ubl_state_recursion_chk) {
1064 1064
         SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
1065 1065
         #if ENABLED(NEWPANEL)
@@ -1143,7 +1143,7 @@
1143 1143
     SERIAL_EOL();
1144 1144
     safe_delay(50);
1145 1145
 
1146
-    #if ENABLED(UBL_DEVEL_DEBUGGING)
1146
+    #ifdef UBL_DEVEL_DEBUGGING
1147 1147
       SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
1148 1148
       SERIAL_EOL();
1149 1149
       SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
@@ -1257,22 +1257,22 @@
1257 1257
 
1258 1258
           found_a_NAN = true;
1259 1259
 
1260
-          int8_t closest_x=-1, closest_y=-1;
1260
+          int8_t closest_x = -1, closest_y = -1;
1261 1261
           float d1, d2 = 99999.9;
1262 1262
           for (int8_t k = 0; k < GRID_MAX_POINTS_X; k++) {
1263 1263
             for (int8_t l = 0; l < GRID_MAX_POINTS_Y; l++) {
1264 1264
               if (!isnan(z_values[k][l])) {
1265 1265
                 found_a_real = true;
1266 1266
 
1267
-          // Add in a random weighting factor that scrambles the probing of the
1268
-          // last half of the mesh (when every unprobed mesh point is one index
1269
-          // from a probed location).
1267
+                // Add in a random weighting factor that scrambles the probing of the
1268
+                // last half of the mesh (when every unprobed mesh point is one index
1269
+                // from a probed location).
1270 1270
 
1271 1271
                 d1 = HYPOT(i - k, j - l) + (1.0 / ((millis() % 47) + 13));
1272 1272
 
1273 1273
                 if (d1 < d2) {    // found a closer distance from invalid mesh point at (i,j) to defined mesh point at (k,l)
1274
-                  d2 = d1;       // found a closer location with
1275
-                  closest_x = i;    // an assigned mesh point value
1274
+                  d2 = d1;        // found a closer location with
1275
+                  closest_x = i;  // an assigned mesh point value
1276 1276
                   closest_y = j;
1277 1277
                 }
1278 1278
               }
@@ -1280,7 +1280,7 @@
1280 1280
           }
1281 1281
 
1282 1282
           //
1283
-          // at this point d2 should have the closest defined mesh point to invalid mesh point (i,j)
1283
+          // At this point d2 should have the closest defined mesh point to invalid mesh point (i,j)
1284 1284
           //
1285 1285
 
1286 1286
           if (found_a_real && (closest_x >= 0) && (d2 > out_mesh.distance)) {
@@ -1523,7 +1523,7 @@
1523 1523
                         y_min = max(MIN_PROBE_Y, MESH_MIN_Y),
1524 1524
                         y_max = min(MAX_PROBE_Y, MESH_MAX_Y);
1525 1525
 
1526
-      bool abort_flag=false;
1526
+      bool abort_flag = false;
1527 1527
 
1528 1528
       float measured_z;
1529 1529
 
@@ -1532,7 +1532,7 @@
1532 1532
 
1533 1533
       struct linear_fit_data lsf_results;
1534 1534
 
1535
-//    float z1, z2, z3;  // Needed for algorithm validation down below.
1535
+      //float z1, z2, z3;  // Needed for algorithm validation down below.
1536 1536
 
1537 1537
       incremental_LSF_reset(&lsf_results);
1538 1538
 
@@ -1542,8 +1542,8 @@
1542 1542
           abort_flag = true;
1543 1543
         else {
1544 1544
           measured_z -= get_z_correction(UBL_PROBE_PT_1_X, UBL_PROBE_PT_1_Y);
1545
-//        z1 = measured_z;
1546
-          if (g29_verbose_level>3) {
1545
+          //z1 = measured_z;
1546
+          if (g29_verbose_level > 3) {
1547 1547
             serial_spaces(16);
1548 1548
             SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z);
1549 1549
           }
@@ -1552,12 +1552,12 @@
1552 1552
 
1553 1553
         if (!abort_flag) {
1554 1554
           measured_z = probe_pt(UBL_PROBE_PT_2_X, UBL_PROBE_PT_2_Y, false, g29_verbose_level);
1555
-//        z2 = measured_z;
1555
+          //z2 = measured_z;
1556 1556
           if (isnan(measured_z))
1557 1557
             abort_flag = true;
1558 1558
           else {
1559 1559
             measured_z -= get_z_correction(UBL_PROBE_PT_2_X, UBL_PROBE_PT_2_Y);
1560
-            if (g29_verbose_level>3) {
1560
+            if (g29_verbose_level > 3) {
1561 1561
               serial_spaces(16);
1562 1562
               SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z);
1563 1563
             }
@@ -1567,12 +1567,12 @@
1567 1567
 
1568 1568
         if (!abort_flag) {
1569 1569
           measured_z = probe_pt(UBL_PROBE_PT_3_X, UBL_PROBE_PT_3_Y, true, g29_verbose_level);
1570
-//        z3 = measured_z;
1570
+          //z3 = measured_z;
1571 1571
           if (isnan(measured_z))
1572 1572
             abort_flag = true;
1573 1573
           else {
1574 1574
             measured_z -= get_z_correction(UBL_PROBE_PT_3_X, UBL_PROBE_PT_3_Y);
1575
-            if (g29_verbose_level>3) {
1575
+            if (g29_verbose_level > 3) {
1576 1576
               serial_spaces(16);
1577 1577
               SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z);
1578 1578
             }
@@ -1584,54 +1584,54 @@
1584 1584
           SERIAL_ECHOPGM("?Error probing point.  Aborting operation.\n");
1585 1585
           return;
1586 1586
         }
1587
-      } else {
1587
+      }
1588
+      else { // !do_3_pt_leveling
1588 1589
 
1589
-      bool zig_zag = false;
1590
-      for (uint8_t ix = 0; ix < g29_grid_size; ix++) {
1591
-        const float rx = float(x_min) + ix * dx;
1592
-        for (int8_t iy = 0; iy < g29_grid_size; iy++) {
1593
-          const float ry = float(y_min) + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
1590
+        bool zig_zag = false;
1591
+        for (uint8_t ix = 0; ix < g29_grid_size; ix++) {
1592
+          const float rx = float(x_min) + ix * dx;
1593
+          for (int8_t iy = 0; iy < g29_grid_size; iy++) {
1594
+            const float ry = float(y_min) + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
1594 1595
 
1595 1596
             if (!abort_flag) {
1596 1597
               measured_z = probe_pt(rx, ry, parser.seen('E'), g29_verbose_level); // TODO: Needs error handling
1597 1598
 
1598
-              if (isnan(measured_z))
1599
-                abort_flag = true;
1599
+              abort_flag = isnan(measured_z);
1600
+
1601
+              #if ENABLED(DEBUG_LEVELING_FEATURE)
1602
+                if (DEBUGGING(LEVELING)) {
1603
+                  SERIAL_CHAR('(');
1604
+                  SERIAL_PROTOCOL_F(rx, 7);
1605
+                  SERIAL_CHAR(',');
1606
+                  SERIAL_PROTOCOL_F(ry, 7);
1607
+                  SERIAL_ECHOPGM(")   logical: ");
1608
+                  SERIAL_CHAR('(');
1609
+                  SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(rx), 7);
1610
+                  SERIAL_CHAR(',');
1611
+                  SERIAL_PROTOCOL_F(LOGICAL_Y_POSITION(ry), 7);
1612
+                  SERIAL_ECHOPGM(")   measured: ");
1613
+                  SERIAL_PROTOCOL_F(measured_z, 7);
1614
+                  SERIAL_ECHOPGM("   correction: ");
1615
+                  SERIAL_PROTOCOL_F(get_z_correction(rx, ry), 7);
1616
+                }
1617
+              #endif
1600 1618
 
1601
-          #if ENABLED(DEBUG_LEVELING_FEATURE)
1602
-            if (DEBUGGING(LEVELING)) {
1603
-              SERIAL_CHAR('(');
1604
-              SERIAL_PROTOCOL_F(rx, 7);
1605
-              SERIAL_CHAR(',');
1606
-              SERIAL_PROTOCOL_F(ry, 7);
1607
-              SERIAL_ECHOPGM(")   logical: ");
1608
-              SERIAL_CHAR('(');
1609
-              SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(rx), 7);
1610
-              SERIAL_CHAR(',');
1611
-              SERIAL_PROTOCOL_F(LOGICAL_Y_POSITION(ry), 7);
1612
-              SERIAL_ECHOPGM(")   measured: ");
1613
-              SERIAL_PROTOCOL_F(measured_z, 7);
1614
-              SERIAL_ECHOPGM("   correction: ");
1615
-              SERIAL_PROTOCOL_F(get_z_correction(rx, ry), 7);
1616
-            }
1617
-          #endif
1619
+              measured_z -= get_z_correction(rx, ry) /* + zprobe_zoffset */ ;
1618 1620
 
1619
-          measured_z -= get_z_correction(rx, ry) /* + zprobe_zoffset */ ;
1621
+              #if ENABLED(DEBUG_LEVELING_FEATURE)
1622
+                if (DEBUGGING(LEVELING)) {
1623
+                  SERIAL_ECHOPGM("   final >>>---> ");
1624
+                  SERIAL_PROTOCOL_F(measured_z, 7);
1625
+                  SERIAL_EOL();
1626
+                }
1627
+              #endif
1620 1628
 
1621
-          #if ENABLED(DEBUG_LEVELING_FEATURE)
1622
-            if (DEBUGGING(LEVELING)) {
1623
-              SERIAL_ECHOPGM("   final >>>---> ");
1624
-              SERIAL_PROTOCOL_F(measured_z, 7);
1625
-              SERIAL_EOL();
1629
+              incremental_LSF(&lsf_results, rx, ry, measured_z);
1626 1630
             }
1627
-          #endif
1628
-
1629
-          incremental_LSF(&lsf_results, rx, ry, measured_z);
1630
-        }
1631 1631
           }
1632 1632
 
1633
-        zig_zag ^= true;
1634
-      }
1633
+          zig_zag ^= true;
1634
+        }
1635 1635
 
1636 1636
       }
1637 1637
 
@@ -1640,7 +1640,6 @@
1640 1640
         return;
1641 1641
       }
1642 1642
 
1643
-
1644 1643
       vector_3 normal = vector_3(lsf_results.A, lsf_results.B, 1.0000).get_normal();
1645 1644
 
1646 1645
       if (g29_verbose_level > 2) {
@@ -1714,22 +1713,22 @@
1714 1713
           SERIAL_ECHOPGM("]\n");
1715 1714
           SERIAL_EOL();
1716 1715
 
1717
-/*
1718
- * The following code can be used to check the validity of the mesh tilting algorithm.
1719
- * When a 3-Point Mesh Tilt is done, the same algorithm is used as the grid based tilting.
1720
- * The only difference is just 3 points are used in the calculations.   That fact guarantees
1721
- * each probed point should have an exact match when a get_z_correction() for that location
1722
- * is calculated.  The Z error between the probed point locations and the get_z_correction()
1723
- * numbers for those locations should be 0.000
1724
- */
1725
-/*
1716
+          /**
1717
+           * The following code can be used to check the validity of the mesh tilting algorithm.
1718
+           * When a 3-Point Mesh Tilt is done, the same algorithm is used as the grid based tilting.
1719
+           * The only difference is just 3 points are used in the calculations.   That fact guarantees
1720
+           * each probed point should have an exact match when a get_z_correction() for that location
1721
+           * is calculated.  The Z error between the probed point locations and the get_z_correction()
1722
+           * numbers for those locations should be 0.000
1723
+           */
1724
+          #if 0
1726 1725
           float t, t1, d;
1727 1726
           t = normal.x * (UBL_PROBE_PT_1_X) + normal.y * (UBL_PROBE_PT_1_Y);
1728 1727
           d = t + normal.z * z1;
1729 1728
           SERIAL_ECHOPGM("D from 1st point: ");
1730 1729
           SERIAL_ECHO_F(d, 6);
1731 1730
           SERIAL_ECHOPGM("   Z error: ");
1732
-          SERIAL_ECHO_F(normal.z*z1-get_z_correction(UBL_PROBE_PT_1_X, UBL_PROBE_PT_1_Y),6);
1731
+          SERIAL_ECHO_F(normal.z*z1-get_z_correction(UBL_PROBE_PT_1_X, UBL_PROBE_PT_1_Y), 6);
1733 1732
           SERIAL_EOL();
1734 1733
 
1735 1734
           t = normal.x * (UBL_PROBE_PT_2_X) + normal.y * (UBL_PROBE_PT_2_Y);
@@ -1738,7 +1737,7 @@
1738 1737
           SERIAL_ECHOPGM("D from 2nd point: ");
1739 1738
           SERIAL_ECHO_F(d, 6);
1740 1739
           SERIAL_ECHOPGM("   Z error: ");
1741
-          SERIAL_ECHO_F(normal.z*z2-get_z_correction(UBL_PROBE_PT_2_X, UBL_PROBE_PT_2_Y),6);
1740
+          SERIAL_ECHO_F(normal.z*z2-get_z_correction(UBL_PROBE_PT_2_X, UBL_PROBE_PT_2_Y), 6);
1742 1741
           SERIAL_EOL();
1743 1742
 
1744 1743
           t = normal.x * (UBL_PROBE_PT_3_X) + normal.y * (UBL_PROBE_PT_3_Y);
@@ -1746,7 +1745,7 @@
1746 1745
           SERIAL_ECHOPGM("D from 3rd point: ");
1747 1746
           SERIAL_ECHO_F(d, 6);
1748 1747
           SERIAL_ECHOPGM("   Z error: ");
1749
-          SERIAL_ECHO_F(normal.z*z3-get_z_correction(UBL_PROBE_PT_3_X, UBL_PROBE_PT_3_Y),6);
1748
+          SERIAL_ECHO_F(normal.z*z3-get_z_correction(UBL_PROBE_PT_3_X, UBL_PROBE_PT_3_Y), 6);
1750 1749
           SERIAL_EOL();
1751 1750
 
1752 1751
           t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
@@ -1760,13 +1759,13 @@
1760 1759
           SERIAL_ECHOPGM("D from home location using mesh value for Z: ");
1761 1760
           SERIAL_ECHO_F(d, 6);
1762 1761
 
1763
-          SERIAL_ECHOPAIR("   Z error: (", Z_SAFE_HOMING_X_POINT );
1762
+          SERIAL_ECHOPAIR("   Z error: (", Z_SAFE_HOMING_X_POINT);
1764 1763
           SERIAL_ECHOPAIR(",", Z_SAFE_HOMING_Y_POINT );
1765 1764
           SERIAL_ECHOPGM(") = ");
1766
-          SERIAL_ECHO_F( get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT),6);
1765
+          SERIAL_ECHO_F(get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT), 6);
1767 1766
           SERIAL_EOL();
1768
-*/
1769
-        }
1767
+          #endif
1768
+        } // DEBUGGING(LEVELING)
1770 1769
       #endif
1771 1770
 
1772 1771
     }

Loading…
Cancel
Save