From 47f9883b0f5c1c8c7ff3551113df78bdd0ac7cd0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 9 Feb 2017 07:05:34 -0600 Subject: [PATCH] Dynamic allocation for SDCARD_SORT_ALPHA --- Marlin/Configuration_adv.h | 2 + Marlin/SanityCheck.h | 8 +- Marlin/cardreader.cpp | 77 ++++++++++++++++--- Marlin/cardreader.h | 23 ++++-- .../Cartesio/Configuration_adv.h | 2 + .../Felix/Configuration_adv.h | 2 + .../Hephestos/Configuration_adv.h | 2 + .../Hephestos_2/Configuration_adv.h | 2 + .../K8200/Configuration_adv.h | 2 + .../K8400/Configuration_adv.h | 2 + .../RigidBot/Configuration_adv.h | 2 + .../SCARA/Configuration_adv.h | 2 + .../TAZ4/Configuration_adv.h | 2 + .../WITBOX/Configuration_adv.h | 2 + .../delta/generic/Configuration_adv.h | 2 + .../delta/kossel_mini/Configuration_adv.h | 2 + .../delta/kossel_pro/Configuration_adv.h | 2 + .../delta/kossel_xl/Configuration_adv.h | 2 + .../makibox/Configuration_adv.h | 2 + .../tvrrug/Round2/Configuration_adv.h | 2 + 20 files changed, 124 insertions(+), 18 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 1c0178063..0e12ba18d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -463,6 +463,7 @@ * - 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 @@ -474,6 +475,7 @@ #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 diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 5df2971d9..c37a81315 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -213,8 +213,12 @@ #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) && ENABLED(SDSORT_CACHE_NAMES) - #error "SDSORT_CACHE_NAMES requires SDSORT_USES_RAM (which reads the directory into RAM)." + #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 diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index ddb607d3e..aefc2dee4 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -676,16 +676,30 @@ void CardReader::updir() { // 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 ENABLED(SDSORT_USES_STACK) - #if DISABLED(SDSORT_CACHE_NAMES) - char sortnames[fileCnt][LONG_FILENAME_LENGTH]; + // 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 - // Folder sorting needs 1 bit per entry for flags. - #if HAS_FOLDER_SORTING + #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 @@ -707,9 +721,20 @@ void CardReader::updir() { // If using RAM then read all filenames now. #if ENABLED(SDSORT_USES_RAM) getfilename(i); - strcpy(sortnames[i], LONGEST_FILENAME); - #if ENABLED(SDSORT_CACHE_NAMES) - strcpy(sortshort[i], filename); + #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]); @@ -780,13 +805,30 @@ void CardReader::updir() { } 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); - strcpy(sortnames[0], LONGEST_FILENAME); - strcpy(sortshort[0], filename); + #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 } @@ -796,7 +838,20 @@ void CardReader::updir() { } void CardReader::flush_presort() { - sort_count = 0; + 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 diff --git a/Marlin/cardreader.h b/Marlin/cardreader.h index d9fbbdf9b..05e8ecf07 100644 --- a/Marlin/cardreader.h +++ b/Marlin/cardreader.h @@ -104,22 +104,35 @@ private: //bool sort_reverse; // Flag to enable / disable reverse sorting #endif - uint8_t sort_order[SDSORT_LIMIT]; + // 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) - char sortshort[SDSORT_LIMIT][FILENAME_LENGTH]; - char sortnames[SDSORT_LIMIT][FILENAME_LENGTH]; + #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 && (ENABLED(SDSORT_CACHE_NAMES) || DISABLED(SDSORT_USES_STACK)) - uint8_t isDir[(SDSORT_LIMIT+7)>>3]; + #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 diff --git a/Marlin/example_configurations/Cartesio/Configuration_adv.h b/Marlin/example_configurations/Cartesio/Configuration_adv.h index 3532f33de..687dade67 100644 --- a/Marlin/example_configurations/Cartesio/Configuration_adv.h +++ b/Marlin/example_configurations/Cartesio/Configuration_adv.h @@ -463,6 +463,7 @@ * - 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 @@ -474,6 +475,7 @@ #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 diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index 761f3240d..141879a94 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -463,6 +463,7 @@ * - 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 @@ -474,6 +475,7 @@ #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 diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index b0cee9181..c9cdf560e 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -463,6 +463,7 @@ * - 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 @@ -474,6 +475,7 @@ #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 diff --git a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h index e82d4bc32..ceb0dfe37 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h @@ -463,6 +463,7 @@ * - 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 @@ -474,6 +475,7 @@ #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 diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index 42dcf29fa..1a84914b1 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -476,6 +476,7 @@ * - 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 @@ -487,6 +488,7 @@ #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 diff --git a/Marlin/example_configurations/K8400/Configuration_adv.h b/Marlin/example_configurations/K8400/Configuration_adv.h index 995643749..67f0ee668 100644 --- a/Marlin/example_configurations/K8400/Configuration_adv.h +++ b/Marlin/example_configurations/K8400/Configuration_adv.h @@ -463,6 +463,7 @@ * - 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 @@ -474,6 +475,7 @@ #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 diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h index d478ab1fd..e501cb328 100644 --- a/Marlin/example_configurations/RigidBot/Configuration_adv.h +++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h @@ -463,6 +463,7 @@ * - 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 @@ -474,6 +475,7 @@ #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 diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index b60913196..deefbf142 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -463,6 +463,7 @@ * - 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 @@ -474,6 +475,7 @@ #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 diff --git a/Marlin/example_configurations/TAZ4/Configuration_adv.h b/Marlin/example_configurations/TAZ4/Configuration_adv.h index 189d6f611..816a45401 100644 --- a/Marlin/example_configurations/TAZ4/Configuration_adv.h +++ b/Marlin/example_configurations/TAZ4/Configuration_adv.h @@ -471,6 +471,7 @@ * - 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 @@ -482,6 +483,7 @@ #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 diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index b0cee9181..c9cdf560e 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -463,6 +463,7 @@ * - 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 @@ -474,6 +475,7 @@ #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 diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index 043ac66af..668028969 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -465,6 +465,7 @@ * - 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 @@ -476,6 +477,7 @@ #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 diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 043ac66af..668028969 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -465,6 +465,7 @@ * - 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 @@ -476,6 +477,7 @@ #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 diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h index 4d17a29c8..7553e02fa 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h @@ -470,6 +470,7 @@ * - 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 @@ -481,6 +482,7 @@ #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 diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h index b3715caa4..4ce2bd808 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h @@ -465,6 +465,7 @@ * - 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 @@ -476,6 +477,7 @@ #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 diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 7acca69f9..34cc51e9e 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -463,6 +463,7 @@ * - 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 @@ -474,6 +475,7 @@ #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 diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index 7453d6658..8f9df52d3 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -463,6 +463,7 @@ * - 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 @@ -474,6 +475,7 @@ #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