Give lcd_sd_status an UNKNOWN state (PR#180)

This commit is contained in:
Scott Lahteine 2015-09-13 16:43:14 -07:00 committed by Richard Wackerbarth
parent 0f149ea0c6
commit 5d65a36dee

View File

@ -227,7 +227,7 @@ static void lcd_status_screen();
uint8_t lastEncoderBits; uint8_t lastEncoderBits;
uint32_t encoderPosition; uint32_t encoderPosition;
#if PIN_EXISTS(SD_DETECT) #if PIN_EXISTS(SD_DETECT)
bool lcd_sd_status; uint8_t lcd_sd_status;
#endif #endif
#endif // ULTIPANEL #endif // ULTIPANEL
@ -1534,7 +1534,7 @@ void lcd_init() {
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
pinMode(SD_DETECT_PIN, INPUT); pinMode(SD_DETECT_PIN, INPUT);
WRITE(SD_DETECT_PIN, HIGH); WRITE(SD_DETECT_PIN, HIGH);
lcd_sd_status = false; lcd_sd_status = 2; // UNKNOWN
#endif #endif
#if ENABLED(LCD_HAS_SLOW_BUTTONS) #if ENABLED(LCD_HAS_SLOW_BUTTONS)
@ -1595,21 +1595,22 @@ void lcd_update() {
bool sd_status = IS_SD_INSERTED; bool sd_status = IS_SD_INSERTED;
if (sd_status != lcd_sd_status && lcd_detected()) { if (sd_status != lcd_sd_status && lcd_detected()) {
lcdDrawUpdate = 2; lcdDrawUpdate = 2;
lcd_sd_status = sd_status;
lcd_implementation_init( // to maybe revive the LCD if static electricity killed it. lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
#if ENABLED(LCD_PROGRESS_BAR) #if ENABLED(LCD_PROGRESS_BAR)
currentMenu == lcd_status_screen currentMenu == lcd_status_screen
#endif #endif
); );
if (lcd_sd_status) { if (sd_status) {
card.initsd(); card.initsd();
LCD_MESSAGEPGM(MSG_SD_INSERTED); if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_INSERTED);
} }
else { else {
card.release(); 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 #endif //SDSUPPORT && SD_DETECT_PIN