MULTI_VOLUME for Color UI and MarlinUI (#22004)

This commit is contained in:
Victor Oliveira 2021-06-14 02:39:16 -03:00 committed by Scott Lahteine
parent d84e2d6e29
commit 2b4284df81
6 changed files with 45 additions and 22 deletions

View File

@ -33,9 +33,9 @@ public:
DiskIODriver* diskIODriver() { DiskIODriver* diskIODriver() {
#if ENABLED(MULTI_VOLUME) #if ENABLED(MULTI_VOLUME)
#if SHARED_VOLUME_IS(SD_ONBOARD) #if SHARED_VOLUME_IS(SD_ONBOARD)
return &card.media_sd_spi; return &card.media_driver_sdcard;
#elif SHARED_VOLUME_IS(USB_FLASH_DRIVE) #elif SHARED_VOLUME_IS(USB_FLASH_DRIVE)
return &card.media_usbFlashDrive; return &card.media_driver_usbFlash;
#endif #endif
#else #else
return card.diskIODriver(); return card.diskIODriver();

View File

@ -46,8 +46,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return; if (event != LV_EVENT_RELEASED) return;
lv_clear_media_select(); lv_clear_media_select();
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_T_USB_DISK: card.changeMedia(&card.media_usbFlashDrive); break; case ID_T_USB_DISK: card.changeMedia(&card.media_driver_usbFlash); break;
case ID_T_SD_DISK: card.changeMedia(&card.media_sd_spi); break; case ID_T_SD_DISK: card.changeMedia(&card.media_driver_sdcard); break;
case ID_T_RETURN: case ID_T_RETURN:
TERN_(MKS_TEST, curent_disp_ui = 1); TERN_(MKS_TEST, curent_disp_ui = 1);
lv_draw_ready_print(); lv_draw_ready_print();

View File

@ -740,6 +740,9 @@ namespace Language_en {
PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Calibration Failed"); PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Calibration Failed");
PROGMEM Language_Str MSG_DRIVER_BACKWARD = _UxGT(" driver backward"); PROGMEM Language_Str MSG_DRIVER_BACKWARD = _UxGT(" driver backward");
PROGMEM Language_Str MSG_SD_CARD = _UxGT("SD Card");
PROGMEM Language_Str MSG_USB_DISK = _UxGT("USB Disk");
} }
#if FAN_COUNT == 1 #if FAN_COUNT == 1

View File

@ -104,7 +104,7 @@ class MenuItem_sdfolder : public MenuItem_sdbase {
} }
}; };
void menu_media() { void menu_media_filelist() {
ui.encoder_direction_menus(); ui.encoder_direction_menus();
#if HAS_MARLINUI_U8GLIB #if HAS_MARLINUI_U8GLIB
@ -115,7 +115,11 @@ void menu_media() {
#endif #endif
START_MENU(); START_MENU();
BACK_ITEM_P(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT(MSG_MAIN) : GET_TEXT(MSG_BACK)); #if ENABLED(MULTI_VOLUME)
ACTION_ITEM(MSG_BACK, []{ ui.goto_screen(menu_media); });
#else
BACK_ITEM_P(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT(MSG_MAIN) : GET_TEXT(MSG_BACK));
#endif
if (card.flag.workDirIsRoot) { if (card.flag.workDirIsRoot) {
#if !PIN_EXISTS(SD_DETECT) #if !PIN_EXISTS(SD_DETECT)
ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); }); ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); });
@ -138,4 +142,22 @@ void menu_media() {
END_MENU(); END_MENU();
} }
#if ENABLED(MULTI_VOLUME)
void menu_media_select() {
START_MENU();
BACK_ITEM_P(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT(MSG_MAIN) : GET_TEXT(MSG_BACK));
#if ENABLED(VOLUME_SD_ONBOARD)
ACTION_ITEM(MSG_SD_CARD, []{ card.changeMedia(&card.media_driver_sdcard); card.mount(); ui.goto_screen(menu_media_filelist); });
#endif
#if ENABLED(VOLUME_USB_FLASH_DRIVE)
ACTION_ITEM(MSG_USB_DISK, []{ card.changeMedia(&card.media_driver_usbFlash); card.mount(); ui.goto_screen(menu_media_filelist); });
#endif
END_MENU();
}
#endif
void menu_media() {
TERN(MULTI_VOLUME, menu_media_select, menu_media_filelist)();
}
#endif // HAS_LCD_MENU && SDSUPPORT #endif // HAS_LCD_MENU && SDSUPPORT

View File

@ -121,13 +121,12 @@ uint8_t CardReader::workDirDepth;
#endif // SDCARD_SORT_ALPHA #endif // SDCARD_SORT_ALPHA
#if SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) #if HAS_USB_FLASH_DRIVE
DiskIODriver_USBFlash CardReader::media_usbFlashDrive; DiskIODriver_USBFlash CardReader::media_driver_usbFlash;
#endif #endif
#if NEED_SD2CARD_SDIO
DiskIODriver_SDIO CardReader::media_sdio; #if NEED_SD2CARD_SDIO || NEED_SD2CARD_SPI
#elif NEED_SD2CARD_SPI CardReader::sdcard_driver_t CardReader::media_driver_sdcard;
DiskIODriver_SPI_SD CardReader::media_sd_spi;
#endif #endif
DiskIODriver* CardReader::driver = nullptr; DiskIODriver* CardReader::driver = nullptr;
@ -144,12 +143,10 @@ uint32_t CardReader::filesize, CardReader::sdpos;
CardReader::CardReader() { CardReader::CardReader() {
changeMedia(& changeMedia(&
#if SHARED_VOLUME_IS(SD_ONBOARD) #if HAS_USB_FLASH_DRIVE && !SHARED_VOLUME_IS(SD_ONBOARD)
TERN(SDIO_SUPPORT, media_sdio, media_sd_spi) media_driver_usbFlash
#elif SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT)
media_usbFlashDrive
#else #else
TERN(SDIO_SUPPORT, media_sdio, media_sd_spi) media_driver_sdcard
#endif #endif
); );

View File

@ -235,12 +235,13 @@ public:
#endif #endif
#if SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) #if SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT)
static DiskIODriver_USBFlash media_usbFlashDrive; #define HAS_USB_FLASH_DRIVE 1
static DiskIODriver_USBFlash media_driver_usbFlash;
#endif #endif
#if NEED_SD2CARD_SDIO
static DiskIODriver_SDIO media_sdio; #if NEED_SD2CARD_SDIO || NEED_SD2CARD_SPI
#elif NEED_SD2CARD_SPI typedef TERN(NEED_SD2CARD_SDIO, DiskIODriver_SDIO, DiskIODriver_SPI_SD) sdcard_driver_t;
static DiskIODriver_SPI_SD media_sd_spi; static sdcard_driver_t media_driver_sdcard;
#endif #endif
private: private: