parent
92910721d0
commit
ce9c81dfa1
|
@ -598,7 +598,7 @@ void MarlinHAL::dma_init() {
|
||||||
void MarlinHAL::init() {
|
void MarlinHAL::init() {
|
||||||
TERN_(DMA_IS_REQUIRED, dma_init());
|
TERN_(DMA_IS_REQUIRED, dma_init());
|
||||||
#if ENABLED(SDSUPPORT)
|
#if ENABLED(SDSUPPORT)
|
||||||
#if SD_CONNECTION_IS(ONBOARD) && PIN_EXISTS(SD_DETECT)
|
#if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD)
|
||||||
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
||||||
#endif
|
#endif
|
||||||
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||||
|
|
|
@ -435,20 +435,28 @@
|
||||||
#define HAS_SHARED_MEDIA 1
|
#define HAS_SHARED_MEDIA 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set SD_DETECT_STATE based on hardware if not overridden
|
|
||||||
#if PIN_EXISTS(SD_DETECT) && !defined(SD_DETECT_STATE)
|
|
||||||
#if BOTH(HAS_MARLINUI_MENU, ELB_FULL_GRAPHIC_CONTROLLER) && (SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION))
|
|
||||||
#define SD_DETECT_STATE HIGH
|
|
||||||
#else
|
|
||||||
#define SD_DETECT_STATE LOW
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Extender cable doesn't support SD_DETECT_PIN
|
// Extender cable doesn't support SD_DETECT_PIN
|
||||||
#if ENABLED(NO_SD_DETECT)
|
#if ENABLED(NO_SD_DETECT)
|
||||||
#undef SD_DETECT_PIN
|
#undef SD_DETECT_PIN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Not onboard or custom cable
|
||||||
|
#if SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION)
|
||||||
|
#define SD_CONNECTION_TYPICAL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Set SD_DETECT_STATE based on hardware if not overridden
|
||||||
|
#if PIN_EXISTS(SD_DETECT)
|
||||||
|
#define HAS_SD_DETECT 1
|
||||||
|
#ifndef SD_DETECT_STATE
|
||||||
|
#if ALL(SD_CONNECTION_TYPICAL, HAS_MARLINUI_MENU, ELB_FULL_GRAPHIC_CONTROLLER)
|
||||||
|
#define SD_DETECT_STATE HIGH
|
||||||
|
#else
|
||||||
|
#define SD_DETECT_STATE LOW
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if DISABLED(USB_FLASH_DRIVE_SUPPORT) || BOTH(MULTI_VOLUME, VOLUME_SD_ONBOARD)
|
#if DISABLED(USB_FLASH_DRIVE_SUPPORT) || BOTH(MULTI_VOLUME, VOLUME_SD_ONBOARD)
|
||||||
#if ENABLED(SDIO_SUPPORT)
|
#if ENABLED(SDIO_SUPPORT)
|
||||||
#define NEED_SD2CARD_SDIO 1
|
#define NEED_SD2CARD_SDIO 1
|
||||||
|
@ -457,10 +465,10 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#if HAS_SD_DETECT && NONE(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI, EXTENSIBLE_UI, HAS_DWIN_E3V2)
|
||||||
|
#define REINIT_NOISY_LCD 1 // Have the LCD re-init on SD insertion
|
||||||
|
#endif
|
||||||
|
|
||||||
#if PIN_EXISTS(SD_DETECT) && NONE(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI, EXTENSIBLE_UI, HAS_DWIN_E3V2)
|
|
||||||
#define REINIT_NOISY_LCD 1 // Have the LCD re-init on SD insertion
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -879,9 +879,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
|
||||||
/**
|
/**
|
||||||
* SD Card Settings
|
* SD Card Settings
|
||||||
*/
|
*/
|
||||||
#if ALL(SDSUPPORT, ELB_FULL_GRAPHIC_CONTROLLER, HAS_MARLINUI_MENU) && PIN_EXISTS(SD_DETECT) && SD_DETECT_STATE != HIGH && (SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION))
|
#if ALL(SDSUPPORT, HAS_SD_DETECT, SD_CONNECTION_TYPICAL, ELB_FULL_GRAPHIC_CONTROLLER, HAS_MARLINUI_MENU) && SD_DETECT_STATE == LOW
|
||||||
#error "SD_DETECT_STATE must be set HIGH for SD on the ELB_FULL_GRAPHIC_CONTROLLER."
|
#error "SD_DETECT_STATE must be set HIGH for SD on the ELB_FULL_GRAPHIC_CONTROLLER."
|
||||||
#endif
|
#endif
|
||||||
|
#undef SD_CONNECTION_TYPICAL
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SD File Sorting
|
* SD File Sorting
|
||||||
|
|
|
@ -86,7 +86,7 @@ void AnycubicTFTClass::OnSetup() {
|
||||||
delay_ms(10);
|
delay_ms(10);
|
||||||
|
|
||||||
// Init the state of the key pins running on the TFT
|
// Init the state of the key pins running on the TFT
|
||||||
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
|
#if BOTH(SDSUPPORT, HAS_SD_DETECT)
|
||||||
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
|
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
|
||||||
|
@ -916,7 +916,7 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnycubicTFTClass::DoSDCardStateCheck() {
|
void AnycubicTFTClass::DoSDCardStateCheck() {
|
||||||
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
|
#if BOTH(SDSUPPORT, HAS_SD_DETECT)
|
||||||
bool isInserted = isMediaInserted();
|
bool isInserted = isMediaInserted();
|
||||||
if (isInserted)
|
if (isInserted)
|
||||||
SENDLINE_DBG_PGM("J00", "TFT Serial Debug: SD card state changed... isInserted");
|
SENDLINE_DBG_PGM("J00", "TFT Serial Debug: SD card state changed... isInserted");
|
||||||
|
|
|
@ -47,9 +47,7 @@ void DGUSRxHandler::ScreenChange(DGUS_VP &vp, void *data_ptr) {
|
||||||
|
|
||||||
if (vp.addr == DGUS_Addr::SCREENCHANGE_SD) {
|
if (vp.addr == DGUS_Addr::SCREENCHANGE_SD) {
|
||||||
#if ENABLED(SDSUPPORT)
|
#if ENABLED(SDSUPPORT)
|
||||||
#if !PIN_EXISTS(SD_DETECT)
|
IF_DISABLED(HAS_SD_DETECT, card.mount());
|
||||||
card.mount();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!ExtUI::isMediaInserted()) {
|
if (!ExtUI::isMediaInserted()) {
|
||||||
dgus_screen_handler.SetStatusMessage(GET_TEXT_F(MSG_NO_MEDIA));
|
dgus_screen_handler.SetStatusMessage(GET_TEXT_F(MSG_NO_MEDIA));
|
||||||
|
|
|
@ -137,8 +137,7 @@ void tft_lvgl_init() {
|
||||||
uint16_t usb_flash_loop = 1000;
|
uint16_t usb_flash_loop = 1000;
|
||||||
#if ENABLED(MULTI_VOLUME) && !HAS_SD_HOST_DRIVE
|
#if ENABLED(MULTI_VOLUME) && !HAS_SD_HOST_DRIVE
|
||||||
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
||||||
if (READ(SD_DETECT_PIN) == LOW) card.changeMedia(&card.media_driver_sdcard);
|
card.changeMedia(IS_SD_INSERTED() ? &card.media_driver_sdcard : &card.media_driver_usbFlash);
|
||||||
else card.changeMedia(&card.media_driver_usbFlash);
|
|
||||||
#endif
|
#endif
|
||||||
do {
|
do {
|
||||||
card.media_driver_usbFlash.idle();
|
card.media_driver_usbFlash.idle();
|
||||||
|
|
|
@ -1756,7 +1756,7 @@ void MarlinUI::init() {
|
||||||
if (old_status < 2) {
|
if (old_status < 2) {
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
ExtUI::onMediaRemoved();
|
ExtUI::onMediaRemoved();
|
||||||
#elif PIN_EXISTS(SD_DETECT)
|
#elif HAS_SD_DETECT
|
||||||
LCD_MESSAGE(MSG_MEDIA_REMOVED);
|
LCD_MESSAGE(MSG_MEDIA_REMOVED);
|
||||||
#if HAS_MARLINUI_MENU
|
#if HAS_MARLINUI_MENU
|
||||||
if (!defer_return_to_status) return_to_status();
|
if (!defer_return_to_status) return_to_status();
|
||||||
|
|
|
@ -246,7 +246,7 @@ void menu_main() {
|
||||||
|
|
||||||
if (card_detected) {
|
if (card_detected) {
|
||||||
if (!card_open) {
|
if (!card_open) {
|
||||||
#if PIN_EXISTS(SD_DETECT)
|
#if HAS_SD_DETECT
|
||||||
GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21")); // M21 Change Media
|
GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21")); // M21 Change Media
|
||||||
#else // - or -
|
#else // - or -
|
||||||
ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media
|
ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media
|
||||||
|
@ -262,7 +262,7 @@ void menu_main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if PIN_EXISTS(SD_DETECT)
|
#if HAS_SD_DETECT
|
||||||
ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media"
|
ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media"
|
||||||
#else
|
#else
|
||||||
GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21")); // M21 Attach Media
|
GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21")); // M21 Attach Media
|
||||||
|
|
|
@ -122,7 +122,7 @@ void menu_media_filelist() {
|
||||||
BACK_ITEM_F(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT_F(MSG_MAIN) : GET_TEXT_F(MSG_BACK));
|
BACK_ITEM_F(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT_F(MSG_MAIN) : GET_TEXT_F(MSG_BACK));
|
||||||
#endif
|
#endif
|
||||||
if (card.flag.workDirIsRoot) {
|
if (card.flag.workDirIsRoot) {
|
||||||
#if !PIN_EXISTS(SD_DETECT)
|
#if !HAS_SD_DETECT
|
||||||
ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); });
|
ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); });
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ CardReader::CardReader() {
|
||||||
workDirDepth = 0;
|
workDirDepth = 0;
|
||||||
ZERO(workDirParents);
|
ZERO(workDirParents);
|
||||||
|
|
||||||
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
|
#if BOTH(SDSUPPORT, HAS_SD_DETECT)
|
||||||
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -456,10 +456,11 @@ void CardReader::mount() {
|
||||||
|
|
||||||
if (flag.mounted)
|
if (flag.mounted)
|
||||||
cdroot();
|
cdroot();
|
||||||
#if ENABLED(USB_FLASH_DRIVE_SUPPORT) || PIN_EXISTS(SD_DETECT)
|
else {
|
||||||
else if (marlin_state != MF_INITIALIZING)
|
#if EITHER(HAS_SD_DETECT, USB_FLASH_DRIVE_SUPPORT)
|
||||||
LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL);
|
if (marlin_state != MF_INITIALIZING) LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
ui.refresh();
|
ui.refresh();
|
||||||
}
|
}
|
||||||
|
@ -496,15 +497,15 @@ void CardReader::manage_media() {
|
||||||
if (TERN1(SD_IGNORE_AT_STARTUP, old_stat != 2)) mount();
|
if (TERN1(SD_IGNORE_AT_STARTUP, old_stat != 2)) mount();
|
||||||
if (!isMounted()) { // Not mounted?
|
if (!isMounted()) { // Not mounted?
|
||||||
stat = 0;
|
stat = 0;
|
||||||
IF_DISABLED(SD_IGNORE_AT_STARTUP, prev_stat = 0);
|
#if HAS_SD_DETECT && DISABLED(SD_IGNORE_AT_STARTUP)
|
||||||
|
prev_stat = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TERN_(RESET_STEPPERS_ON_MEDIA_INSERT, reset_stepper_drivers()); // Workaround for Cheetah bug
|
TERN_(RESET_STEPPERS_ON_MEDIA_INSERT, reset_stepper_drivers()); // Workaround for Cheetah bug
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if PIN_EXISTS(SD_DETECT)
|
TERN_(HAS_SD_DETECT, release()); // Card is released
|
||||||
release(); // Card is released
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.media_changed(old_stat, stat); // Update the UI or flag an error
|
ui.media_changed(old_stat, stat); // Update the UI or flag an error
|
||||||
|
|
|
@ -362,7 +362,7 @@ private:
|
||||||
|
|
||||||
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
|
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
|
||||||
#define IS_SD_INSERTED() DiskIODriver_USBFlash::isInserted()
|
#define IS_SD_INSERTED() DiskIODriver_USBFlash::isInserted()
|
||||||
#elif PIN_EXISTS(SD_DETECT)
|
#elif HAS_SD_DETECT
|
||||||
#define IS_SD_INSERTED() (READ(SD_DETECT_PIN) == SD_DETECT_STATE)
|
#define IS_SD_INSERTED() (READ(SD_DETECT_PIN) == SD_DETECT_STATE)
|
||||||
#else
|
#else
|
||||||
// No card detect line? Assume the card is inserted.
|
// No card detect line? Assume the card is inserted.
|
||||||
|
|
Loading…
Reference in a new issue