From 8196b36ad9f7ed5b49a8f69742359e16b47affa9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 24 Nov 2014 14:03:20 -0800 Subject: [PATCH] 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. --- Marlin/cardreader.cpp | 6 +++--- Marlin/cardreader.h | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index cf0b5176a..c02b35403 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -54,7 +54,7 @@ void CardReader::lsDive(const char *prepend,SdFile parent) dir_t p; uint8_t cnt=0; - while (parent.readDir(p, longFilename) > 0) + while (parent.readDir(p, diveFilename) > 0) { if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint { @@ -91,8 +91,8 @@ void CardReader::lsDive(const char *prepend,SdFile parent) { if (p.name[0] == DIR_NAME_FREE) break; if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.'|| p.name[0] == '_') continue; - if (longFilename[0] != '\0' && - (longFilename[0] == '.' || longFilename[0] == '_')) continue; + if (diveFilename[0] != '\0' && + (diveFilename[0] == '.' || diveFilename[0] == '_')) continue; if ( p.name[0] == '.') { if ( p.name[1] != '.') diff --git a/Marlin/cardreader.h b/Marlin/cardreader.h index fd8635a5b..494a315f2 100644 --- a/Marlin/cardreader.h +++ b/Marlin/cardreader.h @@ -46,7 +46,11 @@ public: #ifdef SDCARD_SORT_ALPHA void presort(); void flush_presort(); +<<<<<<< HEAD void getfilename_sorted(const uint16_t nr); +======= + void getfilename_sorted(const uint8_t nr); +>>>>>>> SD Card Alpha Sorting #endif @@ -60,22 +64,37 @@ public: public: bool saving; bool logging; +<<<<<<< HEAD bool sdprinting; bool cardOK; char filename[FILENAME_LENGTH]; char longFilename[LONG_FILENAME_LENGTH]; +======= + bool sdprinting ; + bool cardOK; + char filename[FILENAME_LENGTH]; + char diveFilename[LONG_FILENAME_LENGTH]; +>>>>>>> SD Card Alpha Sorting bool filenameIsDir; int lastnr; //last number of the autostart; private: SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH]; uint16_t workDirDepth; #ifdef SDCARD_SORT_ALPHA +<<<<<<< HEAD uint16_t sort_count; uint8_t *sort_order; #if SORT_USES_MORE_RAM char **sortshort; char **sortnames; uint8_t *isDir; +======= + #if SORT_USES_MORE_RAM + uint16_t sort_count; + char **sortnames; + #else + uint8_t sort_order[SORT_LIMIT]; +>>>>>>> SD Card Alpha Sorting #endif #endif Sd2Card card;