Browse Source

Try to init SD with no detect pin

Scott Lahteine 6 years ago
parent
commit
eb1c9113c2
2 changed files with 19 additions and 13 deletions
  1. 1
    1
      Marlin/src/Marlin.cpp
  2. 18
    12
      Marlin/src/lcd/ultralcd.cpp

+ 1
- 1
Marlin/src/Marlin.cpp View File

@@ -937,7 +937,7 @@ void setup() {
937 937
     ui.show_bootscreen();
938 938
   #endif
939 939
 
940
-  #if ENABLED(SDIO_SUPPORT) && SD_DETECT_PIN == -1
940
+  #if ENABLED(SDIO_SUPPORT) && !PIN_EXISTS(SD_DETECT)
941 941
     // Auto-mount the SD for EEPROM.dat emulation
942 942
     if (!card.isDetected()) card.initsd();
943 943
   #endif

+ 18
- 12
Marlin/src/lcd/ultralcd.cpp View File

@@ -104,7 +104,7 @@
104 104
   #endif
105 105
 #endif
106 106
 
107
-#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
107
+#if ENABLED(SDSUPPORT)
108 108
   uint8_t lcd_sd_status;
109 109
 #endif
110 110
 
@@ -315,8 +315,10 @@ void MarlinUI::init() {
315 315
 
316 316
   #endif // HAS_SHIFT_ENCODER
317 317
 
318
-  #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
319
-    SET_INPUT_PULLUP(SD_DETECT_PIN);
318
+  #if ENABLED(SDSUPPORT)
319
+    #if PIN_EXISTS(SD_DETECT)
320
+      SET_INPUT_PULLUP(SD_DETECT_PIN);
321
+    #endif
320 322
     lcd_sd_status = 2; // UNKNOWN
321 323
   #endif
322 324
 
@@ -766,7 +768,7 @@ void MarlinUI::update() {
766 768
 
767 769
   #endif // HAS_LCD_MENU
768 770
 
769
-  #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
771
+  #if ENABLED(SDSUPPORT)
770 772
 
771 773
     const uint8_t sd_status = (uint8_t)IS_SD_INSERTED();
772 774
     if (sd_status != lcd_sd_status && detected()) {
@@ -782,16 +784,20 @@ void MarlinUI::update() {
782 784
         else
783 785
           set_status_P(PSTR(MSG_SD_INSERTED));
784 786
       }
785
-      else {
786
-        card.release();
787
-        if (old_sd_status != 2) {
788
-          set_status_P(PSTR(MSG_SD_REMOVED));
789
-          if (!on_status_screen()) return_to_status();
787
+      #if PIN_EXISTS(SD_DETECT)
788
+        else {
789
+          card.release();
790
+          if (old_sd_status != 2) {
791
+            set_status_P(PSTR(MSG_SD_REMOVED));
792
+            if (!on_status_screen()) return_to_status();
793
+          }
790 794
         }
791
-      }
795
+
796
+        init_lcd(); // May revive the LCD if static electricity killed it
797
+
798
+      #endif
792 799
 
793 800
       refresh();
794
-      init_lcd(); // May revive the LCD if static electricity killed it
795 801
 
796 802
       ms = millis();
797 803
       next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;  // delay LCD update until after SD activity completes
@@ -801,7 +807,7 @@ void MarlinUI::update() {
801 807
       #endif
802 808
     }
803 809
 
804
-  #endif // SDSUPPORT && SD_DETECT_PIN
810
+  #endif // SDSUPPORT
805 811
 
806 812
   if (ELAPSED(ms, next_lcd_update_ms)
807 813
     #if HAS_GRAPHICAL_LCD

Loading…
Cancel
Save