Merge pull request #3152 from thinkyhead/sd_alpha_sort
SD files alphabetical sort in LCD menus
This commit is contained in:
commit
20ef0a6e27
|
@ -298,6 +298,15 @@ script:
|
||||||
- opt_enable G3D_PANEL SDSUPPORT
|
- opt_enable G3D_PANEL SDSUPPORT
|
||||||
- build_marlin
|
- build_marlin
|
||||||
#
|
#
|
||||||
|
# Add SDCARD_SORT_ALPHA, test G3D_PANEL again
|
||||||
|
#
|
||||||
|
- opt_enable_adv SDCARD_SORT_ALPHA
|
||||||
|
- opt_set_adv SDSORT_GCODE true
|
||||||
|
- opt_set_adv SDSORT_USES_RAM true
|
||||||
|
- opt_set_adv SDSORT_USES_STACK true
|
||||||
|
- opt_set_adv SDSORT_CACHE_NAMES true
|
||||||
|
- build_marlin
|
||||||
|
#
|
||||||
# REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
|
# REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
|
||||||
#
|
#
|
||||||
- restore_configs
|
- restore_configs
|
||||||
|
|
|
@ -722,4 +722,8 @@
|
||||||
#define DELTA_ENDSTOP_ADJ { 0 }
|
#define DELTA_ENDSTOP_ADJ { 0 }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define HAS_FOLDER_SORTING (FOLDER_SORTING || ENABLED(SDSORT_GCODE))
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // CONDITIONALS_POST_H
|
#endif // CONDITIONALS_POST_H
|
||||||
|
|
|
@ -442,6 +442,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@
|
||||||
* Use P to run other files as sub-programs: "M32 P !filename#"
|
* Use P to run other files as sub-programs: "M32 P !filename#"
|
||||||
* The '#' is necessary when calling from within sd files, as it stops buffer prereading
|
* The '#' is necessary when calling from within sd files, as it stops buffer prereading
|
||||||
* M33 - Get the longname version of a path. (Requires LONG_FILENAME_HOST_SUPPORT)
|
* M33 - Get the longname version of a path. (Requires LONG_FILENAME_HOST_SUPPORT)
|
||||||
|
* M34 - Set SD Card sorting options. (Requires SDCARD_SORT_ALPHA)
|
||||||
* M42 - Change pin status via gcode: M42 P<pin> S<value>. LED pin assumed if P is omitted.
|
* M42 - Change pin status via gcode: M42 P<pin> S<value>. LED pin assumed if P is omitted.
|
||||||
* M43 - Monitor pins & report changes - report active pins
|
* M43 - Monitor pins & report changes - report active pins
|
||||||
* M48 - Measure Z Probe repeatability: M48 P<points> X<pos> Y<pos> V<level> E<engage> L<legs>. (Requires Z_MIN_PROBE_REPEATABILITY_TEST)
|
* M48 - Measure Z Probe repeatability: M48 P<points> X<pos> Y<pos> V<level> E<engage> L<legs>. (Requires Z_MIN_PROBE_REPEATABILITY_TEST)
|
||||||
|
@ -4843,6 +4844,20 @@ inline void gcode_M31() {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_GCODE)
|
||||||
|
/**
|
||||||
|
* M34: Set SD Card Sorting Options
|
||||||
|
*/
|
||||||
|
inline void gcode_M34() {
|
||||||
|
if (code_seen('S')) card.setSortOn(code_value_bool());
|
||||||
|
if (code_seen('F')) {
|
||||||
|
int v = code_value_long();
|
||||||
|
card.setSortFolders(v < 0 ? -1 : v > 0 ? 1 : 0);
|
||||||
|
}
|
||||||
|
//if (code_seen('R')) card.setSortReverse(code_value_bool());
|
||||||
|
}
|
||||||
|
#endif // SDCARD_SORT_ALPHA && SDSORT_GCODE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* M928: Start SD Write
|
* M928: Start SD Write
|
||||||
*/
|
*/
|
||||||
|
@ -8289,6 +8304,11 @@ void process_next_command() {
|
||||||
gcode_M33(); break;
|
gcode_M33(); break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_GCODE)
|
||||||
|
case 34: //M34 - Set SD card sorting options
|
||||||
|
gcode_M34(); break;
|
||||||
|
#endif // SDCARD_SORT_ALPHA && SDSORT_GCODE
|
||||||
|
|
||||||
case 928: // M928: Start SD write
|
case 928: // M928: Start SD write
|
||||||
gcode_M928(); break;
|
gcode_M928(); break;
|
||||||
#endif //SDSUPPORT
|
#endif //SDSUPPORT
|
||||||
|
|
|
@ -205,6 +205,23 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SD File Sorting
|
||||||
|
*/
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#if SDSORT_LIMIT > 256
|
||||||
|
#error "SDSORT_LIMIT must be 256 or smaller."
|
||||||
|
#elif SDSORT_LIMIT < 10
|
||||||
|
#error "SDSORT_LIMIT should be greater than 9 to be useful."
|
||||||
|
#elif DISABLED(SDSORT_USES_RAM)
|
||||||
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
||||||
|
#error "SDSORT_DYNAMIC_RAM requires SDSORT_USES_RAM (which reads the directory into RAM)."
|
||||||
|
#elif ENABLED(SDSORT_CACHE_NAMES)
|
||||||
|
#error "SDSORT_CACHE_NAMES requires SDSORT_USES_RAM (which reads the directory into RAM)."
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delta requirements
|
* Delta requirements
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,7 +30,17 @@
|
||||||
|
|
||||||
#if ENABLED(SDSUPPORT)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
|
#define LONGEST_FILENAME (longFilename[0] ? longFilename : filename)
|
||||||
|
|
||||||
CardReader::CardReader() {
|
CardReader::CardReader() {
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
sort_count = 0;
|
||||||
|
#if ENABLED(SDSORT_GCODE)
|
||||||
|
sort_alpha = true;
|
||||||
|
sort_folders = FOLDER_SORTING;
|
||||||
|
//sort_reverse = false;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
sdprinting = cardOK = saving = logging = false;
|
sdprinting = cardOK = saving = logging = false;
|
||||||
filesize = 0;
|
filesize = 0;
|
||||||
sdpos = 0;
|
sdpos = 0;
|
||||||
|
@ -243,6 +253,9 @@ void CardReader::initsd() {
|
||||||
}
|
}
|
||||||
workDir = root;
|
workDir = root;
|
||||||
curDir = &root;
|
curDir = &root;
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
presort();
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
if (!workDir.openRoot(&volume)) {
|
if (!workDir.openRoot(&volume)) {
|
||||||
SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
|
SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
|
||||||
|
@ -256,6 +269,9 @@ void CardReader::setroot() {
|
||||||
}*/
|
}*/
|
||||||
workDir = root;
|
workDir = root;
|
||||||
curDir = &workDir;
|
curDir = &workDir;
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
presort();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardReader::release() {
|
void CardReader::release() {
|
||||||
|
@ -272,7 +288,12 @@ void CardReader::openAndPrintFile(const char *name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardReader::startFileprint() {
|
void CardReader::startFileprint() {
|
||||||
if (cardOK) sdprinting = true;
|
if (cardOK) {
|
||||||
|
sdprinting = true;
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
flush_presort();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardReader::stopSDPrint() {
|
void CardReader::stopSDPrint() {
|
||||||
|
@ -463,6 +484,9 @@ void CardReader::removeFile(char* name) {
|
||||||
SERIAL_PROTOCOLPGM("File deleted:");
|
SERIAL_PROTOCOLPGM("File deleted:");
|
||||||
SERIAL_PROTOCOLLN(fname);
|
SERIAL_PROTOCOLLN(fname);
|
||||||
sdpos = 0;
|
sdpos = 0;
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
presort();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SERIAL_PROTOCOLPGM("Deletion failed, File: ");
|
SERIAL_PROTOCOLPGM("Deletion failed, File: ");
|
||||||
|
@ -551,6 +575,20 @@ void CardReader::closefile(bool store_location) {
|
||||||
* Get the name of a file in the current directory by index
|
* Get the name of a file in the current directory by index
|
||||||
*/
|
*/
|
||||||
void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) {
|
void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) {
|
||||||
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
||||||
|
if (match != NULL) {
|
||||||
|
while (nr < sort_count) {
|
||||||
|
if (strcasecmp(match, sortshort[nr]) == 0) break;
|
||||||
|
nr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nr < sort_count) {
|
||||||
|
strcpy(filename, sortshort[nr]);
|
||||||
|
strcpy(longFilename, sortnames[nr]);
|
||||||
|
filenameIsDir = TEST(isDir[nr>>3], nr & 0x07);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif // SDSORT_CACHE_NAMES
|
||||||
curDir = &workDir;
|
curDir = &workDir;
|
||||||
lsAction = LS_GetFilename;
|
lsAction = LS_GetFilename;
|
||||||
nrFiles = nr;
|
nrFiles = nr;
|
||||||
|
@ -583,14 +621,241 @@ void CardReader::chdir(const char * relpath) {
|
||||||
if (workDirDepth < MAX_DIR_DEPTH)
|
if (workDirDepth < MAX_DIR_DEPTH)
|
||||||
workDirParents[workDirDepth++] = *parent;
|
workDirParents[workDirDepth++] = *parent;
|
||||||
workDir = newfile;
|
workDir = newfile;
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
presort();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardReader::updir() {
|
void CardReader::updir() {
|
||||||
if (workDirDepth > 0)
|
if (workDirDepth > 0) {
|
||||||
workDir = workDirParents[--workDirDepth];
|
workDir = workDirParents[--workDirDepth];
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
presort();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of a file in the current directory by sort-index
|
||||||
|
*/
|
||||||
|
void CardReader::getfilename_sorted(const uint16_t nr) {
|
||||||
|
getfilename(
|
||||||
|
#if ENABLED(SDSORT_GCODE)
|
||||||
|
sort_alpha &&
|
||||||
|
#endif
|
||||||
|
(nr < sort_count) ? sort_order[nr] : nr
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read all the files and produce a sort key
|
||||||
|
*
|
||||||
|
* We can do this in 3 ways...
|
||||||
|
* - Minimal RAM: Read two filenames at a time sorting along...
|
||||||
|
* - Some RAM: Buffer the directory just for this sort
|
||||||
|
* - Most RAM: Buffer the directory and return filenames from RAM
|
||||||
|
*/
|
||||||
|
void CardReader::presort() {
|
||||||
|
|
||||||
|
// Sorting may be turned off
|
||||||
|
#if ENABLED(SDSORT_GCODE)
|
||||||
|
if (!sort_alpha) return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Throw away old sort index
|
||||||
|
flush_presort();
|
||||||
|
|
||||||
|
// If there are files, sort up to the limit
|
||||||
|
uint16_t fileCnt = getnrfilenames();
|
||||||
|
if (fileCnt > 0) {
|
||||||
|
|
||||||
|
// Never sort more than the max allowed
|
||||||
|
// If you use folders to organize, 20 may be enough
|
||||||
|
if (fileCnt > SDSORT_LIMIT) fileCnt = SDSORT_LIMIT;
|
||||||
|
|
||||||
|
// Sort order is always needed. May be static or dynamic.
|
||||||
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
||||||
|
sort_order = new uint8_t[fileCnt];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Use RAM to store the entire directory during pre-sort.
|
||||||
|
// SDSORT_LIMIT should be set to prevent over-allocation.
|
||||||
|
#if ENABLED(SDSORT_USES_RAM)
|
||||||
|
|
||||||
|
// If using dynamic ram for names, allocate on the heap.
|
||||||
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
||||||
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
||||||
|
sortshort = new char*[fileCnt];
|
||||||
|
sortnames = new char*[fileCnt];
|
||||||
|
#endif
|
||||||
|
#elif ENABLED(SDSORT_USES_STACK)
|
||||||
|
char sortnames[fileCnt][LONG_FILENAME_LENGTH];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Folder sorting needs 1 bit per entry for flags.
|
||||||
|
#if HAS_FOLDER_SORTING
|
||||||
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
||||||
|
isDir = new uint8_t[(fileCnt + 7) >> 3];
|
||||||
|
#elif ENABLED(SDSORT_USES_STACK)
|
||||||
|
uint8_t isDir[(fileCnt + 7) >> 3];
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else // !SDSORT_USES_RAM
|
||||||
|
|
||||||
|
// By default re-read the names from SD for every compare
|
||||||
|
// retaining only two filenames at a time. This is very
|
||||||
|
// slow but is safest and uses minimal RAM.
|
||||||
|
char name1[LONG_FILENAME_LENGTH + 1];
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (fileCnt > 1) {
|
||||||
|
|
||||||
|
// Init sort order.
|
||||||
|
for (uint16_t i = 0; i < fileCnt; i++) {
|
||||||
|
sort_order[i] = i;
|
||||||
|
// If using RAM then read all filenames now.
|
||||||
|
#if ENABLED(SDSORT_USES_RAM)
|
||||||
|
getfilename(i);
|
||||||
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
||||||
|
// Use dynamic method to copy long filename
|
||||||
|
sortnames[i] = strdup(LONGEST_FILENAME);
|
||||||
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
||||||
|
// When caching also store the short name, since
|
||||||
|
// we're replacing the getfilename() behavior.
|
||||||
|
sortshort[i] = strdup(filename);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
// Copy filenames into the static array
|
||||||
|
strcpy(sortnames[i], LONGEST_FILENAME);
|
||||||
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
||||||
|
strcpy(sortshort[i], filename);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
// char out[30];
|
||||||
|
// sprintf_P(out, PSTR("---- %i %s %s"), i, filenameIsDir ? "D" : " ", sortnames[i]);
|
||||||
|
// SERIAL_ECHOLN(out);
|
||||||
|
#if HAS_FOLDER_SORTING
|
||||||
|
const uint16_t bit = i & 0x07, ind = i >> 3;
|
||||||
|
if (bit == 0) isDir[ind] = 0x00;
|
||||||
|
if (filenameIsDir) isDir[ind] |= _BV(bit);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bubble Sort
|
||||||
|
for (uint16_t i = fileCnt; --i;) {
|
||||||
|
bool didSwap = false;
|
||||||
|
for (uint16_t j = 0; j < i; ++j) {
|
||||||
|
const uint16_t o1 = sort_order[j], o2 = sort_order[j + 1];
|
||||||
|
|
||||||
|
// Compare names from the array or just the two buffered names
|
||||||
|
#if ENABLED(SDSORT_USES_RAM)
|
||||||
|
#define _SORT_CMP_NODIR() (strcasecmp(sortnames[o1], sortnames[o2]) > 0)
|
||||||
|
#else
|
||||||
|
#define _SORT_CMP_NODIR() (strcasecmp(name1, name2) > 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAS_FOLDER_SORTING
|
||||||
|
#if ENABLED(SDSORT_USES_RAM)
|
||||||
|
// Folder sorting needs an index and bit to test for folder-ness.
|
||||||
|
const uint8_t ind1 = o1 >> 3, bit1 = o1 & 0x07,
|
||||||
|
ind2 = o2 >> 3, bit2 = o2 & 0x07;
|
||||||
|
#define _SORT_CMP_DIR(fs) \
|
||||||
|
(((isDir[ind1] & _BV(bit1)) != 0) == ((isDir[ind2] & _BV(bit2)) != 0) \
|
||||||
|
? _SORT_CMP_NODIR() \
|
||||||
|
: (isDir[fs > 0 ? ind1 : ind2] & (fs > 0 ? _BV(bit1) : _BV(bit2))) != 0)
|
||||||
|
#else
|
||||||
|
#define _SORT_CMP_DIR(fs) ((dir1 == filenameIsDir) ? _SORT_CMP_NODIR() : (fs > 0 ? dir1 : !dir1))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// The most economical method reads names as-needed
|
||||||
|
// throughout the loop. Slow if there are many.
|
||||||
|
#if DISABLED(SDSORT_USES_RAM)
|
||||||
|
getfilename(o1);
|
||||||
|
strcpy(name1, LONGEST_FILENAME); // save (or getfilename below will trounce it)
|
||||||
|
#if HAS_FOLDER_SORTING
|
||||||
|
bool dir1 = filenameIsDir;
|
||||||
|
#endif
|
||||||
|
getfilename(o2);
|
||||||
|
char *name2 = LONGEST_FILENAME; // use the string in-place
|
||||||
|
#endif // !SDSORT_USES_RAM
|
||||||
|
|
||||||
|
// Sort the current pair according to settings.
|
||||||
|
if (
|
||||||
|
#if HAS_FOLDER_SORTING
|
||||||
|
#if ENABLED(SDSORT_GCODE)
|
||||||
|
sort_folders ? _SORT_CMP_DIR(sort_folders) : _SORT_CMP_NODIR()
|
||||||
|
#else
|
||||||
|
_SORT_CMP_DIR(FOLDER_SORTING)
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
_SORT_CMP_NODIR()
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
sort_order[j] = o2;
|
||||||
|
sort_order[j + 1] = o1;
|
||||||
|
didSwap = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!didSwap) break;
|
||||||
|
}
|
||||||
|
// Using RAM but not keeping names around
|
||||||
|
#if ENABLED(SDSORT_USES_RAM) && DISABLED(SDSORT_CACHE_NAMES)
|
||||||
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
||||||
|
for (uint16_t i = 0; i < fileCnt; ++i) free(sortnames[i]);
|
||||||
|
#if HAS_FOLDER_SORTING
|
||||||
|
free(isDir);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sort_order[0] = 0;
|
||||||
|
#if ENABLED(SDSORT_USES_RAM) && ENABLED(SDSORT_CACHE_NAMES)
|
||||||
|
getfilename(0);
|
||||||
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
||||||
|
sortnames = new char*[1];
|
||||||
|
sortnames[0] = strdup(LONGEST_FILENAME); // malloc
|
||||||
|
sortshort = new char*[1];
|
||||||
|
sortshort[0] = strdup(filename); // malloc
|
||||||
|
isDir = new uint8_t[1];
|
||||||
|
#else
|
||||||
|
strcpy(sortnames[0], LONGEST_FILENAME);
|
||||||
|
strcpy(sortshort[0], filename);
|
||||||
|
#endif
|
||||||
|
isDir[0] = filenameIsDir ? 0x01 : 0x00;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
sort_count = fileCnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardReader::flush_presort() {
|
||||||
|
if (sort_count > 0) {
|
||||||
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
||||||
|
delete sort_order;
|
||||||
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
||||||
|
for (uint8_t i = 0; i < sort_count; ++i) {
|
||||||
|
free(sortshort[i]); // strdup
|
||||||
|
free(sortnames[i]); // strdup
|
||||||
|
}
|
||||||
|
delete sortshort;
|
||||||
|
delete sortnames;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
sort_count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
void CardReader::printingHasFinished() {
|
void CardReader::printingHasFinished() {
|
||||||
stepper.synchronize();
|
stepper.synchronize();
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -607,6 +872,9 @@ void CardReader::printingHasFinished() {
|
||||||
print_job_timer.stop();
|
print_job_timer.stop();
|
||||||
if (print_job_timer.duration() > 60)
|
if (print_job_timer.duration() > 60)
|
||||||
enqueue_and_echo_commands_P(PSTR("M31"));
|
enqueue_and_echo_commands_P(PSTR("M31"));
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
presort();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,16 @@ public:
|
||||||
void updir();
|
void updir();
|
||||||
void setroot();
|
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 void pauseSDPrint() { sdprinting = false; }
|
||||||
FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
|
FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
|
||||||
FORCE_INLINE bool eof() { return sdpos >= filesize; }
|
FORCE_INLINE bool eof() { return sdpos >= filesize; }
|
||||||
|
@ -84,6 +94,51 @@ public:
|
||||||
private:
|
private:
|
||||||
SdFile root, *curDir, workDir, workDirParents[MAX_DIR_DEPTH];
|
SdFile root, *curDir, workDir, workDirParents[MAX_DIR_DEPTH];
|
||||||
uint8_t workDirDepth;
|
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
|
||||||
|
|
||||||
|
// By default the sort index is static
|
||||||
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
||||||
|
uint8_t *sort_order;
|
||||||
|
#else
|
||||||
|
uint8_t sort_order[SDSORT_LIMIT];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
||||||
|
char **sortshort, **sortnames;
|
||||||
|
#else
|
||||||
|
char sortshort[SDSORT_LIMIT][FILENAME_LENGTH];
|
||||||
|
char sortnames[SDSORT_LIMIT][FILENAME_LENGTH];
|
||||||
|
#endif
|
||||||
|
#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
|
||||||
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
||||||
|
uint8_t *isDir;
|
||||||
|
#elif ENABLED(SDSORT_CACHE_NAMES) || DISABLED(SDSORT_USES_STACK)
|
||||||
|
uint8_t isDir[(SDSORT_LIMIT+7)>>3];
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // SDSORT_USES_RAM
|
||||||
|
|
||||||
|
#endif // SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
Sd2Card card;
|
Sd2Card card;
|
||||||
SdVolume volume;
|
SdVolume volume;
|
||||||
SdFile file;
|
SdFile file;
|
||||||
|
@ -103,6 +158,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.
|
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;
|
char* diveDirName;
|
||||||
void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
|
void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
|
||||||
|
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
void flush_presort();
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CardReader card;
|
extern CardReader card;
|
||||||
|
|
|
@ -442,6 +442,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -442,6 +442,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -442,6 +442,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -442,6 +442,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -455,6 +455,42 @@
|
||||||
// using:
|
// using:
|
||||||
#define MENU_ADDAUTOSTART
|
#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
#define LCD_PROGRESS_BAR
|
#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -442,6 +442,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -442,6 +442,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -442,6 +442,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -450,6 +450,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -442,6 +442,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -444,6 +444,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -444,6 +444,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -449,6 +449,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -444,6 +444,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -442,6 +442,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -442,6 +442,42 @@
|
||||||
// using:
|
// using:
|
||||||
//#define MENU_ADDAUTOSTART
|
//#define MENU_ADDAUTOSTART
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort SD file listings in alphabetical order.
|
||||||
|
*
|
||||||
|
* With this option enabled, items on SD cards will be sorted
|
||||||
|
* by name for easier navigation.
|
||||||
|
*
|
||||||
|
* By default...
|
||||||
|
*
|
||||||
|
* - Use the slowest -but safest- method for sorting.
|
||||||
|
* - Folders are sorted to the top.
|
||||||
|
* - The sort key is statically allocated.
|
||||||
|
* - No added G-code (M34) support.
|
||||||
|
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
|
||||||
|
*
|
||||||
|
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
|
||||||
|
* compiler to calculate the worst-case usage and throw an error if the SRAM
|
||||||
|
* limit is exceeded.
|
||||||
|
*
|
||||||
|
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
|
||||||
|
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
|
||||||
|
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
|
||||||
|
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
|
||||||
|
*/
|
||||||
|
//#define SDCARD_SORT_ALPHA
|
||||||
|
|
||||||
|
// SD Card Sorting options
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256).
|
||||||
|
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
|
||||||
|
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
|
||||||
|
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
|
||||||
|
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
|
||||||
|
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
|
||||||
|
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show a progress bar on HD44780 LCDs for SD printing
|
// Show a progress bar on HD44780 LCDs for SD printing
|
||||||
//#define LCD_PROGRESS_BAR
|
//#define LCD_PROGRESS_BAR
|
||||||
|
|
||||||
|
|
|
@ -2277,12 +2277,17 @@ KeepDrawing:
|
||||||
|
|
||||||
for (uint16_t i = 0; i < fileCnt; i++) {
|
for (uint16_t i = 0; i < fileCnt; i++) {
|
||||||
if (_menuLineNr == _thisItemNr) {
|
if (_menuLineNr == _thisItemNr) {
|
||||||
card.getfilename(
|
#if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA)
|
||||||
#if ENABLED(SDCARD_RATHERRECENTFIRST)
|
int nr = fileCnt - 1 - i;
|
||||||
fileCnt-1 -
|
#else
|
||||||
#endif
|
int nr = i;
|
||||||
i
|
#endif
|
||||||
);
|
|
||||||
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
|
card.getfilename_sorted(nr);
|
||||||
|
#else
|
||||||
|
card.getfilename(nr);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (card.filenameIsDir)
|
if (card.filenameIsDir)
|
||||||
MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename);
|
MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename);
|
||||||
|
|
Loading…
Reference in a new issue