From eb1c9113c23869b839abb63b7a43f84d13ed603c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 15 Jun 2019 15:32:09 -0500 Subject: [PATCH] Try to init SD with no detect pin --- Marlin/src/Marlin.cpp | 2 +- Marlin/src/lcd/ultralcd.cpp | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 52555e1e8..b21d5593f 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -937,7 +937,7 @@ void setup() { ui.show_bootscreen(); #endif - #if ENABLED(SDIO_SUPPORT) && SD_DETECT_PIN == -1 + #if ENABLED(SDIO_SUPPORT) && !PIN_EXISTS(SD_DETECT) // Auto-mount the SD for EEPROM.dat emulation if (!card.isDetected()) card.initsd(); #endif diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 13f5f5fb0..7a3ea4538 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -104,7 +104,7 @@ #endif #endif -#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) +#if ENABLED(SDSUPPORT) uint8_t lcd_sd_status; #endif @@ -315,8 +315,10 @@ void MarlinUI::init() { #endif // HAS_SHIFT_ENCODER - #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) - SET_INPUT_PULLUP(SD_DETECT_PIN); + #if ENABLED(SDSUPPORT) + #if PIN_EXISTS(SD_DETECT) + SET_INPUT_PULLUP(SD_DETECT_PIN); + #endif lcd_sd_status = 2; // UNKNOWN #endif @@ -766,7 +768,7 @@ void MarlinUI::update() { #endif // HAS_LCD_MENU - #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) + #if ENABLED(SDSUPPORT) const uint8_t sd_status = (uint8_t)IS_SD_INSERTED(); if (sd_status != lcd_sd_status && detected()) { @@ -782,16 +784,20 @@ void MarlinUI::update() { else set_status_P(PSTR(MSG_SD_INSERTED)); } - else { - card.release(); - if (old_sd_status != 2) { - set_status_P(PSTR(MSG_SD_REMOVED)); - if (!on_status_screen()) return_to_status(); + #if PIN_EXISTS(SD_DETECT) + else { + card.release(); + if (old_sd_status != 2) { + set_status_P(PSTR(MSG_SD_REMOVED)); + if (!on_status_screen()) return_to_status(); + } } - } + + init_lcd(); // May revive the LCD if static electricity killed it + + #endif refresh(); - init_lcd(); // May revive the LCD if static electricity killed it ms = millis(); next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL; // delay LCD update until after SD activity completes @@ -801,7 +807,7 @@ void MarlinUI::update() { #endif } - #endif // SDSUPPORT && SD_DETECT_PIN + #endif // SDSUPPORT if (ELAPSED(ms, next_lcd_update_ms) #if HAS_GRAPHICAL_LCD