From f4a89ec7768d68d4ea4ed6976b94f11b759ef7c6 Mon Sep 17 00:00:00 2001
From: daid303 <daid303@gmail.com>
Date: Mon, 12 Nov 2012 09:16:27 +0100
Subject: [PATCH] SDCARDINSERTED is always defined, and thus we do not need the
 #ifdefs.

---
 Marlin/ultralcd.cpp | 73 +++++++++++++++++----------------------------
 1 file changed, 28 insertions(+), 45 deletions(-)

diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp
index c0f2fe8974..45e3bcb568 100644
--- a/Marlin/ultralcd.cpp
+++ b/Marlin/ultralcd.cpp
@@ -2295,11 +2295,7 @@ void MainMenu::showSD()
 //         if(force_lcd_update)
 //         {
 //           lcd.setCursor(0,line);
-//            #ifdef CARDINSERTED
 //           if(CARDINSERTED)
-//           #else
-//           if(true)
-//           #endif
 //           {
 //             LCD_PRINT_PGM(" \004Refresh");
 //           }
@@ -2455,11 +2451,7 @@ void MainMenu::showMainMenu()
         if(force_lcd_update) 
         {
           lcd.setCursor(0,line);
-          #ifdef CARDINSERTED
-            if(CARDINSERTED)
-          #else
-            if(true)
-          #endif
+          if(CARDINSERTED)
           {
             if(card.sdprinting)
               LCD_PRINT_PGM(MSG_STOP_PRINT);
@@ -2471,10 +2463,7 @@ void MainMenu::showMainMenu()
            LCD_PRINT_PGM(MSG_NO_CARD); 
           }
         }
-        #ifdef CARDINSERTED
-          if(CARDINSERTED)
-        #endif
-        if((activeline==line)&&CLICKED)
+        if(CARDINSERTED&&(activeline==line)&&CLICKED)
         {
           card.printingHasFinished();
           BLOCK;
@@ -2487,41 +2476,34 @@ void MainMenu::showMainMenu()
             if(force_lcd_update)
             {
                 lcd.setCursor(0,line);
-#ifdef CARDINSERTED
                 if(CARDINSERTED)
-#else
-                    if(true)
-#endif
-                    {
-                        if(card.sdprinting)
-                            LCD_PRINT_PGM(MSG_PAUSE_PRINT);
-                        else
-                            LCD_PRINT_PGM(MSG_RESUME_PRINT);
-                    }
-                    else
-                    {
-                        //LCD_PRINT_PGM(MSG_NO_CARD);
-                    }
-            }
-#ifdef CARDINSERTED
-            if(CARDINSERTED)
-#endif
-                if((activeline==line) && CLICKED)
                 {
                     if(card.sdprinting)
-                    {
-                        card.pauseSDPrint();
-                        beepshort();
-                        status = Main_Status;
-                    }
+                        LCD_PRINT_PGM(MSG_PAUSE_PRINT);
                     else
-                    {
-                        card.startFileprint();
-                        starttime=millis();
-                        beepshort();
-                        status = Main_Status;
-                    }
+                        LCD_PRINT_PGM(MSG_RESUME_PRINT);
+                }
+                else
+                {
+                    //LCD_PRINT_PGM(MSG_NO_CARD);
+                }
+            }
+            if(CARDINSERTED && (activeline==line) && CLICKED)
+            {
+                if(card.sdprinting)
+                {
+                    card.pauseSDPrint();
+                    beepshort();
+                    status = Main_Status;
                 }
+                else
+                {
+                    card.startFileprint();
+                    starttime=millis();
+                    beepshort();
+                    status = Main_Status;
+                }
+            }
         }break;
       #else
       case ItemM_file:
@@ -2550,8 +2532,9 @@ void MainMenu::update()
 {
   static MainStatus oldstatus=Main_Menu;  //init automatically causes foce_lcd_update=true
   static unsigned long timeoutToStatus=0;
-  static bool oldcardstatus=false;
-  #ifdef CARDINSERTED
+  #if (SDCARDDETECT > -1)
+    //This code is only relivant if you have an SDcard detect pin.
+    static bool oldcardstatus=false;
     if((CARDINSERTED != oldcardstatus))
     {
       force_lcd_update=true;
-- 
GitLab