When over the SD limit, continue from the last sorted file
This gives a significant speed boost when just above the sorting limit, while only costing 2 bytes of ram
This commit is contained in:
parent
a96e60c241
commit
ae1815dc52
2 changed files with 14 additions and 2 deletions
Firmware
|
@ -779,7 +779,15 @@ void CardReader::getfilename_sorted(const uint16_t nr, uint8_t sdSort) {
|
||||||
if (nr < sort_count)
|
if (nr < sort_count)
|
||||||
getfilename_simple(sort_entries[(sdSort == SD_SORT_ALPHA) ? (sort_count - nr - 1) : nr]);
|
getfilename_simple(sort_entries[(sdSort == SD_SORT_ALPHA) ? (sort_count - nr - 1) : nr]);
|
||||||
else
|
else
|
||||||
getfilename(nr);
|
getfilename_afterMaxSorting(nr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardReader::getfilename_afterMaxSorting(uint16_t entry, const char * const match/*=NULL*/)
|
||||||
|
{
|
||||||
|
curDir = &workDir;
|
||||||
|
nrFiles = entry - sort_count + 1;
|
||||||
|
curDir->seekSet(lastSortedFilePosition << 5);
|
||||||
|
lsDive("", *curDir, match, LS_GetFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -830,6 +838,7 @@ void CardReader::presort() {
|
||||||
LongTimer sortingSpeedtestTimer;
|
LongTimer sortingSpeedtestTimer;
|
||||||
sortingSpeedtestTimer.start();
|
sortingSpeedtestTimer.start();
|
||||||
#endif //SORTING_SPEEDTEST
|
#endif //SORTING_SPEEDTEST
|
||||||
|
lastSortedFilePosition = position >> 5;
|
||||||
|
|
||||||
// By default re-read the names from SD for every compare
|
// By default re-read the names from SD for every compare
|
||||||
// retaining only two filenames at a time. This is very
|
// retaining only two filenames at a time. This is very
|
||||||
|
@ -989,6 +998,7 @@ void CardReader::presort() {
|
||||||
|
|
||||||
void CardReader::flush_presort() {
|
void CardReader::flush_presort() {
|
||||||
sort_count = 0;
|
sort_count = 0;
|
||||||
|
lastSortedFilePosition = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SDCARD_SORT_ALPHA
|
#endif // SDCARD_SORT_ALPHA
|
||||||
|
|
|
@ -64,6 +64,7 @@ public:
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
void presort();
|
void presort();
|
||||||
void getfilename_sorted(const uint16_t nr, uint8_t sdSort);
|
void getfilename_sorted(const uint16_t nr, uint8_t sdSort);
|
||||||
|
void getfilename_afterMaxSorting(uint16_t entry, const char * const match = NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
|
FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
|
||||||
|
@ -98,8 +99,8 @@ public:
|
||||||
int lastnr; //last number of the autostart;
|
int lastnr; //last number of the autostart;
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
bool presort_flag;
|
bool presort_flag;
|
||||||
char dir_names[MAX_DIR_DEPTH][9];
|
|
||||||
#endif // SDCARD_SORT_ALPHA
|
#endif // SDCARD_SORT_ALPHA
|
||||||
|
char dir_names[MAX_DIR_DEPTH][9];
|
||||||
private:
|
private:
|
||||||
SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
|
SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
|
||||||
uint16_t workDirDepth;
|
uint16_t workDirDepth;
|
||||||
|
@ -108,6 +109,7 @@ private:
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
uint16_t sort_count; // Count of sorted items in the current directory
|
uint16_t sort_count; // Count of sorted items in the current directory
|
||||||
uint16_t sort_entries[SDSORT_LIMIT];
|
uint16_t sort_entries[SDSORT_LIMIT];
|
||||||
|
uint16_t lastSortedFilePosition;
|
||||||
|
|
||||||
#endif // SDCARD_SORT_ALPHA
|
#endif // SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue