Minor fixes to SD presence handling (#3139)

* Remove forgotten function protorypes

* Fix code indentation

* Fix double sorting if SD card is inserted during setup()

* Correctly handle SD removal during sorting
This commit is contained in:
Alex Voinea 2021-06-20 22:30:47 -07:00 committed by GitHub
parent 0cbc759d8b
commit 30d9faef9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 18 deletions

View File

@ -196,7 +196,7 @@ void CardReader::ls(ls_param params)
} }
void CardReader::initsd() void CardReader::initsd(bool doPresort/* = true*/)
{ {
cardOK = false; cardOK = false;
if(root.isOpen()) if(root.isOpen())
@ -240,6 +240,7 @@ void CardReader::initsd()
workDirDepth = 0; workDirDepth = 0;
#ifdef SDCARD_SORT_ALPHA #ifdef SDCARD_SORT_ALPHA
if (doPresort)
presort(); presort();
#endif #endif

View File

@ -27,7 +27,7 @@ public:
inline ls_param(bool LFN, bool timestamp):LFN(LFN), timestamp(timestamp) { } inline ls_param(bool LFN, bool timestamp):LFN(LFN), timestamp(timestamp) { }
} __attribute__((packed)); } __attribute__((packed));
void initsd(); void initsd(bool doPresort = true);
void write_command(char *buf); void write_command(char *buf);
void write_command_no_newline(char *buf); void write_command_no_newline(char *buf);
//files auto[0-9].g on the sd card are performed in a row //files auto[0-9].g on the sd card are performed in a row

View File

@ -8869,11 +8869,14 @@ void menu_lcd_lcdupdate_func(void)
backlight_wake(); backlight_wake();
if (lcd_oldcardstatus) if (lcd_oldcardstatus)
{ {
card.initsd(); if (!card.cardOK)
{
card.initsd(false); //delay the sorting to the sd menu. Otherwise, removing the SD card while sorting will not menu_back()
card.presort_flag = true; //force sorting of the SD menu
}
LCD_MESSAGERPGM(_T(WELCOME_MSG)); LCD_MESSAGERPGM(_T(WELCOME_MSG));
bMain=false; // flag (i.e. 'fake parameter') for 'lcd_sdcard_menu()' function bMain=false; // flag (i.e. 'fake parameter') for 'lcd_sdcard_menu()' function
menu_submenu(lcd_sdcard_menu); menu_submenu(lcd_sdcard_menu);
//get_description();
} }
else else
{ {

View File

@ -205,12 +205,6 @@ void lcd_printer_connected();
void lcd_ping(); void lcd_ping();
void lcd_calibrate_extruder(); void lcd_calibrate_extruder();
void lcd_farm_sdcard_menu();
//void getFileDescription(char *name, char *description);
void lcd_farm_sdcard_menu_w();
//void get_description();
void lcd_wait_for_heater(); void lcd_wait_for_heater();
void lcd_wait_for_cool_down(); void lcd_wait_for_cool_down();