From 5d65a36dee638ffcd6c605142bd1efb11da8c834 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Sep 2015 16:43:14 -0700 Subject: [PATCH] Give lcd_sd_status an UNKNOWN state (PR#180) --- Marlin/ultralcd.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 720e9faa01..6fe7a299ee 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -227,7 +227,7 @@ static void lcd_status_screen(); uint8_t lastEncoderBits; uint32_t encoderPosition; #if PIN_EXISTS(SD_DETECT) - bool lcd_sd_status; + uint8_t lcd_sd_status; #endif #endif // ULTIPANEL @@ -1534,7 +1534,7 @@ void lcd_init() { #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) pinMode(SD_DETECT_PIN, INPUT); WRITE(SD_DETECT_PIN, HIGH); - lcd_sd_status = false; + lcd_sd_status = 2; // UNKNOWN #endif #if ENABLED(LCD_HAS_SLOW_BUTTONS) @@ -1595,21 +1595,22 @@ void lcd_update() { bool sd_status = IS_SD_INSERTED; if (sd_status != lcd_sd_status && lcd_detected()) { lcdDrawUpdate = 2; - lcd_sd_status = sd_status; lcd_implementation_init( // to maybe revive the LCD if static electricity killed it. #if ENABLED(LCD_PROGRESS_BAR) currentMenu == lcd_status_screen #endif ); - if (lcd_sd_status) { + if (sd_status) { card.initsd(); - LCD_MESSAGEPGM(MSG_SD_INSERTED); + if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_INSERTED); } else { card.release(); - LCD_MESSAGEPGM(MSG_SD_REMOVED); + if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_REMOVED); } + + lcd_sd_status = sd_status; } #endif //SDSUPPORT && SD_DETECT_PIN