Parcourir la source

🧑‍💻 Preheat menu improvements (#24017)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Keith Bennett il y a 2 ans
Parent
révision
9d623160a6
Aucun compte lié à l'adresse e-mail de l'auteur

+ 1
- 1
Marlin/Configuration.h Voir le fichier

@@ -2005,7 +2005,7 @@
2005 2005
 // @section temperature
2006 2006
 
2007 2007
 //
2008
-// Preheat Constants - Up to 5 are supported without changes
2008
+// Preheat Constants - Up to 6 are supported without changes
2009 2009
 //
2010 2010
 #define PREHEAT_1_LABEL       "PLA"
2011 2011
 #define PREHEAT_1_TEMP_HOTEND 180

+ 97
- 403
Marlin/src/lcd/e3v2/jyersui/dwin.cpp Voir le fichier

@@ -1012,10 +1012,62 @@ void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) {
1012 1012
 /* Menu Item Config */
1013 1013
 
1014 1014
 void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/*=true*/) {
1015
-  uint8_t row = item - scrollpos;
1015
+  const uint8_t row = item - scrollpos;
1016 1016
   #if HAS_LEVELING
1017 1017
     static bool level_state;
1018 1018
   #endif
1019
+
1020
+  #if HAS_PREHEAT
1021
+
1022
+    #define PREHEAT_BACK 0
1023
+    #define PREHEAT_SUBMENU_HOTEND (PREHEAT_BACK + ENABLED(HAS_HOTEND))
1024
+    #define PREHEAT_SUBMENU_BED (PREHEAT_SUBMENU_HOTEND + ENABLED(HAS_HEATED_BED))
1025
+    #define PREHEAT_SUBMENU_FAN (PREHEAT_SUBMENU_BED + ENABLED(HAS_FAN))
1026
+    #define PREHEAT_SUBMENU_TOTAL PREHEAT_SUBMENU_FAN
1027
+
1028
+    auto preheat_submenu = [&](const int index, const uint8_t item, const uint8_t sel) {
1029
+      switch (item) {
1030
+        case PREHEAT_BACK:
1031
+          if (draw)
1032
+            Draw_Menu_Item(row, ICON_Back, F("Back"));
1033
+          else
1034
+            Draw_Menu(TempMenu, sel);
1035
+          break;
1036
+        #if HAS_HOTEND
1037
+          case PREHEAT_SUBMENU_HOTEND:
1038
+            if (draw) {
1039
+              Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend"));
1040
+              Draw_Float(ui.material_preset[index].hotend_temp, row, false, 1);
1041
+            }
1042
+            else
1043
+              Modify_Value(ui.material_preset[index].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1);
1044
+            break;
1045
+        #endif
1046
+        #if HAS_HEATED_BED
1047
+          case PREHEAT_SUBMENU_BED:
1048
+            if (draw) {
1049
+              Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed"));
1050
+              Draw_Float(ui.material_preset[index].bed_temp, row, false, 1);
1051
+            }
1052
+            else
1053
+              Modify_Value(ui.material_preset[index].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1);
1054
+            break;
1055
+        #endif
1056
+        #if HAS_FAN
1057
+          case PREHEAT_SUBMENU_FAN:
1058
+            if (draw) {
1059
+              Draw_Menu_Item(row, ICON_FanSpeed, F("Fan"));
1060
+              Draw_Float(ui.material_preset[index].fan_speed, row, false, 1);
1061
+            }
1062
+            else
1063
+              Modify_Value(ui.material_preset[index].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
1064
+            break;
1065
+        #endif
1066
+      }
1067
+    };
1068
+
1069
+  #endif
1070
+
1019 1071
   switch (menu) {
1020 1072
     case Prepare:
1021 1073
 
@@ -1584,7 +1636,6 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
1584 1636
 
1585 1637
     #if HAS_PREHEAT
1586 1638
       case Preheat: {
1587
-        #define PREHEAT_BACK 0
1588 1639
         #define PREHEAT_MODE (PREHEAT_BACK + 1)
1589 1640
         #define PREHEAT_1 (PREHEAT_MODE + 1)
1590 1641
         #define PREHEAT_2 (PREHEAT_1 + (PREHEAT_COUNT >= 2))
@@ -1606,6 +1657,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
1606 1657
             else
1607 1658
               Draw_Menu(Prepare, PREPARE_PREHEAT);
1608 1659
             break;
1660
+
1609 1661
           case PREHEAT_MODE:
1610 1662
             if (draw) {
1611 1663
               Draw_Menu_Item(row, ICON_Homing, F("Preheat Mode"));
@@ -1615,50 +1667,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
1615 1667
               Modify_Option(preheatmode, preheat_modes, 2);
1616 1668
             break;
1617 1669
 
1618
-          #if PREHEAT_COUNT >= 1
1619
-            case PREHEAT_1:
1620
-              if (draw)
1621
-                Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_1_LABEL));
1622
-              else
1623
-                do_preheat(0);
1624
-              break;
1625
-          #endif
1626
-
1627
-          #if PREHEAT_COUNT >= 2
1628
-            case PREHEAT_2:
1629
-              if (draw)
1630
-                Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_2_LABEL));
1631
-              else
1632
-                do_preheat(1);
1633
-              break;
1634
-          #endif
1635
-
1636
-          #if PREHEAT_COUNT >= 3
1637
-            case PREHEAT_3:
1638
-              if (draw)
1639
-                Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_3_LABEL));
1640
-              else
1641
-                do_preheat(2);
1642
-              break;
1643
-          #endif
1644
-
1645
-          #if PREHEAT_COUNT >= 4
1646
-            case PREHEAT_4:
1647
-              if (draw)
1648
-                Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_4_LABEL));
1649
-              else
1650
-                do_preheat(3);
1651
-              break;
1652
-          #endif
1670
+          #define _PREHEAT_CASE(N) \
1671
+            case PREHEAT_##N: { \
1672
+              if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_## N ##_LABEL)); \
1673
+              else do_preheat(N - 1); \
1674
+            } break;
1653 1675
 
1654
-          #if PREHEAT_COUNT >= 5
1655
-            case PREHEAT_5:
1656
-              if (draw)
1657
-                Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_5_LABEL));
1658
-              else
1659
-                do_preheat(4);
1660
-              break;
1661
-          #endif
1676
+          REPEAT_1(PREHEAT_COUNT, _PREHEAT_CASE)
1662 1677
         }
1663 1678
       } break;
1664 1679
     #endif // HAS_PREHEAT
@@ -1871,46 +1886,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
1871 1886
               Draw_Menu(PID);
1872 1887
             break;
1873 1888
         #endif
1874
-        #if PREHEAT_COUNT >= 1
1875
-          case TEMP_PREHEAT1:
1876
-            if (draw)
1877
-              Draw_Menu_Item(row, ICON_Step, F(PREHEAT_1_LABEL), nullptr, true);
1878
-            else
1879
-              Draw_Menu(Preheat1);
1880
-            break;
1881
-        #endif
1882
-        #if PREHEAT_COUNT >= 2
1883
-          case TEMP_PREHEAT2:
1884
-            if (draw)
1885
-              Draw_Menu_Item(row, ICON_Step, F(PREHEAT_2_LABEL), nullptr, true);
1886
-            else
1887
-              Draw_Menu(Preheat2);
1888
-            break;
1889
-        #endif
1890
-        #if PREHEAT_COUNT >= 3
1891
-          case TEMP_PREHEAT3:
1892
-            if (draw)
1893
-              Draw_Menu_Item(row, ICON_Step, F(PREHEAT_3_LABEL), nullptr, true);
1894
-            else
1895
-              Draw_Menu(Preheat3);
1896
-            break;
1897
-        #endif
1898
-        #if PREHEAT_COUNT >= 4
1899
-          case TEMP_PREHEAT4:
1900
-            if (draw)
1901
-              Draw_Menu_Item(row, ICON_Step, F(PREHEAT_4_LABEL), nullptr, true);
1902
-            else
1903
-              Draw_Menu(Preheat4);
1904
-            break;
1905
-        #endif
1906
-        #if PREHEAT_COUNT >= 5
1907
-          case TEMP_PREHEAT5:
1908
-            if (draw)
1909
-              Draw_Menu_Item(row, ICON_Step, F(PREHEAT_5_LABEL), nullptr, true);
1910
-            else
1911
-              Draw_Menu(Preheat5);
1912
-            break;
1913
-        #endif
1889
+
1890
+        #define _TEMP_PREHEAT_CASE(N) \
1891
+          case TEMP_PREHEAT##N: { \
1892
+            if (draw) Draw_Menu_Item(row, ICON_Step, F(PREHEAT_## N ##_LABEL), nullptr, true); \
1893
+            else Draw_Menu(Preheat##N); \
1894
+          } break;
1895
+
1896
+        REPEAT_1(PREHEAT_COUNT, _TEMP_PREHEAT_CASE)
1914 1897
       }
1915 1898
       break;
1916 1899
 
@@ -2095,255 +2078,10 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
2095 2078
         break;
2096 2079
     #endif // HAS_HEATED_BED
2097 2080
 
2098
-    #if PREHEAT_COUNT >= 1
2099
-      case Preheat1:
2100
-
2101
-        #define PREHEAT1_BACK 0
2102
-        #define PREHEAT1_HOTEND (PREHEAT1_BACK + ENABLED(HAS_HOTEND))
2103
-        #define PREHEAT1_BED (PREHEAT1_HOTEND + ENABLED(HAS_HEATED_BED))
2104
-        #define PREHEAT1_FAN (PREHEAT1_BED + ENABLED(HAS_FAN))
2105
-        #define PREHEAT1_TOTAL PREHEAT1_FAN
2106
-
2107
-        switch (item) {
2108
-          case PREHEAT1_BACK:
2109
-            if (draw)
2110
-              Draw_Menu_Item(row, ICON_Back, F("Back"));
2111
-            else
2112
-              Draw_Menu(TempMenu, TEMP_PREHEAT1);
2113
-            break;
2114
-          #if HAS_HOTEND
2115
-            case PREHEAT1_HOTEND:
2116
-              if (draw) {
2117
-                Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend"));
2118
-                Draw_Float(ui.material_preset[0].hotend_temp, row, false, 1);
2119
-              }
2120
-              else
2121
-                Modify_Value(ui.material_preset[0].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1);
2122
-              break;
2123
-          #endif
2124
-          #if HAS_HEATED_BED
2125
-            case PREHEAT1_BED:
2126
-              if (draw) {
2127
-                Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed"));
2128
-                Draw_Float(ui.material_preset[0].bed_temp, row, false, 1);
2129
-              }
2130
-              else
2131
-                Modify_Value(ui.material_preset[0].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1);
2132
-              break;
2133
-          #endif
2134
-          #if HAS_FAN
2135
-            case PREHEAT1_FAN:
2136
-              if (draw) {
2137
-                Draw_Menu_Item(row, ICON_FanSpeed, F("Fan"));
2138
-                Draw_Float(ui.material_preset[0].fan_speed, row, false, 1);
2139
-              }
2140
-              else
2141
-                Modify_Value(ui.material_preset[0].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
2142
-              break;
2143
-          #endif
2144
-        }
2145
-        break;
2146
-    #endif // PREHEAT_COUNT >= 1
2147
-
2148
-    #if PREHEAT_COUNT >= 2
2149
-      case Preheat2:
2150
-
2151
-        #define PREHEAT2_BACK 0
2152
-        #define PREHEAT2_HOTEND (PREHEAT2_BACK + ENABLED(HAS_HOTEND))
2153
-        #define PREHEAT2_BED (PREHEAT2_HOTEND + ENABLED(HAS_HEATED_BED))
2154
-        #define PREHEAT2_FAN (PREHEAT2_BED + ENABLED(HAS_FAN))
2155
-        #define PREHEAT2_TOTAL PREHEAT2_FAN
2156
-
2157
-        switch (item) {
2158
-          case PREHEAT2_BACK:
2159
-            if (draw)
2160
-              Draw_Menu_Item(row, ICON_Back, F("Back"));
2161
-            else
2162
-              Draw_Menu(TempMenu, TEMP_PREHEAT2);
2163
-            break;
2164
-          #if HAS_HOTEND
2165
-            case PREHEAT2_HOTEND:
2166
-              if (draw) {
2167
-                Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend"));
2168
-                Draw_Float(ui.material_preset[1].hotend_temp, row, false, 1);
2169
-              }
2170
-              else
2171
-                Modify_Value(ui.material_preset[1].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1);
2172
-              break;
2173
-          #endif
2174
-          #if HAS_HEATED_BED
2175
-            case PREHEAT2_BED:
2176
-              if (draw) {
2177
-                Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed"));
2178
-                Draw_Float(ui.material_preset[1].bed_temp, row, false, 1);
2179
-              }
2180
-              else
2181
-                Modify_Value(ui.material_preset[1].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1);
2182
-              break;
2183
-          #endif
2184
-          #if HAS_FAN
2185
-            case PREHEAT2_FAN:
2186
-              if (draw) {
2187
-                Draw_Menu_Item(row, ICON_FanSpeed, F("Fan"));
2188
-                Draw_Float(ui.material_preset[1].fan_speed, row, false, 1);
2189
-              }
2190
-              else
2191
-                Modify_Value(ui.material_preset[1].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
2192
-              break;
2193
-          #endif
2194
-        }
2195
-        break;
2196
-    #endif // PREHEAT_COUNT >= 2
2197
-
2198
-    #if PREHEAT_COUNT >= 3
2199
-      case Preheat3:
2200
-
2201
-        #define PREHEAT3_BACK 0
2202
-        #define PREHEAT3_HOTEND (PREHEAT3_BACK + ENABLED(HAS_HOTEND))
2203
-        #define PREHEAT3_BED (PREHEAT3_HOTEND + ENABLED(HAS_HEATED_BED))
2204
-        #define PREHEAT3_FAN (PREHEAT3_BED + ENABLED(HAS_FAN))
2205
-        #define PREHEAT3_TOTAL PREHEAT3_FAN
2206
-
2207
-        switch (item) {
2208
-          case PREHEAT3_BACK:
2209
-            if (draw)
2210
-              Draw_Menu_Item(row, ICON_Back, F("Back"));
2211
-            else
2212
-              Draw_Menu(TempMenu, TEMP_PREHEAT3);
2213
-            break;
2214
-          #if HAS_HOTEND
2215
-            case PREHEAT3_HOTEND:
2216
-              if (draw) {
2217
-                Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend"));
2218
-                Draw_Float(ui.material_preset[2].hotend_temp, row, false, 1);
2219
-              }
2220
-              else
2221
-                Modify_Value(ui.material_preset[2].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1);
2222
-              break;
2223
-          #endif
2224
-          #if HAS_HEATED_BED
2225
-            case PREHEAT3_BED:
2226
-              if (draw) {
2227
-                Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed"));
2228
-                Draw_Float(ui.material_preset[2].bed_temp, row, false, 1);
2229
-              }
2230
-              else
2231
-                Modify_Value(ui.material_preset[2].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1);
2232
-              break;
2233
-          #endif
2234
-          #if HAS_FAN
2235
-            case PREHEAT3_FAN:
2236
-              if (draw) {
2237
-                Draw_Menu_Item(row, ICON_FanSpeed, F("Fan"));
2238
-                Draw_Float(ui.material_preset[2].fan_speed, row, false, 1);
2239
-              }
2240
-              else
2241
-                Modify_Value(ui.material_preset[2].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
2242
-              break;
2243
-          #endif
2244
-        }
2245
-        break;
2246
-    #endif // PREHEAT_COUNT >= 3
2247
-
2248
-    #if PREHEAT_COUNT >= 4
2249
-      case Preheat4:
2250
-
2251
-        #define PREHEAT4_BACK 0
2252
-        #define PREHEAT4_HOTEND (PREHEAT4_BACK + ENABLED(HAS_HOTEND))
2253
-        #define PREHEAT4_BED (PREHEAT4_HOTEND + ENABLED(HAS_HEATED_BED))
2254
-        #define PREHEAT4_FAN (PREHEAT4_BED + ENABLED(HAS_FAN))
2255
-        #define PREHEAT4_TOTAL PREHEAT4_FAN
2256
-
2257
-        switch (item) {
2258
-          case PREHEAT4_BACK:
2259
-            if (draw)
2260
-              Draw_Menu_Item(row, ICON_Back, F("Back"));
2261
-            else
2262
-              Draw_Menu(TempMenu, TEMP_PREHEAT4);
2263
-            break;
2264
-          #if HAS_HOTEND
2265
-            case PREHEAT4_HOTEND:
2266
-              if (draw) {
2267
-                Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend"));
2268
-                Draw_Float(ui.material_preset[3].hotend_temp, row, false, 1);
2269
-              }
2270
-              else
2271
-                Modify_Value(ui.material_preset[3].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1);
2272
-              break;
2273
-          #endif
2274
-          #if HAS_HEATED_BED
2275
-            case PREHEAT4_BED:
2276
-              if (draw) {
2277
-                Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed"));
2278
-                Draw_Float(ui.material_preset[3].bed_temp, row, false, 1);
2279
-              }
2280
-              else
2281
-                Modify_Value(ui.material_preset[3].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1);
2282
-              break;
2283
-          #endif
2284
-          #if HAS_FAN
2285
-            case PREHEAT4_FAN:
2286
-              if (draw) {
2287
-                Draw_Menu_Item(row, ICON_FanSpeed, F("Fan"));
2288
-                Draw_Float(ui.material_preset[3].fan_speed, row, false, 1);
2289
-              }
2290
-              else
2291
-                Modify_Value(ui.material_preset[3].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
2292
-              break;
2293
-          #endif
2294
-        }
2295
-        break;
2296
-    #endif // PREHEAT_COUNT >= 4
2297
-
2298
-    #if PREHEAT_COUNT >= 5
2299
-      case Preheat5:
2300
-
2301
-        #define PREHEAT5_BACK 0
2302
-        #define PREHEAT5_HOTEND (PREHEAT5_BACK + ENABLED(HAS_HOTEND))
2303
-        #define PREHEAT5_BED (PREHEAT5_HOTEND + ENABLED(HAS_HEATED_BED))
2304
-        #define PREHEAT5_FAN (PREHEAT5_BED + ENABLED(HAS_FAN))
2305
-        #define PREHEAT5_TOTAL PREHEAT5_FAN
2306
-
2307
-        switch (item) {
2308
-          case PREHEAT5_BACK:
2309
-            if (draw)
2310
-              Draw_Menu_Item(row, ICON_Back, F("Back"));
2311
-            else
2312
-              Draw_Menu(TempMenu, TEMP_PREHEAT5);
2313
-            break;
2314
-          #if HAS_HOTEND
2315
-            case PREHEAT5_HOTEND:
2316
-              if (draw) {
2317
-                Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend"));
2318
-                Draw_Float(ui.material_preset[4].hotend_temp, row, false, 1);
2319
-              }
2320
-              else
2321
-                Modify_Value(ui.material_preset[4].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1);
2322
-              break;
2323
-          #endif
2324
-          #if HAS_HEATED_BED
2325
-            case PREHEAT5_BED:
2326
-              if (draw) {
2327
-                Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed"));
2328
-                Draw_Float(ui.material_preset[4].bed_temp, row, false, 1);
2329
-              }
2330
-              else
2331
-                Modify_Value(ui.material_preset[4].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1);
2332
-              break;
2333
-          #endif
2334
-          #if HAS_FAN
2335
-            case PREHEAT5_FAN:
2336
-              if (draw) {
2337
-                Draw_Menu_Item(row, ICON_FanSpeed, F("Fan"));
2338
-                Draw_Float(ui.material_preset[4].fan_speed, row, false, 1);
2339
-              }
2340
-              else
2341
-                Modify_Value(ui.material_preset[4].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
2342
-              break;
2343
-          #endif
2344
-        }
2345
-        break;
2346
-    #endif // PREHEAT_COUNT >= 5
2081
+    #if HAS_PREHEAT
2082
+      #define _PREHEAT_SUBMENU_CASE(N) case Preheat##N: preheat_submenu(N, item, TEMP_PREHEAT##N); break;
2083
+      REPEAT_1(PREHEAT_COUNT, _PREHEAT_SUBMENU_CASE)
2084
+    #endif
2347 2085
 
2348 2086
     case Motion:
2349 2087
 
@@ -3855,7 +3593,9 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
3855 3593
       }
3856 3594
       break;
3857 3595
 
3858
-    case PreheatHotend:
3596
+    #if HAS_PREHEAT && HAS_HOTEND
3597
+
3598
+      case PreheatHotend:
3859 3599
 
3860 3600
         #define PREHEATHOTEND_BACK 0
3861 3601
         #define PREHEATHOTEND_CONTINUE (PREHEATHOTEND_BACK + 1)
@@ -3918,46 +3658,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
3918 3658
               }
3919 3659
             }
3920 3660
             break;
3921
-          #if PREHEAT_COUNT >= 1
3922
-            case PREHEATHOTEND_1:
3923
-              if (draw)
3924
-                Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_1_LABEL));
3925
-              else
3926
-                ui.preheat_hotend_and_fan(0);
3927
-              break;
3928
-          #endif
3929
-          #if PREHEAT_COUNT >= 2
3930
-            case PREHEATHOTEND_2:
3931
-              if (draw)
3932
-                Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_2_LABEL));
3933
-              else
3934
-                ui.preheat_hotend_and_fan(1);
3935
-              break;
3936
-          #endif
3937
-          #if PREHEAT_COUNT >= 3
3938
-            case PREHEATHOTEND_3:
3939
-              if (draw)
3940
-                Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_3_LABEL));
3941
-              else
3942
-                ui.preheat_hotend_and_fan(2);
3943
-              break;
3944
-          #endif
3945
-          #if PREHEAT_COUNT >= 4
3946
-            case PREHEATHOTEND_4:
3947
-              if (draw)
3948
-                Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_4_LABEL));
3949
-              else
3950
-                ui.preheat_hotend_and_fan(3);
3951
-              break;
3952
-          #endif
3953
-          #if PREHEAT_COUNT >= 5
3954
-            case PREHEATHOTEND_5:
3955
-              if (draw)
3956
-                Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_5_LABEL));
3957
-              else
3958
-                ui.preheat_hotend_and_fan(4);
3661
+
3662
+
3663
+          #define _PREHEAT_HOTEND_CASE(N) \
3664
+            case PREHEATHOTEND_##N: \
3665
+              if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_## N ##_LABEL)); \
3666
+              else ui.preheat_hotend_and_fan((N) - 1); \
3959 3667
               break;
3960
-          #endif
3668
+
3669
+          REPEAT_1(PREHEAT_COUNT, _PREHEAT_HOTEND_CASE)
3670
+
3961 3671
           case PREHEATHOTEND_CUSTOM:
3962 3672
             if (draw) {
3963 3673
               Draw_Menu_Item(row, ICON_Temperature, F("Custom"));
@@ -3968,6 +3678,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
3968 3678
             break;
3969 3679
         }
3970 3680
         break;
3681
+
3682
+    #endif // HAS_PREHEAT && HAS_HOTEND
3971 3683
   }
3972 3684
 }
3973 3685
 
@@ -3998,20 +3710,9 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) {
3998 3710
     #if HAS_HEATED_BED
3999 3711
       case BedPID:          return F("Bed PID Settings");
4000 3712
     #endif
4001
-    #if PREHEAT_COUNT >= 1
4002
-      case Preheat1:        return F(PREHEAT_1_LABEL " Settings");
4003
-    #endif
4004
-    #if PREHEAT_COUNT >= 2
4005
-      case Preheat2:        return F(PREHEAT_2_LABEL " Settings");
4006
-    #endif
4007
-    #if PREHEAT_COUNT >= 3
4008
-      case Preheat3:        return F(PREHEAT_3_LABEL " Settings");
4009
-    #endif
4010
-    #if PREHEAT_COUNT >= 4
4011
-      case Preheat4:        return F(PREHEAT_4_LABEL " Settings");
4012
-    #endif
4013
-    #if PREHEAT_COUNT >= 5
4014
-      case Preheat5:        return F(PREHEAT_5_LABEL " Settings");
3713
+    #if HAS_PREHEAT
3714
+      #define _PREHEAT_TITLE_CASE(N) case Preheat##N: return F(PREHEAT_## N ##_LABEL " Settings");
3715
+      REPEAT_1(PREHEAT_COUNT, _PREHEAT_TITLE_CASE)
4015 3716
     #endif
4016 3717
     case Motion:            return F("Motion Settings");
4017 3718
     case HomeOffsets:       return F("Home Offsets");
@@ -4074,20 +3775,9 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) {
4074 3775
     #if HAS_HEATED_BED
4075 3776
       case BedPID:          return BEDPID_TOTAL;
4076 3777
     #endif
4077
-    #if PREHEAT_COUNT >= 1
4078
-      case Preheat1:        return PREHEAT1_TOTAL;
4079
-    #endif
4080
-    #if PREHEAT_COUNT >= 2
4081
-      case Preheat2:        return PREHEAT2_TOTAL;
4082
-    #endif
4083
-    #if PREHEAT_COUNT >= 3
4084
-      case Preheat3:        return PREHEAT3_TOTAL;
4085
-    #endif
4086
-    #if PREHEAT_COUNT >= 4
4087
-      case Preheat4:        return PREHEAT4_TOTAL;
4088
-    #endif
4089
-    #if PREHEAT_COUNT >= 5
4090
-      case Preheat5:        return PREHEAT5_TOTAL;
3778
+    #if HAS_PREHEAT
3779
+      case Preheat1 ... CAT(Preheat, PREHEAT_COUNT):
3780
+                            return PREHEAT_SUBMENU_TOTAL;
4091 3781
     #endif
4092 3782
     case Motion:            return MOTION_TOTAL;
4093 3783
     case HomeOffsets:       return HOMEOFFSETS_TOTAL;
@@ -4118,7 +3808,11 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) {
4118 3808
       case LevelManual:     return LEVELING_M_TOTAL;
4119 3809
     #endif
4120 3810
     case Tune:              return TUNE_TOTAL;
4121
-    case PreheatHotend:     return PREHEATHOTEND_TOTAL;
3811
+
3812
+    #if HAS_PREHEAT && HAS_HOTEND
3813
+      case PreheatHotend:   return PREHEATHOTEND_TOTAL;
3814
+    #endif
3815
+
4122 3816
     case ColorSettings:     return COLORSETTINGS_TOTAL;
4123 3817
   }
4124 3818
   return 0;

+ 4
- 5
Marlin/src/lcd/e3v2/jyersui/dwin.h Voir le fichier

@@ -60,11 +60,10 @@ enum menuID : uint8_t {
60 60
         PID,
61 61
           HotendPID,
62 62
           BedPID,
63
-        Preheat1,
64
-        Preheat2,
65
-        Preheat3,
66
-        Preheat4,
67
-        Preheat5,
63
+        #if HAS_PREHEAT
64
+          #define _PREHEAT_ID(N) Preheat##N,
65
+          REPEAT_1(PREHEAT_COUNT, _PREHEAT_ID)
66
+        #endif
68 67
       Motion,
69 68
         HomeOffsets,
70 69
         MaxSpeed,

+ 4
- 17
Marlin/src/lcd/menu/menu_ubl.cpp Voir le fichier

@@ -211,26 +211,13 @@ void _lcd_ubl_edit_mesh() {
211 211
     #if HAS_PREHEAT
212 212
       #if HAS_HEATED_BED
213 213
         #define VALIDATE_MESH_GCODE_ITEM(M) \
214
-          GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26CPI" STRINGIFY(M)))
214
+          GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26CPI" STRINGIFY(M)));
215 215
       #else
216 216
         #define VALIDATE_MESH_GCODE_ITEM(M) \
217
-          GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26CPB0I" STRINGIFY(M)))
217
+          GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26CPB0I" STRINGIFY(M)));
218 218
       #endif
219
-
220
-      VALIDATE_MESH_GCODE_ITEM(0);
221
-      #if PREHEAT_COUNT > 1
222
-        VALIDATE_MESH_GCODE_ITEM(1);
223
-        #if PREHEAT_COUNT > 2
224
-          VALIDATE_MESH_GCODE_ITEM(2);
225
-          #if PREHEAT_COUNT > 3
226
-            VALIDATE_MESH_GCODE_ITEM(3);
227
-            #if PREHEAT_COUNT > 4
228
-              VALIDATE_MESH_GCODE_ITEM(4);
229
-            #endif
230
-          #endif
231
-        #endif
232
-      #endif
233
-    #endif // HAS_PREHEAT
219
+      REPEAT(PREHEAT_COUNT, VALIDATE_MESH_GCODE_ITEM)
220
+    #endif
234 221
     ACTION_ITEM(MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh);
235 222
     ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
236 223
     END_MENU();

Chargement…
Annuler
Enregistrer