New feature: SDCARD_SORT_ALPHA
This commit is contained in:
@ -69,6 +69,16 @@ public:
|
||||
void updir();
|
||||
void setroot();
|
||||
|
||||
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||
void presort();
|
||||
void getfilename_sorted(const uint16_t nr);
|
||||
#if ENABLED(SDSORT_GCODE)
|
||||
FORCE_INLINE void setSortOn(bool b) { sort_alpha = b; presort(); }
|
||||
FORCE_INLINE void setSortFolders(int i) { sort_folders = i; presort(); }
|
||||
//FORCE_INLINE void setSortReverse(bool b) { sort_reverse = b; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
FORCE_INLINE void pauseSDPrint() { sdprinting = false; }
|
||||
FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
|
||||
FORCE_INLINE bool eof() { return sdpos >= filesize; }
|
||||
@ -84,6 +94,38 @@ public:
|
||||
private:
|
||||
SdFile root, *curDir, workDir, workDirParents[MAX_DIR_DEPTH];
|
||||
uint8_t workDirDepth;
|
||||
|
||||
// Sort files and folders alphabetically.
|
||||
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||
uint16_t sort_count; // Count of sorted items in the current directory
|
||||
#if ENABLED(SDSORT_GCODE)
|
||||
bool sort_alpha; // Flag to enable / disable the feature
|
||||
int sort_folders; // Flag to enable / disable folder sorting
|
||||
//bool sort_reverse; // Flag to enable / disable reverse sorting
|
||||
#endif
|
||||
|
||||
uint8_t sort_order[SDSORT_LIMIT];
|
||||
|
||||
// Cache filenames to speed up SD menus.
|
||||
#if ENABLED(SDSORT_USES_RAM)
|
||||
|
||||
// If using dynamic ram for names, allocate on the heap.
|
||||
#if ENABLED(SDSORT_CACHE_NAMES)
|
||||
char sortshort[SDSORT_LIMIT][FILENAME_LENGTH];
|
||||
char sortnames[SDSORT_LIMIT][FILENAME_LENGTH];
|
||||
#elif DISABLED(SDSORT_USES_STACK)
|
||||
char sortnames[SDSORT_LIMIT][FILENAME_LENGTH];
|
||||
#endif
|
||||
|
||||
// Folder sorting uses an isDir array when caching items.
|
||||
#if HAS_FOLDER_SORTING && (ENABLED(SDSORT_CACHE_NAMES) || DISABLED(SDSORT_USES_STACK))
|
||||
uint8_t isDir[(SDSORT_LIMIT+7)>>3];
|
||||
#endif
|
||||
|
||||
#endif // SDSORT_USES_RAM
|
||||
|
||||
#endif // SDCARD_SORT_ALPHA
|
||||
|
||||
Sd2Card card;
|
||||
SdVolume volume;
|
||||
SdFile file;
|
||||
@ -103,6 +145,10 @@ private:
|
||||
uint16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
|
||||
char* diveDirName;
|
||||
void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
|
||||
|
||||
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||
void flush_presort();
|
||||
#endif
|
||||
};
|
||||
|
||||
extern CardReader card;
|
||||
|
Reference in New Issue
Block a user