From 3a3e7d0b131ef7cc46d80e08062e956ef141a5eb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 1 Jun 2021 23:50:40 -0500 Subject: [PATCH] Single name for sd card driver --- Marlin/src/HAL/STM32/msc_sd.cpp | 4 ++-- .../src/lcd/extui/mks_ui/draw_media_select.cpp | 4 ++-- Marlin/src/lcd/menu/menu_media.cpp | 4 ++-- Marlin/src/sd/cardreader.cpp | 17 +++++++---------- Marlin/src/sd/cardreader.h | 10 +++++----- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Marlin/src/HAL/STM32/msc_sd.cpp b/Marlin/src/HAL/STM32/msc_sd.cpp index cbfb837875c83..64f2533002d87 100644 --- a/Marlin/src/HAL/STM32/msc_sd.cpp +++ b/Marlin/src/HAL/STM32/msc_sd.cpp @@ -33,9 +33,9 @@ class Sd2CardUSBMscHandler : public USBMscHandler { DiskIODriver* diskIODriver() { #if ENABLED(MULTI_VOLUME) #if SHARED_VOLUME_IS(SD_ONBOARD) - return &card.media_sd_spi; + return &card.media_driver_sdcard; #elif SHARED_VOLUME_IS(USB_FLASH_DRIVE) - return &card.media_usbFlashDrive; + return &card.media_driver_usbFlash; #endif #else return card.diskIODriver(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp b/Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp index 6fa5cefef0a4c..0394ed6009d69 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp @@ -46,8 +46,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; lv_clear_media_select(); switch (obj->mks_obj_id) { - case ID_T_USB_DISK: card.changeMedia(&card.media_usbFlashDrive); break; - case ID_T_SD_DISK: card.changeMedia(&card.media_sd_spi); break; + case ID_T_USB_DISK: card.changeMedia(&card.media_driver_usbFlash); break; + case ID_T_SD_DISK: card.changeMedia(&card.media_driver_sdcard); break; case ID_T_RETURN: TERN_(MKS_TEST, curent_disp_ui = 1); lv_draw_ready_print(); diff --git a/Marlin/src/lcd/menu/menu_media.cpp b/Marlin/src/lcd/menu/menu_media.cpp index e025ade5ed15e..8630f48b3736f 100644 --- a/Marlin/src/lcd/menu/menu_media.cpp +++ b/Marlin/src/lcd/menu/menu_media.cpp @@ -147,10 +147,10 @@ void menu_media_filelist() { 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_sd_spi); card.mount(); ui.goto_screen(menu_media_filelist); }); + 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_usbFlashDrive); card.mount(); ui.goto_screen(menu_media_filelist); }); + ACTION_ITEM(MSG_USB_DISK, []{ card.changeMedia(&card.media_driver_usbFlash); card.mount(); ui.goto_screen(menu_media_filelist); }); #endif END_MENU(); } diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 3890b08147de9..355289c500dea 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -121,12 +121,11 @@ uint8_t CardReader::workDirDepth; #endif // SDCARD_SORT_ALPHA #if SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) - DiskIODriver_USBFlash CardReader::media_usbFlashDrive; + DiskIODriver_USBFlash CardReader::media_driver_usbFlash; #endif -#if NEED_SD2CARD_SDIO - DiskIODriver_SDIO CardReader::media_sdio; -#elif NEED_SD2CARD_SPI - DiskIODriver_SPI_SD CardReader::media_sd_spi; + +#if NEED_SD2CARD_SDIO || NEED_SD2CARD_SPI + CardReader::sdcard_driver_t CardReader::media_driver_sdcard; #endif DiskIODriver* CardReader::driver = nullptr; @@ -143,12 +142,10 @@ uint32_t CardReader::filesize, CardReader::sdpos; CardReader::CardReader() { changeMedia(& - #if SHARED_VOLUME_IS(SD_ONBOARD) - TERN(SDIO_SUPPORT, media_sdio, media_sd_spi) - #elif SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) - media_usbFlashDrive + #if !SHARED_VOLUME_IS(SD_ONBOARD) && SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) + media_driver_usbFlash #else - TERN(SDIO_SUPPORT, media_sdio, media_sd_spi) + media_driver_sdcard #endif ); diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 35d762742164c..5152cd398fa41 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -235,12 +235,12 @@ class CardReader { #endif #if SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) - static DiskIODriver_USBFlash media_usbFlashDrive; + static DiskIODriver_USBFlash media_driver_usbFlash; #endif - #if NEED_SD2CARD_SDIO - static DiskIODriver_SDIO media_sdio; - #elif NEED_SD2CARD_SPI - static DiskIODriver_SPI_SD media_sd_spi; + + #if NEED_SD2CARD_SDIO || NEED_SD2CARD_SPI + typedef TERN(NEED_SD2CARD_SDIO, DiskIODriver_SDIO, DiskIODriver_SPI_SD) sdcard_driver_t; + static sdcard_driver_t media_driver_sdcard; #endif private: