Переглянути джерело

Some cleanup, fixes for ultralcd.cpp UBL code

- Free up 30 bytes of SRAM in UBL LCD code
- Fix BUILD_ABS_MESH temperature
- Fix UBL indentation in ultralcd.cpp
- UBL vars lowercase, "convert to positive" sensibly
Scott Lahteine 8 роки тому
джерело
коміт
1d167a6874
2 змінених файлів з 340 додано та 320 видалено
  1. 5
    5
      Marlin/language_en.h
  2. 335
    315
      Marlin/ultralcd.cpp

+ 5
- 5
Marlin/language_en.h Переглянути файл

@@ -170,18 +170,18 @@
170 170
   #ifndef MSG_UBL_DEACTIVATE_MESH
171 171
     #define MSG_UBL_DEACTIVATE_MESH           _UxGT("Deactivate UBL")
172 172
   #endif
173
-  #ifndef MSG_UBL_CUSTOM_BED_TEMP
174
-    #define MSG_UBL_CUSTOM_BED_TEMP           _UxGT("Bed Temp")
175
-  #endif
176 173
   #ifndef MSG_UBL_SET_BED_TEMP
177 174
     #define MSG_UBL_SET_BED_TEMP              _UxGT("Bed Temp")
178 175
   #endif
179
-  #ifndef MSG_UBL_CUSTOM_HOTEND_TEMP
180
-    #define MSG_UBL_CUSTOM_HOTEND_TEMP        _UxGT("Hotend Temp")
176
+  #ifndef MSG_UBL_CUSTOM_BED_TEMP
177
+    #define MSG_UBL_CUSTOM_BED_TEMP           MSG_UBL_SET_BED_TEMP
181 178
   #endif
182 179
   #ifndef MSG_UBL_SET_HOTEND_TEMP
183 180
     #define MSG_UBL_SET_HOTEND_TEMP           _UxGT("Hotend Temp")
184 181
   #endif
182
+  #ifndef MSG_UBL_CUSTOM_HOTEND_TEMP
183
+    #define MSG_UBL_CUSTOM_HOTEND_TEMP        MSG_UBL_SET_HOTEND_TEMP
184
+  #endif
185 185
   #ifndef MSG_UBL_EDIT_CUSTOM_MESH
186 186
     #define MSG_UBL_EDIT_CUSTOM_MESH          _UxGT("Edit Custom Mesh")
187 187
   #endif

+ 335
- 315
Marlin/ultralcd.cpp Переглянути файл

@@ -1663,346 +1663,366 @@ void kill_screen(const char* lcd_msg) {
1663 1663
       END_MENU();
1664 1664
     }
1665 1665
 
1666
-  #if ENABLED(AUTO_BED_LEVELING_UBL)
1667
-
1668
-    void _lcd_ubl_level_bed();
1669
-
1670
-    int UBL_STORAGE_SLOT = 0,
1671
-        CUSTOM_BED_TEMP = 50,
1672
-        CUSTOM_HOTEND_TEMP = 190,
1673
-        SIDE_POINTS = 3,
1674
-        UBL_FILLIN_AMOUNT = 5,
1675
-        UBL_HEIGHT_AMOUNT,
1676
-        map_type;
1666
+    #if ENABLED(AUTO_BED_LEVELING_UBL)
1677 1667
 
1678
-    char UBL_LCD_GCODE [30];
1668
+      void _lcd_ubl_level_bed();
1679 1669
 
1680
-    /**
1681
-     * UBL Build Custom Mesh Command
1682
-     */
1683
-    void _lcd_ubl_build_custom_mesh() {
1684
-      enqueue_and_echo_command("G28");
1685
-      #if (WATCH_THE_BED)
1686
-      sprintf_P(UBL_LCD_GCODE, PSTR("M190 S%i"), CUSTOM_BED_TEMP);
1687
-      enqueue_and_echo_command(UBL_LCD_GCODE);
1688
-      #endif
1689
-      sprintf_P(UBL_LCD_GCODE, PSTR("M109 S%i"), CUSTOM_HOTEND_TEMP);
1690
-      enqueue_and_echo_command(UBL_LCD_GCODE);
1691
-      enqueue_and_echo_command("G29 P1");
1692
-    }
1670
+      static int ubl_storage_slot = 0,
1671
+                 custom_bed_temp = 50,
1672
+                 custom_hotend_temp = 190,
1673
+                 side_points = 3,
1674
+                 ubl_fillin_amount = 5,
1675
+                 ubl_height_amount,
1676
+                 map_type;
1693 1677
 
1694
-    /**
1695
-     * UBL Custom Mesh submenu
1696
-     */
1697
-    void _lcd_ubl_custom_mesh() {
1698
-      START_MENU();
1699
-      MENU_BACK(MSG_UBL_BUILD_MESH_MENU);
1700
-      MENU_ITEM_EDIT(int3, MSG_UBL_CUSTOM_HOTEND_TEMP, &CUSTOM_HOTEND_TEMP, EXTRUDE_MINTEMP, (HEATER_0_MAXTEMP - 10));
1701
-      #if (WATCH_THE_BED)
1702
-      MENU_ITEM_EDIT(int3, MSG_UBL_CUSTOM_BED_TEMP, &CUSTOM_BED_TEMP, BED_MINTEMP, (BED_MAXTEMP - 5));
1703
-      #endif
1704
-      MENU_ITEM(function, MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_build_custom_mesh);
1705
-      END_MENU();
1706
-    }
1678
+      /**
1679
+       * UBL Build Custom Mesh Command
1680
+       */
1681
+      void _lcd_ubl_build_custom_mesh() {
1682
+        char UBL_LCD_GCODE[20];
1683
+        enqueue_and_echo_commands_P(PSTR("G28"));
1684
+        #if WATCH_THE_BED
1685
+          sprintf_P(UBL_LCD_GCODE, PSTR("M190 S%i"), custom_bed_temp);
1686
+          enqueue_and_echo_command(UBL_LCD_GCODE);
1687
+        #endif
1688
+        sprintf_P(UBL_LCD_GCODE, PSTR("M109 S%i"), custom_hotend_temp);
1689
+        enqueue_and_echo_command(UBL_LCD_GCODE);
1690
+        enqueue_and_echo_commands_P(PSTR("G29 P1"));
1691
+      }
1707 1692
 
1708
-    /**
1709
-     * UBL Adjust Mesh Height Command
1710
-     */
1711
-    void _lcd_ubl_adjust_height_cmd() {
1712
-      if (UBL_HEIGHT_AMOUNT < 0) {
1713
-        // Convert to positive for the `sprintf_P` string.
1714
-        UBL_HEIGHT_AMOUNT = (UBL_HEIGHT_AMOUNT - (UBL_HEIGHT_AMOUNT * 2)); // Convert to positive
1715
-        sprintf_P(UBL_LCD_GCODE, PSTR("G29 P6-.%i"), UBL_HEIGHT_AMOUNT);
1716
-        // Convert back to negative to preserve the user setting.
1717
-        UBL_HEIGHT_AMOUNT = (UBL_HEIGHT_AMOUNT - (UBL_HEIGHT_AMOUNT * 2)); // Convert back to negative
1693
+      /**
1694
+       * UBL Custom Mesh submenu
1695
+       */
1696
+      void _lcd_ubl_custom_mesh() {
1697
+        START_MENU();
1698
+        MENU_BACK(MSG_UBL_BUILD_MESH_MENU);
1699
+        MENU_ITEM_EDIT(int3, MSG_UBL_CUSTOM_HOTEND_TEMP, &custom_hotend_temp, EXTRUDE_MINTEMP, (HEATER_0_MAXTEMP - 10));
1700
+        #if WATCH_THE_BED
1701
+          MENU_ITEM_EDIT(int3, MSG_UBL_CUSTOM_BED_TEMP, &custom_bed_temp, BED_MINTEMP, (BED_MAXTEMP - 5));
1702
+        #endif
1703
+        MENU_ITEM(function, MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_build_custom_mesh);
1704
+        END_MENU();
1718 1705
       }
1719
-      else {
1720
-        sprintf_P(UBL_LCD_GCODE, PSTR("G29 P6.%i"), UBL_HEIGHT_AMOUNT);
1706
+
1707
+      /**
1708
+       * UBL Adjust Mesh Height Command
1709
+       */
1710
+      void _lcd_ubl_adjust_height_cmd() {
1711
+        char UBL_LCD_GCODE[16];
1712
+        const int ind = ubl_height_amount < 0 ? 6 : 7;
1713
+        strcpy_P(UBL_LCD_GCODE, PSTR("G29 P6-"));
1714
+        sprintf_P(&UBL_LCD_GCODE[ind], PSTR(".%i"), abs(ubl_height_amount));
1715
+        enqueue_and_echo_command(UBL_LCD_GCODE);
1721 1716
       }
1722
-      enqueue_and_echo_command(UBL_LCD_GCODE);
1723
-    }
1724 1717
 
1725
-    /**
1726
-     * UBL Adjust Mesh Height submenu
1727
-     */
1728
-    void _lcd_ubl_height_adjust_menu() {
1729
-      START_MENU();
1730
-      MENU_BACK(MSG_UBL_EDIT_MESH_MENU);
1731
-      MENU_ITEM_EDIT(int3, MSG_UBL_MESH_HEIGHT_AMOUNT, &UBL_HEIGHT_AMOUNT, -9, 9);
1732
-      MENU_ITEM(function, MSG_UBL_MESH_HEIGHT_ADJUST, _lcd_ubl_adjust_height_cmd);
1733
-      MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1734
-      END_MENU();
1735
-    }
1718
+      /**
1719
+       * UBL Adjust Mesh Height submenu
1720
+       */
1721
+      void _lcd_ubl_height_adjust_menu() {
1722
+        START_MENU();
1723
+        MENU_BACK(MSG_UBL_EDIT_MESH_MENU);
1724
+        MENU_ITEM_EDIT(int3, MSG_UBL_MESH_HEIGHT_AMOUNT, &ubl_height_amount, -9, 9);
1725
+        MENU_ITEM(function, MSG_UBL_MESH_HEIGHT_ADJUST, _lcd_ubl_adjust_height_cmd);
1726
+        MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1727
+        END_MENU();
1728
+      }
1736 1729
 
1737
-    /**
1738
-     * UBL Edit Mesh submenu
1739
-     */
1740
-    void _lcd_ubl_edit_mesh() {
1741
-      START_MENU();
1742
-      MENU_BACK(MSG_UBL_TOOLS);
1743
-      MENU_BACK(MSG_UBL_LEVEL_BED);
1744
-      MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R T"));
1745
-      MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29 P4 T"));
1746
-      MENU_ITEM(submenu, MSG_UBL_MESH_HEIGHT_ADJUST, _lcd_ubl_height_adjust_menu);
1747
-      MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1748
-      END_MENU();
1749
-    }
1730
+      /**
1731
+       * UBL Edit Mesh submenu
1732
+       */
1733
+      void _lcd_ubl_edit_mesh() {
1734
+        START_MENU();
1735
+        MENU_BACK(MSG_UBL_TOOLS);
1736
+        MENU_BACK(MSG_UBL_LEVEL_BED);
1737
+        MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R T"));
1738
+        MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29 P4 T"));
1739
+        MENU_ITEM(submenu, MSG_UBL_MESH_HEIGHT_ADJUST, _lcd_ubl_height_adjust_menu);
1740
+        MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1741
+        END_MENU();
1742
+      }
1750 1743
 
1751
-    /**
1752
-     * UBL Validate Custom Mesh Command
1753
-     */
1754
-    void _lcd_ubl_validate_custom_mesh() {
1755
-      enqueue_and_echo_command("G28");
1756
-      #if (WATCH_THE_BED)
1757
-        sprintf_P(UBL_LCD_GCODE, PSTR("G26 C B%i H%i P"), CUSTOM_BED_TEMP, CUSTOM_HOTEND_TEMP);
1758
-      #else
1759
-        sprintf_P(UBL_LCD_GCODE, PSTR("G26 C B0 H%i P"), CUSTOM_HOTEND_TEMP);
1760
-      #endif
1761
-      enqueue_and_echo_command(UBL_LCD_GCODE);
1762
-    }
1744
+      /**
1745
+       * UBL Validate Custom Mesh Command
1746
+       */
1747
+      void _lcd_ubl_validate_custom_mesh() {
1748
+        char UBL_LCD_GCODE[24];
1749
+        const int temp = 
1750
+          #if WATCH_THE_BED
1751
+            custom_bed_temp
1752
+          #else
1753
+            0
1754
+          #endif
1755
+        ;
1756
+        sprintf_P(UBL_LCD_GCODE, PSTR("G28\nG26 C B%i H%i P"), temp, custom_hotend_temp);
1757
+        enqueue_and_echo_command(UBL_LCD_GCODE);
1758
+      }
1763 1759
 
1764
-    /**
1765
-     * UBL Validate Mesh submenu
1766
-     */
1767
-    void _lcd_ubl_validate_mesh() {
1768
-      START_MENU();
1769
-      MENU_BACK(MSG_UBL_TOOLS);
1770
-      #if (WATCH_THE_BED)
1771
-        MENU_ITEM(gcode, MSG_UBL_VALIDATE_PLA_MESH, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_1_TEMP_BED)
1772
-          " H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
1773
-        MENU_ITEM(gcode, MSG_UBL_VALIDATE_ABS_MESH, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_2_TEMP_BED)
1774
-          " H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
1775
-      #else
1776
-        MENU_ITEM(gcode, MSG_UBL_VALIDATE_PLA_MESH, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
1777
-        MENU_ITEM(gcode, MSG_UBL_VALIDATE_ABS_MESH, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
1778
-      #endif
1779
-      MENU_ITEM(function, MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh);
1780
-      MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1781
-      END_MENU();
1782
-    }
1760
+      /**
1761
+       * UBL Validate Mesh submenu
1762
+       */
1763
+      void _lcd_ubl_validate_mesh() {
1764
+        START_MENU();
1765
+        MENU_BACK(MSG_UBL_TOOLS);
1766
+        #if WATCH_THE_BED
1767
+          MENU_ITEM(gcode, MSG_UBL_VALIDATE_PLA_MESH, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_1_TEMP_BED) " H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
1768
+          MENU_ITEM(gcode, MSG_UBL_VALIDATE_ABS_MESH, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_2_TEMP_BED) " H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
1769
+        #else
1770
+          MENU_ITEM(gcode, MSG_UBL_VALIDATE_PLA_MESH, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
1771
+          MENU_ITEM(gcode, MSG_UBL_VALIDATE_ABS_MESH, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
1772
+        #endif
1773
+        MENU_ITEM(function, MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh);
1774
+        MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1775
+        END_MENU();
1776
+      }
1783 1777
 
1784
-    /**
1785
-     * UBL Grid Leveling Command
1786
-     */
1787
-    void _lcd_ubl_grid_level_cmd() {
1788
-      sprintf_P(UBL_LCD_GCODE, PSTR("G29 J%i"), SIDE_POINTS);
1789
-      enqueue_and_echo_command(UBL_LCD_GCODE);
1790
-    }
1778
+      /**
1779
+       * UBL Grid Leveling Command
1780
+       */
1781
+      void _lcd_ubl_grid_level_cmd() {
1782
+        char UBL_LCD_GCODE[10];
1783
+        sprintf_P(UBL_LCD_GCODE, PSTR("G29 J%i"), side_points);
1784
+        enqueue_and_echo_command(UBL_LCD_GCODE);
1785
+      }
1791 1786
 
1792
-    /**
1793
-     * UBL Grid Leveling submenu
1794
-     */
1795
-    void _lcd_ubl_grid_level() {
1796
-      START_MENU();
1797
-      MENU_BACK(MSG_UBL_TOOLS);
1798
-      MENU_ITEM_EDIT(int3, MSG_UBL_SIDE_POINTS, &SIDE_POINTS, 2, 6);
1799
-      MENU_ITEM(function, MSG_UBL_MESH_LEVEL, _lcd_ubl_grid_level_cmd);
1800
-      END_MENU();
1801
-    }
1787
+      /**
1788
+       * UBL Grid Leveling submenu
1789
+       */
1790
+      void _lcd_ubl_grid_level() {
1791
+        START_MENU();
1792
+        MENU_BACK(MSG_UBL_TOOLS);
1793
+        MENU_ITEM_EDIT(int3, MSG_UBL_SIDE_POINTS, &side_points, 2, 6);
1794
+        MENU_ITEM(function, MSG_UBL_MESH_LEVEL, _lcd_ubl_grid_level_cmd);
1795
+        END_MENU();
1796
+      }
1802 1797
 
1803
-    /**
1804
-     * UBL Mesh Leveling submenu
1805
-     */
1806
-    void _lcd_ubl_mesh_leveling() {
1807
-      START_MENU();
1808
-      MENU_BACK(MSG_UBL_TOOLS);
1809
-      MENU_ITEM(gcode, MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29 J0"));
1810
-      MENU_ITEM(submenu, MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level);
1811
-      MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1812
-      END_MENU();
1813
-    }
1798
+      /**
1799
+       * UBL Mesh Leveling submenu
1800
+       */
1801
+      void _lcd_ubl_mesh_leveling() {
1802
+        START_MENU();
1803
+        MENU_BACK(MSG_UBL_TOOLS);
1804
+        MENU_ITEM(gcode, MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29 J0"));
1805
+        MENU_ITEM(submenu, MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level);
1806
+        MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1807
+        END_MENU();
1808
+      }
1814 1809
 
1815
-    /**
1816
-     * UBL Fill-in Amount Mesh Command
1817
-     */
1818
-    void _lcd_ubl_fillin_amount_cmd() {
1819
-      sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 R C.%i"), UBL_FILLIN_AMOUNT);
1820
-      enqueue_and_echo_command(UBL_LCD_GCODE);
1821
-    }
1810
+      /**
1811
+       * UBL Fill-in Amount Mesh Command
1812
+       */
1813
+      void _lcd_ubl_fillin_amount_cmd() {
1814
+        char UBL_LCD_GCODE[16];
1815
+        sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 R C.%i"), ubl_fillin_amount);
1816
+        enqueue_and_echo_command(UBL_LCD_GCODE);
1817
+      }
1822 1818
 
1823
-    /**
1824
-     * UBL Smart Fill-in Command
1825
-     */
1826
-    void _lcd_ubl_smart_fillin_cmd() {
1827
-      sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 T%i"), map_type);
1828
-      enqueue_and_echo_command(UBL_LCD_GCODE);
1829
-    }
1819
+      /**
1820
+       * UBL Smart Fill-in Command
1821
+       */
1822
+      void _lcd_ubl_smart_fillin_cmd() {
1823
+        char UBL_LCD_GCODE[12];
1824
+        sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 T%i"), map_type);
1825
+        enqueue_and_echo_command(UBL_LCD_GCODE);
1826
+      }
1830 1827
 
1831
-    /**
1832
-     * UBL Fill-in Mesh submenu
1833
-     */
1834
-    void _lcd_ubl_fillin_menu() {
1835
-      START_MENU();
1836
-      MENU_BACK(MSG_UBL_BUILD_MESH_MENU);
1837
-      MENU_ITEM_EDIT(int3, MSG_UBL_FILLIN_AMOUNT, &UBL_FILLIN_AMOUNT, 0, 9);
1838
-      MENU_ITEM(function, MSG_UBL_FILLIN_MESH, _lcd_ubl_fillin_amount_cmd);
1839
-      MENU_ITEM(function, MSG_UBL_SMART_FILLIN, _lcd_ubl_smart_fillin_cmd);
1840
-      MENU_ITEM(gcode, MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0"));
1841
-      MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1842
-      END_MENU();
1843
-    }
1828
+      /**
1829
+       * UBL Fill-in Mesh submenu
1830
+       */
1831
+      void _lcd_ubl_fillin_menu() {
1832
+        START_MENU();
1833
+        MENU_BACK(MSG_UBL_BUILD_MESH_MENU);
1834
+        MENU_ITEM_EDIT(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9);
1835
+        MENU_ITEM(function, MSG_UBL_FILLIN_MESH, _lcd_ubl_fillin_amount_cmd);
1836
+        MENU_ITEM(function, MSG_UBL_SMART_FILLIN, _lcd_ubl_smart_fillin_cmd);
1837
+        MENU_ITEM(gcode, MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0"));
1838
+        MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1839
+        END_MENU();
1840
+      }
1844 1841
 
1845
-    void _lcd_ubl_invalidate() {
1846
-      ubl.invalidate();
1847
-      SERIAL_PROTOCOLLNPGM("Mesh invalidated.");
1848
-    }
1842
+      void _lcd_ubl_invalidate() {
1843
+        ubl.invalidate();
1844
+        SERIAL_PROTOCOLLNPGM("Mesh invalidated.");
1845
+      }
1849 1846
 
1850
-    /**
1851
-     * UBL Build Mesh submenu
1852
-     */
1853
-    void _lcd_ubl_build_mesh() {
1854
-      START_MENU();
1855
-      MENU_BACK(MSG_UBL_TOOLS);
1856
-      #if (WATCH_THE_BED)
1857
-        MENU_ITEM(gcode, MSG_UBL_BUILD_PLA_MESH, PSTR("G28\nM190 S" STRINGIFY(PREHEAT_1_TEMP_BED)
1858
-          "\nM109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\nG29 P1\nM104 S0\nM140 S0"));
1859
-        MENU_ITEM(gcode, MSG_UBL_BUILD_ABS_MESH, PSTR("G28\nM190 S" STRINGIFY(PREHEAT_1_TEMP_BED)
1860
-          "\nM109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\nG29 P1\nM104 S0\nM140 S0"));
1861
-      #else
1862
-        MENU_ITEM(gcode, MSG_UBL_BUILD_PLA_MESH, PSTR("G28\nM109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND)
1863
-          "\nG29 P1\nM104 S0"));
1864
-        MENU_ITEM(gcode, MSG_UBL_BUILD_ABS_MESH, PSTR("G28\nM109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND)
1865
-          "\nG29 P1\nM104 S0"));
1866
-      #endif
1867
-      MENU_ITEM(submenu, MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh);
1868
-      MENU_ITEM(gcode, MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
1869
-      MENU_ITEM(submenu, MSG_UBL_FILLIN_MESH, _lcd_ubl_fillin_menu);
1870
-      MENU_ITEM(gcode, MSG_UBL_CONTINUE_MESH, PSTR("G29 P1 C"));
1871
-      MENU_ITEM(function, MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate);
1872
-      MENU_ITEM(gcode, MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29 I"));
1873
-      MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1874
-      END_MENU();
1875
-    }
1847
+      /**
1848
+       * UBL Build Mesh submenu
1849
+       */
1850
+      void _lcd_ubl_build_mesh() {
1851
+        START_MENU();
1852
+        MENU_BACK(MSG_UBL_TOOLS);
1853
+        #if WATCH_THE_BED
1854
+          MENU_ITEM(gcode, MSG_UBL_BUILD_PLA_MESH, PSTR(
1855
+            "G28\n"
1856
+            "M190 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\n"
1857
+            "M109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\n"
1858
+            "G29 P1\n"
1859
+            "M104 S0\n"
1860
+            "M140 S0"
1861
+          ));
1862
+          MENU_ITEM(gcode, MSG_UBL_BUILD_ABS_MESH, PSTR(
1863
+            "G28\n"
1864
+            "M190 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\n"
1865
+            "M109 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) "\n"
1866
+            "G29 P1\n"
1867
+            "M104 S0\n"
1868
+            "M140 S0"
1869
+          ));
1870
+        #else
1871
+          MENU_ITEM(gcode, MSG_UBL_BUILD_PLA_MESH, PSTR(
1872
+            "G28\n"
1873
+            "M109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\n"
1874
+            "G29 P1\n"
1875
+            "M104 S0"
1876
+          ));
1877
+          MENU_ITEM(gcode, MSG_UBL_BUILD_ABS_MESH, PSTR(
1878
+            "G28\n"
1879
+            "M109 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) "\n"
1880
+            "G29 P1\n"
1881
+            "M104 S0"
1882
+          ));
1883
+        #endif
1884
+        MENU_ITEM(submenu, MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh);
1885
+        MENU_ITEM(gcode, MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
1886
+        MENU_ITEM(submenu, MSG_UBL_FILLIN_MESH, _lcd_ubl_fillin_menu);
1887
+        MENU_ITEM(gcode, MSG_UBL_CONTINUE_MESH, PSTR("G29 P1 C"));
1888
+        MENU_ITEM(function, MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate);
1889
+        MENU_ITEM(gcode, MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29 I"));
1890
+        MENU_ITEM(submenu, MSG_WATCH, lcd_status_screen);
1891
+        END_MENU();
1892
+      }
1876 1893
 
1877
-    /**
1878
-     * UBL Load Mesh Command
1879
-     */
1880
-    void _lcd_ubl_load_mesh_cmd() {
1881
-      sprintf_P(UBL_LCD_GCODE, PSTR("G29 L%i"), UBL_STORAGE_SLOT);
1882
-      enqueue_and_echo_command(UBL_LCD_GCODE);
1883
-    }
1894
+      /**
1895
+       * UBL Load Mesh Command
1896
+       */
1897
+      void _lcd_ubl_load_mesh_cmd() {
1898
+        char UBL_LCD_GCODE[8];
1899
+        sprintf_P(UBL_LCD_GCODE, PSTR("G29 L%i"), ubl_storage_slot);
1900
+        enqueue_and_echo_command(UBL_LCD_GCODE);
1901
+      }
1884 1902
 
1885
-    /**
1886
-     * UBL Save Mesh Command
1887
-     */
1888
-    void _lcd_ubl_save_mesh_cmd() {
1889
-      sprintf_P(UBL_LCD_GCODE, PSTR("G29 S%i"), UBL_STORAGE_SLOT);
1890
-      enqueue_and_echo_command(UBL_LCD_GCODE);
1891
-    }
1903
+      /**
1904
+       * UBL Save Mesh Command
1905
+       */
1906
+      void _lcd_ubl_save_mesh_cmd() {
1907
+        char UBL_LCD_GCODE[8];
1908
+        sprintf_P(UBL_LCD_GCODE, PSTR("G29 S%i"), ubl_storage_slot);
1909
+        enqueue_and_echo_command(UBL_LCD_GCODE);
1910
+      }
1892 1911
 
1893
-    /**
1894
-     * UBL Mesh Storage submenu
1895
-     */
1896
-    void _lcd_ubl_storage_mesh() {
1897
-      START_MENU();
1898
-      MENU_BACK(MSG_UBL_LEVEL_BED);
1899
-      MENU_ITEM_EDIT(int3, MSG_UBL_STORAGE_SLOT, &UBL_STORAGE_SLOT, 0, 9);
1900
-      MENU_ITEM(function, MSG_UBL_LOAD_MESH, _lcd_ubl_load_mesh_cmd);
1901
-      MENU_ITEM(function, MSG_UBL_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
1902
-      END_MENU();
1903
-    }
1912
+      /**
1913
+       * UBL Mesh Storage submenu
1914
+       */
1915
+      void _lcd_ubl_storage_mesh() {
1916
+        START_MENU();
1917
+        MENU_BACK(MSG_UBL_LEVEL_BED);
1918
+        MENU_ITEM_EDIT(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, 9);
1919
+        MENU_ITEM(function, MSG_UBL_LOAD_MESH, _lcd_ubl_load_mesh_cmd);
1920
+        MENU_ITEM(function, MSG_UBL_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
1921
+        END_MENU();
1922
+      }
1904 1923
 
1905
-    /**
1906
-     * UBL Output map Command
1907
-     */
1908
-    void _lcd_ubl_output_map_cmd() {
1909
-      sprintf_P(UBL_LCD_GCODE, PSTR("G29 T%i"), map_type);
1910
-      enqueue_and_echo_command(UBL_LCD_GCODE);
1911
-    }
1924
+      /**
1925
+       * UBL Output map Command
1926
+       */
1927
+      void _lcd_ubl_output_map_cmd() {
1928
+        char UBL_LCD_GCODE[10];
1929
+        sprintf_P(UBL_LCD_GCODE, PSTR("G29 T%i"), map_type);
1930
+        enqueue_and_echo_command(UBL_LCD_GCODE);
1931
+      }
1912 1932
 
1913
-    /**
1914
-     * UBL Output map submenu
1915
-     */
1916
-    void _lcd_ubl_output_map() {
1917
-      START_MENU();
1918
-      MENU_BACK(MSG_UBL_LEVEL_BED);
1919
-      MENU_ITEM_EDIT(int3, MSG_UBL_MAP_TYPE, &map_type, 0, 1);
1920
-      if (map_type == 0) MENU_ITEM(function, MSG_UBL_OUTPUT_MAP_HOST, _lcd_ubl_output_map_cmd);
1921
-      if (map_type == 1) MENU_ITEM(function, MSG_UBL_OUTPUT_MAP_CSV, _lcd_ubl_output_map_cmd);
1922
-      END_MENU();
1923
-    }
1933
+      /**
1934
+       * UBL Output map submenu
1935
+       */
1936
+      void _lcd_ubl_output_map() {
1937
+        START_MENU();
1938
+        MENU_BACK(MSG_UBL_LEVEL_BED);
1939
+        MENU_ITEM_EDIT(int3, MSG_UBL_MAP_TYPE, &map_type, 0, 1);
1940
+        if (map_type == 0) MENU_ITEM(function, MSG_UBL_OUTPUT_MAP_HOST, _lcd_ubl_output_map_cmd);
1941
+        if (map_type == 1) MENU_ITEM(function, MSG_UBL_OUTPUT_MAP_CSV, _lcd_ubl_output_map_cmd);
1942
+        END_MENU();
1943
+      }
1924 1944
 
1925
-    /**
1926
-     * UBL Tools submenu
1927
-     */
1928
-    void _lcd_ubl_tools_menu() {
1929
-      START_MENU();
1930
-      MENU_BACK(MSG_UBL_LEVEL_BED);
1931
-      MENU_ITEM(submenu, MSG_UBL_BUILD_MESH_MENU, _lcd_ubl_build_mesh);
1932
-      MENU_ITEM(submenu, MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
1933
-      MENU_ITEM(submenu, MSG_UBL_EDIT_MESH_MENU, _lcd_ubl_edit_mesh);
1934
-      MENU_ITEM(submenu, MSG_UBL_MESH_LEVELING, _lcd_ubl_mesh_leveling);
1935
-      END_MENU();
1936
-    }
1945
+      /**
1946
+       * UBL Tools submenu
1947
+       */
1948
+      void _lcd_ubl_tools_menu() {
1949
+        START_MENU();
1950
+        MENU_BACK(MSG_UBL_LEVEL_BED);
1951
+        MENU_ITEM(submenu, MSG_UBL_BUILD_MESH_MENU, _lcd_ubl_build_mesh);
1952
+        MENU_ITEM(submenu, MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
1953
+        MENU_ITEM(submenu, MSG_UBL_EDIT_MESH_MENU, _lcd_ubl_edit_mesh);
1954
+        MENU_ITEM(submenu, MSG_UBL_MESH_LEVELING, _lcd_ubl_mesh_leveling);
1955
+        END_MENU();
1956
+      }
1937 1957
 
1938
-    /**
1939
-     * UBL System submenu
1940
-     *
1941
-     *  Prepare
1942
-     * - Unified Bed Leveling
1943
-     *   - Activate UBL
1944
-     *   - Deactivate UBL
1945
-     *   - Mesh Storage
1946
-     *       Memory Slot:
1947
-     *       Load Bed Mesh
1948
-     *       Save Bed Mesh
1949
-     *   - Output Map
1950
-     *       Map Type:
1951
-     *       Output Bed Mesh Host / Output Bed Mesh CSV
1952
-     *   - UBL Tools
1953
-     *     - Build Mesh
1954
-     *         Build PLA Mesh
1955
-     *         Build ABS Mesh
1956
-     *       - Build Custom Mesh
1957
-     *           Hotend Temp:
1958
-     *           Bed Temp:
1959
-     *           Build Custom Mesh
1960
-     *         Info Screen
1961
-     *       - Build Cold Mesh
1962
-     *       - Fill-in Mesh
1963
-     *           Fill-in Mesh
1964
-     *           Smart Fill-in
1965
-     *           Manual Fill-in
1966
-     *           Info Screen
1967
-     *         Continue Bed Mesh
1968
-     *         Invalidate All
1969
-     *         Invalidate Closest
1970
-     *     - Validate Mesh
1971
-     *         PLA Mesh Validation
1972
-     *         ABS Mesh Validation
1973
-     *       - Custom Mesh Validation
1974
-     *           Hotend Temp:
1975
-     *           Bed Temp:
1976
-     *           Validate Mesh
1977
-     *         Info Screen
1978
-     *     - Edit Mesh
1979
-     *         Fine Tune All
1980
-     *         Fine Tune Closest
1981
-     *       - Adjust Mesh Height
1982
-     *           Height Amount:
1983
-     *           Adjust Mesh Height
1984
-     *         Info Screen
1985
-     *     - Mesh Leveling
1986
-     *         3-Point Mesh Leveling
1987
-     *       - Grid Mesh Leveling
1988
-     *           Side points:
1989
-     *           Level Mesh
1990
-     *         Info Screen
1991
-     *   - Output UBL Info
1992
-     */
1958
+      /**
1959
+       * UBL System submenu
1960
+       *
1961
+       *  Prepare
1962
+       * - Unified Bed Leveling
1963
+       *   - Activate UBL
1964
+       *   - Deactivate UBL
1965
+       *   - Mesh Storage
1966
+       *       Memory Slot:
1967
+       *       Load Bed Mesh
1968
+       *       Save Bed Mesh
1969
+       *   - Output Map
1970
+       *       Map Type:
1971
+       *       Output Bed Mesh Host / Output Bed Mesh CSV
1972
+       *   - UBL Tools
1973
+       *     - Build Mesh
1974
+       *         Build PLA Mesh
1975
+       *         Build ABS Mesh
1976
+       *       - Build Custom Mesh
1977
+       *           Hotend Temp:
1978
+       *           Bed Temp:
1979
+       *           Build Custom Mesh
1980
+       *         Info Screen
1981
+       *       - Build Cold Mesh
1982
+       *       - Fill-in Mesh
1983
+       *           Fill-in Mesh
1984
+       *           Smart Fill-in
1985
+       *           Manual Fill-in
1986
+       *           Info Screen
1987
+       *         Continue Bed Mesh
1988
+       *         Invalidate All
1989
+       *         Invalidate Closest
1990
+       *     - Validate Mesh
1991
+       *         PLA Mesh Validation
1992
+       *         ABS Mesh Validation
1993
+       *       - Custom Mesh Validation
1994
+       *           Hotend Temp:
1995
+       *           Bed Temp:
1996
+       *           Validate Mesh
1997
+       *         Info Screen
1998
+       *     - Edit Mesh
1999
+       *         Fine Tune All
2000
+       *         Fine Tune Closest
2001
+       *       - Adjust Mesh Height
2002
+       *           Height Amount:
2003
+       *           Adjust Mesh Height
2004
+       *         Info Screen
2005
+       *     - Mesh Leveling
2006
+       *         3-Point Mesh Leveling
2007
+       *       - Grid Mesh Leveling
2008
+       *           Side points:
2009
+       *           Level Mesh
2010
+       *         Info Screen
2011
+       *   - Output UBL Info
2012
+       */
1993 2013
 
1994
-    void _lcd_ubl_level_bed() {
1995
-      START_MENU();
1996
-      MENU_BACK(MSG_PREPARE);
1997
-      MENU_ITEM(gcode, MSG_UBL_ACTIVATE_MESH, PSTR("G29 A"));
1998
-      MENU_ITEM(gcode, MSG_UBL_DEACTIVATE_MESH, PSTR("G29 D"));
1999
-      MENU_ITEM(submenu, MSG_UBL_STORAGE_MESH_MENU, _lcd_ubl_storage_mesh);
2000
-      MENU_ITEM(submenu, MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map);
2001
-      MENU_ITEM(submenu, MSG_UBL_TOOLS, _lcd_ubl_tools_menu);
2002
-      MENU_ITEM(gcode, MSG_UBL_INFO_UBL, PSTR("G29 W"));
2003
-      END_MENU();
2004
-    }
2005
-  #endif
2014
+      void _lcd_ubl_level_bed() {
2015
+        START_MENU();
2016
+        MENU_BACK(MSG_PREPARE);
2017
+        MENU_ITEM(gcode, MSG_UBL_ACTIVATE_MESH, PSTR("G29 A"));
2018
+        MENU_ITEM(gcode, MSG_UBL_DEACTIVATE_MESH, PSTR("G29 D"));
2019
+        MENU_ITEM(submenu, MSG_UBL_STORAGE_MESH_MENU, _lcd_ubl_storage_mesh);
2020
+        MENU_ITEM(submenu, MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map);
2021
+        MENU_ITEM(submenu, MSG_UBL_TOOLS, _lcd_ubl_tools_menu);
2022
+        MENU_ITEM(gcode, MSG_UBL_INFO_UBL, PSTR("G29 W"));
2023
+        END_MENU();
2024
+      }
2025
+    #endif
2006 2026
 
2007 2027
   #endif // LCD_BED_LEVELING || HAS_ABL
2008 2028
 
@@ -2052,7 +2072,7 @@ void kill_screen(const char* lcd_msg) {
2052 2072
         MENU_ITEM(submenu, MSG_LEVEL_BED, lcd_level_bed);
2053 2073
       #endif
2054 2074
 
2055
-    #endif
2075
+    #endif // LCD_BED_LEVELING || HAS_ABL
2056 2076
 
2057 2077
     #if HAS_M206_COMMAND
2058 2078
       //

Завантаження…
Відмінити
Зберегти