Skip to content

Commit

Permalink
Single name for sd card driver
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jun 2, 2021
1 parent dafcd1b commit 3a3e7d0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Marlin/src/HAL/STM32/msc_sd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/menu/menu_media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
17 changes: 7 additions & 10 deletions Marlin/src/sd/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
);

Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/sd/cardreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3a3e7d0

Please sign in to comment.