Expand on More RAM concept, address minor bugs

This commit is contained in:
Scott Lahteine 2014-11-24 20:26:27 -08:00
parent 0cbbba08bd
commit 785143a013

View file

@ -11,7 +11,7 @@
CardReader::CardReader() CardReader::CardReader()
{ {
#if SORT_USES_MORE_RAM #if defined(SDCARD_SORT_ALPHA) && SORT_USES_MORE_RAM
sortnames = NULL; sortnames = NULL;
sort_count = 0; sort_count = 0;
#endif #endif
@ -558,6 +558,13 @@ void CardReader::closefile(bool store_location)
void CardReader::getfilename(const uint8_t nr) void CardReader::getfilename(const uint8_t nr)
{ {
#if defined(SDCARD_SORT_ALPHA) && SORT_USES_MORE_RAM
if (nr < sort_count) {
strcpy(diveFilename, sortnames[nr]);
return;
}
#endif
curDir=&workDir; curDir=&workDir;
lsAction=LS_GetFilename; lsAction=LS_GetFilename;
nrFiles=nr; nrFiles=nr;
@ -642,9 +649,7 @@ void CardReader::getfilename_sorted(const uint8_t nr) {
*/ */
void CardReader::presort() void CardReader::presort()
{ {
#if SORT_USES_MORE_RAM flush_presort();
flush_presort();
#endif
uint16_t fileCnt = getnrfilenames(); uint16_t fileCnt = getnrfilenames();
if (fileCnt > 0) { if (fileCnt > 0) {
@ -652,7 +657,7 @@ void CardReader::presort()
if (fileCnt > SORT_LIMIT) fileCnt = SORT_LIMIT; if (fileCnt > SORT_LIMIT) fileCnt = SORT_LIMIT;
#if SORT_USES_MORE_RAM #if SORT_USES_MORE_RAM
sortnames = malloc(fileCnt * sizeof(char*)); sortnames = (char**)malloc(fileCnt * sizeof(char*));
sort_count = fileCnt; sort_count = fileCnt;
#elif SORT_USES_RAM #elif SORT_USES_RAM
char *sortnames[fileCnt]; char *sortnames[fileCnt];
@ -748,7 +753,7 @@ void CardReader::flush_presort() {
#endif #endif
} }
#endif #endif // SDCARD_SORT_ALPHA
void CardReader::printingHasFinished() void CardReader::printingHasFinished()
{ {