Просмотр исходного кода

✨ MEDIA_MENU_AT_TOP for MarlinUI (#21925)

Pascal de Bruijn 3 лет назад
Родитель
Сommit
781b34709b
Аккаунт пользователя с таким Email не найден
3 измененных файлов: 42 добавлений и 65 удалений
  1. 2
    0
      Marlin/Configuration_adv.h
  2. 38
    63
      Marlin/src/lcd/menu/menu_main.cpp
  3. 2
    2
      buildroot/tests/mega2560

+ 2
- 0
Marlin/Configuration_adv.h Просмотреть файл

@@ -1301,6 +1301,8 @@
1301 1301
 
1302 1302
   //#define BROWSE_MEDIA_ON_INSERT          // Open the file browser when media is inserted
1303 1303
 
1304
+  //#define MEDIA_MENU_AT_TOP               // Force the media menu to be listed on the top of the main menu
1305
+
1304 1306
   #define EVENT_GCODE_SD_ABORT "G28XY"      // G-code to run on SD Abort Print (e.g., "G28XY" or "G27")
1305 1307
 
1306 1308
   #if ENABLED(PRINTER_EVENT_LEDS)

+ 38
- 63
Marlin/src/lcd/menu/menu_main.cpp Просмотреть файл

@@ -254,6 +254,38 @@ void menu_main() {
254 254
   START_MENU();
255 255
   BACK_ITEM(MSG_INFO_SCREEN);
256 256
 
257
+  #if ENABLED(SDSUPPORT)
258
+
259
+    #if !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL
260
+      #define MEDIA_MENU_AT_TOP
261
+    #endif
262
+
263
+    auto sdcard_menu_items = [&]{
264
+      #if ENABLED(MENU_ADDAUTOSTART)
265
+        ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files
266
+      #endif
267
+
268
+      if (card_detected) {
269
+        if (!card_open) {
270
+          #if PIN_EXISTS(SD_DETECT)
271
+            GCODES_ITEM(MSG_CHANGE_MEDIA, PSTR("M21"));       // M21 Change Media
272
+          #else                                               // - or -
273
+            GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22"));      // M22 Release Media
274
+          #endif
275
+          SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY);        // Media Menu (or Password First)
276
+        }
277
+      }
278
+      else {
279
+        #if PIN_EXISTS(SD_DETECT)
280
+          ACTION_ITEM(MSG_NO_MEDIA, nullptr);                 // "No Media"
281
+        #else
282
+          GCODES_ITEM(MSG_ATTACH_MEDIA, PSTR("M21"));         // M21 Attach Media
283
+        #endif
284
+      }
285
+    };
286
+
287
+  #endif
288
+
257 289
   if (busy) {
258 290
     #if MACHINE_CAN_PAUSE
259 291
       ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print);
@@ -281,36 +313,9 @@ void menu_main() {
281 313
   }
282 314
   else {
283 315
 
284
-    #if !HAS_ENCODER_WHEEL && ENABLED(SDSUPPORT)
285
-
286
-      // *** IF THIS SECTION IS CHANGED, REPRODUCE BELOW ***
287
-
288
-      //
289
-      // Run Auto Files
290
-      //
291
-      #if ENABLED(MENU_ADDAUTOSTART)
292
-        ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin);
293
-      #endif
294
-
295
-      if (card_detected) {
296
-        if (!card_open) {
297
-          SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY);
298
-          #if PIN_EXISTS(SD_DETECT)
299
-            GCODES_ITEM(MSG_CHANGE_MEDIA, PSTR("M21"));
300
-          #else
301
-            GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22"));
302
-          #endif
303
-        }
304
-      }
305
-      else {
306
-        #if PIN_EXISTS(SD_DETECT)
307
-          ACTION_ITEM(MSG_NO_MEDIA, nullptr);
308
-        #else
309
-          GCODES_ITEM(MSG_ATTACH_MEDIA, PSTR("M21"));
310
-        #endif
311
-      }
312
-
313
-    #endif // !HAS_ENCODER_WHEEL && SDSUPPORT
316
+    #if BOTH(SDSUPPORT, MEDIA_MENU_AT_TOP)
317
+      sdcard_menu_items();
318
+    #endif
314 319
 
315 320
     if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused()))
316 321
       ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print);
@@ -387,39 +392,9 @@ void menu_main() {
387 392
       GCODES_ITEM(MSG_SWITCH_PS_ON, PSTR("M80"));
388 393
   #endif
389 394
 
390
-  #if BOTH(HAS_ENCODER_WHEEL, SDSUPPORT)
391
-
392
-    if (!busy) {
393
-
394
-      // *** IF THIS SECTION IS CHANGED, REPRODUCE ABOVE ***
395
-
396
-      //
397
-      // Autostart
398
-      //
399
-      #if ENABLED(MENU_ADDAUTOSTART)
400
-        ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin);
401
-      #endif
402
-
403
-      if (card_detected) {
404
-        if (!card_open) {
405
-          #if PIN_EXISTS(SD_DETECT)
406
-            GCODES_ITEM(MSG_CHANGE_MEDIA, PSTR("M21"));
407
-          #else
408
-            GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22"));
409
-          #endif
410
-          SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY);
411
-        }
412
-      }
413
-      else {
414
-        #if PIN_EXISTS(SD_DETECT)
415
-          ACTION_ITEM(MSG_NO_MEDIA, nullptr);
416
-        #else
417
-          GCODES_ITEM(MSG_ATTACH_MEDIA, PSTR("M21"));
418
-        #endif
419
-      }
420
-    }
421
-
422
-  #endif // HAS_ENCODER_WHEEL && SDSUPPORT
395
+  #if ENABLED(SDSUPPORT) && DISABLED(MEDIA_MENU_AT_TOP)
396
+    sdcard_menu_items();
397
+  #endif
423 398
 
424 399
   #if HAS_SERVICE_INTERVALS
425 400
     static auto _service_reset = [](const int index) {

+ 2
- 2
buildroot/tests/mega2560 Просмотреть файл

@@ -20,8 +20,8 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE fr \
20 20
         EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 5 TEMP_SENSOR_3 20 TEMP_SENSOR_4 1000 TEMP_SENSOR_BED 1
21 21
 opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \
22 22
            REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \
23
-           SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT AUTO_REPORT_SD_STATUS SCROLL_LONG_FILENAMES CANCEL_OBJECTS SOUND_MENU_ITEM \
24
-           EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN FREEZE_FEATURE \
23
+           SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT AUTO_REPORT_SD_STATUS SCROLL_LONG_FILENAMES MEDIA_MENU_AT_TOP \
24
+           EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN FREEZE_FEATURE CANCEL_OBJECTS SOUND_MENU_ITEM \
25 25
            MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \
26 26
            LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \
27 27
            BABYSTEPPING BABYSTEP_XY NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL

Загрузка…
Отмена
Сохранить