# This is a combination of 4 commits.

# The first commit's message is:
SD Card Alpha Sorting

First iteration of alphabetical sorting for SD cards, both
slow+efficient and fast+rammy. Option for folders to sort first, last,
or not at all.

# This is the 2nd commit message:

Expand on More RAM concept, address minor bugs

# This is the 3rd commit message:

Improvements, more SORT_USES_MORE_RAM

With this option, always keeps the dir in RAM, doubling as a cache for
getfilename. A board with only 8K of SRAM is cutting it very close.

# This is the 4th commit message:

Completed SORT_USES_MORE_RAM implementation

For the MORE_RAM option we need to buffer both the short and long
names, even though long names are sometimes redundant. Worst case, all
the names are max length. We can save some RAM by not storing these. We
could save more RAM by only storing the visible part of the long name.
This commit is contained in:
Scott Lahteine
2014-11-24 14:03:20 -08:00
parent 1977b4490f
commit de725bd408
5 changed files with 237 additions and 52 deletions

View File

@ -993,9 +993,9 @@ void lcd_sdcard_menu()
card.getWorkDirName();
if(card.filename[0]=='/')
{
#if SDCARDDETECT == -1
#if SDCARDDETECT == -1
MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
#endif
#endif
}else{
MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
}
@ -1004,16 +1004,23 @@ void lcd_sdcard_menu()
{
if (_menuItemNr == _lineNr)
{
#ifndef SDCARD_RATHERRECENTFIRST
card.getfilename(i);
#if defined(SDCARD_RATHERRECENTFIRST) && !defined(SDCARD_SORT_ALPHA)
int nr = fileCnt-1-i;
#else
card.getfilename(fileCnt-1-i);
int nr = i;
#endif
if (card.filenameIsDir)
{
MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename);
}else{
MENU_ITEM(sdfile, MSG_CARD_MENU, card.filename, card.longFilename);
#ifdef SDCARD_SORT_ALPHA
card.getfilename_sorted(nr);
#else
card.getfilename(nr);
#endif
if (card.filenameIsDir) {
MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename);
}
else {
MENU_ITEM(sdfile, MSG_CARD_MENU, card.filename, card.longFilename);
}
}else{
MENU_ITEM_DUMMY();
@ -1219,7 +1226,7 @@ void lcd_init()
#endif // SR_LCD_2W_NL
#endif//!NEWPANEL
#if defined (SDSUPPORT) && defined(SDCARDDETECT) && (SDCARDDETECT > 0)
#if defined(SDSUPPORT) && defined(SDCARDDETECT) && (SDCARDDETECT > 0)
pinMode(SDCARDDETECT,INPUT);
WRITE(SDCARDDETECT, HIGH);
lcd_oldcardstatus = IS_SD_INSERTED;