Browse Source

Dynamic allocation for SDCARD_SORT_ALPHA

Scott Lahteine 7 years ago
parent
commit
47f9883b0f

+ 2
- 0
Marlin/Configuration_adv.h View File

@@ -463,6 +463,7 @@
463 463
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
464 464
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
465 465
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
466
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
466 467
    */
467 468
   //#define SDCARD_SORT_ALPHA
468 469
 
@@ -474,6 +475,7 @@
474 475
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
475 476
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
476 477
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
478
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
477 479
   #endif
478 480
 
479 481
   // Show a progress bar on HD44780 LCDs for SD printing

+ 6
- 2
Marlin/SanityCheck.h View File

@@ -213,8 +213,12 @@
213 213
     #error "SDSORT_LIMIT must be 256 or smaller."
214 214
   #elif SDSORT_LIMIT < 10
215 215
     #error "SDSORT_LIMIT should be greater than 9 to be useful."
216
-  #elif DISABLED(SDSORT_USES_RAM) && ENABLED(SDSORT_CACHE_NAMES)
217
-    #error "SDSORT_CACHE_NAMES requires SDSORT_USES_RAM (which reads the directory into RAM)."
216
+  #elif DISABLED(SDSORT_USES_RAM)
217
+    #if ENABLED(SDSORT_DYNAMIC_RAM)
218
+      #error "SDSORT_DYNAMIC_RAM requires SDSORT_USES_RAM (which reads the directory into RAM)."
219
+    #elif ENABLED(SDSORT_CACHE_NAMES)
220
+      #error "SDSORT_CACHE_NAMES requires SDSORT_USES_RAM (which reads the directory into RAM)."
221
+    #endif
218 222
   #endif
219 223
 #endif
220 224
 

+ 66
- 11
Marlin/cardreader.cpp View File

@@ -676,16 +676,30 @@ void CardReader::updir() {
676 676
       // If you use folders to organize, 20 may be enough
677 677
       if (fileCnt > SDSORT_LIMIT) fileCnt = SDSORT_LIMIT;
678 678
 
679
+      // Sort order is always needed. May be static or dynamic.
680
+      #if ENABLED(SDSORT_DYNAMIC_RAM)
681
+        sort_order = new uint8_t[fileCnt];
682
+      #endif
683
+
679 684
       // Use RAM to store the entire directory during pre-sort.
680 685
       // SDSORT_LIMIT should be set to prevent over-allocation.
681 686
       #if ENABLED(SDSORT_USES_RAM)
682 687
 
683
-        #if ENABLED(SDSORT_USES_STACK)
684
-          #if DISABLED(SDSORT_CACHE_NAMES)
685
-            char sortnames[fileCnt][LONG_FILENAME_LENGTH];
688
+        // If using dynamic ram for names, allocate on the heap.
689
+        #if ENABLED(SDSORT_CACHE_NAMES)
690
+          #if ENABLED(SDSORT_DYNAMIC_RAM)
691
+            sortshort = new char*[fileCnt];
692
+            sortnames = new char*[fileCnt];
686 693
           #endif
687
-          // Folder sorting needs 1 bit per entry for flags.
688
-          #if HAS_FOLDER_SORTING
694
+        #elif ENABLED(SDSORT_USES_STACK)
695
+          char sortnames[fileCnt][LONG_FILENAME_LENGTH];
696
+        #endif
697
+
698
+        // Folder sorting needs 1 bit per entry for flags.
699
+        #if HAS_FOLDER_SORTING
700
+          #if ENABLED(SDSORT_DYNAMIC_RAM)
701
+            isDir = new uint8_t[(fileCnt + 7) >> 3];
702
+          #elif ENABLED(SDSORT_USES_STACK)
689 703
             uint8_t isDir[(fileCnt + 7) >> 3];
690 704
           #endif
691 705
         #endif
@@ -707,9 +721,20 @@ void CardReader::updir() {
707 721
           // If using RAM then read all filenames now.
708 722
           #if ENABLED(SDSORT_USES_RAM)
709 723
             getfilename(i);
710
-            strcpy(sortnames[i], LONGEST_FILENAME);
711
-            #if ENABLED(SDSORT_CACHE_NAMES)
712
-              strcpy(sortshort[i], filename);
724
+            #if ENABLED(SDSORT_DYNAMIC_RAM)
725
+              // Use dynamic method to copy long filename
726
+              sortnames[i] = strdup(LONGEST_FILENAME);
727
+              #if ENABLED(SDSORT_CACHE_NAMES)
728
+                // When caching also store the short name, since
729
+                // we're replacing the getfilename() behavior.
730
+                sortshort[i] = strdup(filename);
731
+              #endif
732
+            #else
733
+              // Copy filenames into the static array
734
+              strcpy(sortnames[i], LONGEST_FILENAME);
735
+              #if ENABLED(SDSORT_CACHE_NAMES)
736
+                strcpy(sortshort[i], filename);
737
+              #endif
713 738
             #endif
714 739
             // char out[30];
715 740
             // sprintf_P(out, PSTR("---- %i %s %s"), i, filenameIsDir ? "D" : " ", sortnames[i]);
@@ -780,13 +805,30 @@ void CardReader::updir() {
780 805
           }
781 806
           if (!didSwap) break;
782 807
         }
808
+        // Using RAM but not keeping names around
809
+        #if ENABLED(SDSORT_USES_RAM) && DISABLED(SDSORT_CACHE_NAMES)
810
+          #if ENABLED(SDSORT_DYNAMIC_RAM)
811
+            for (uint16_t i = 0; i < fileCnt; ++i) free(sortnames[i]);
812
+            #if HAS_FOLDER_SORTING
813
+              free(isDir);
814
+            #endif
815
+          #endif
816
+        #endif
783 817
       }
784 818
       else {
785 819
         sort_order[0] = 0;
786 820
         #if ENABLED(SDSORT_USES_RAM) && ENABLED(SDSORT_CACHE_NAMES)
787 821
           getfilename(0);
788
-          strcpy(sortnames[0], LONGEST_FILENAME);
789
-          strcpy(sortshort[0], filename);
822
+          #if ENABLED(SDSORT_DYNAMIC_RAM)
823
+            sortnames = new char*[1];
824
+            sortnames[0] = strdup(LONGEST_FILENAME); // malloc
825
+            sortshort = new char*[1];
826
+            sortshort[0] = strdup(filename);         // malloc
827
+            isDir = new uint8_t[1];
828
+          #else
829
+            strcpy(sortnames[0], LONGEST_FILENAME);
830
+            strcpy(sortshort[0], filename);
831
+          #endif
790 832
           isDir[0] = filenameIsDir ? 0x01 : 0x00;
791 833
         #endif
792 834
       }
@@ -796,7 +838,20 @@ void CardReader::updir() {
796 838
   }
797 839
 
798 840
   void CardReader::flush_presort() {
799
-    sort_count = 0;
841
+    if (sort_count > 0) {
842
+      #if ENABLED(SDSORT_DYNAMIC_RAM)
843
+        delete sort_order;
844
+        #if ENABLED(SDSORT_CACHE_NAMES)
845
+          for (uint8_t i = 0; i < sort_count; ++i) {
846
+            free(sortshort[i]); // strdup
847
+            free(sortnames[i]); // strdup
848
+          }
849
+          delete sortshort;
850
+          delete sortnames;
851
+        #endif
852
+      #endif
853
+      sort_count = 0;
854
+    }
800 855
   }
801 856
 
802 857
 #endif // SDCARD_SORT_ALPHA

+ 18
- 5
Marlin/cardreader.h View File

@@ -104,22 +104,35 @@ private:
104 104
       //bool sort_reverse;      // Flag to enable / disable reverse sorting
105 105
     #endif
106 106
 
107
-    uint8_t sort_order[SDSORT_LIMIT];
107
+    // By default the sort index is static
108
+    #if ENABLED(SDSORT_DYNAMIC_RAM)
109
+      uint8_t *sort_order;
110
+    #else
111
+      uint8_t sort_order[SDSORT_LIMIT];
112
+    #endif
108 113
 
109 114
     // Cache filenames to speed up SD menus.
110 115
     #if ENABLED(SDSORT_USES_RAM)
111 116
 
112 117
       // If using dynamic ram for names, allocate on the heap.
113 118
       #if ENABLED(SDSORT_CACHE_NAMES)
114
-        char sortshort[SDSORT_LIMIT][FILENAME_LENGTH];
115
-        char sortnames[SDSORT_LIMIT][FILENAME_LENGTH];
119
+        #if ENABLED(SDSORT_DYNAMIC_RAM)
120
+          char **sortshort, **sortnames;
121
+        #else
122
+          char sortshort[SDSORT_LIMIT][FILENAME_LENGTH];
123
+          char sortnames[SDSORT_LIMIT][FILENAME_LENGTH];
124
+        #endif
116 125
       #elif DISABLED(SDSORT_USES_STACK)
117 126
         char sortnames[SDSORT_LIMIT][FILENAME_LENGTH];
118 127
       #endif
119 128
 
120 129
       // Folder sorting uses an isDir array when caching items.
121
-      #if HAS_FOLDER_SORTING && (ENABLED(SDSORT_CACHE_NAMES) || DISABLED(SDSORT_USES_STACK))
122
-        uint8_t isDir[(SDSORT_LIMIT+7)>>3];
130
+      #if HAS_FOLDER_SORTING
131
+        #if ENABLED(SDSORT_DYNAMIC_RAM)
132
+          uint8_t *isDir;
133
+        #elif ENABLED(SDSORT_CACHE_NAMES) || DISABLED(SDSORT_USES_STACK)
134
+          uint8_t isDir[(SDSORT_LIMIT+7)>>3];
135
+        #endif
123 136
       #endif
124 137
 
125 138
     #endif // SDSORT_USES_RAM

+ 2
- 0
Marlin/example_configurations/Cartesio/Configuration_adv.h View File

@@ -463,6 +463,7 @@
463 463
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
464 464
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
465 465
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
466
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
466 467
    */
467 468
   //#define SDCARD_SORT_ALPHA
468 469
 
@@ -474,6 +475,7 @@
474 475
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
475 476
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
476 477
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
478
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
477 479
   #endif
478 480
 
479 481
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/Felix/Configuration_adv.h View File

@@ -463,6 +463,7 @@
463 463
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
464 464
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
465 465
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
466
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
466 467
    */
467 468
   //#define SDCARD_SORT_ALPHA
468 469
 
@@ -474,6 +475,7 @@
474 475
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
475 476
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
476 477
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
478
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
477 479
   #endif
478 480
 
479 481
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

@@ -463,6 +463,7 @@
463 463
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
464 464
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
465 465
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
466
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
466 467
    */
467 468
   //#define SDCARD_SORT_ALPHA
468 469
 
@@ -474,6 +475,7 @@
474 475
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
475 476
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
476 477
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
478
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
477 479
   #endif
478 480
 
479 481
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/Hephestos_2/Configuration_adv.h View File

@@ -463,6 +463,7 @@
463 463
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
464 464
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
465 465
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
466
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
466 467
    */
467 468
   //#define SDCARD_SORT_ALPHA
468 469
 
@@ -474,6 +475,7 @@
474 475
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
475 476
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
476 477
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
478
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
477 479
   #endif
478 480
 
479 481
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/K8200/Configuration_adv.h View File

@@ -476,6 +476,7 @@
476 476
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
477 477
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
478 478
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
479
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
479 480
    */
480 481
   //#define SDCARD_SORT_ALPHA
481 482
 
@@ -487,6 +488,7 @@
487 488
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
488 489
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
489 490
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
491
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
490 492
   #endif
491 493
 
492 494
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/K8400/Configuration_adv.h View File

@@ -463,6 +463,7 @@
463 463
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
464 464
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
465 465
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
466
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
466 467
    */
467 468
   //#define SDCARD_SORT_ALPHA
468 469
 
@@ -474,6 +475,7 @@
474 475
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
475 476
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
476 477
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
478
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
477 479
   #endif
478 480
 
479 481
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/RigidBot/Configuration_adv.h View File

@@ -463,6 +463,7 @@
463 463
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
464 464
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
465 465
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
466
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
466 467
    */
467 468
   //#define SDCARD_SORT_ALPHA
468 469
 
@@ -474,6 +475,7 @@
474 475
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
475 476
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
476 477
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
478
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
477 479
   #endif
478 480
 
479 481
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/SCARA/Configuration_adv.h View File

@@ -463,6 +463,7 @@
463 463
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
464 464
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
465 465
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
466
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
466 467
    */
467 468
   //#define SDCARD_SORT_ALPHA
468 469
 
@@ -474,6 +475,7 @@
474 475
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
475 476
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
476 477
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
478
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
477 479
   #endif
478 480
 
479 481
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/TAZ4/Configuration_adv.h View File

@@ -471,6 +471,7 @@
471 471
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
472 472
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
473 473
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
474
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
474 475
    */
475 476
   //#define SDCARD_SORT_ALPHA
476 477
 
@@ -482,6 +483,7 @@
482 483
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
483 484
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
484 485
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
486
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
485 487
   #endif
486 488
 
487 489
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

@@ -463,6 +463,7 @@
463 463
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
464 464
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
465 465
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
466
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
466 467
    */
467 468
   //#define SDCARD_SORT_ALPHA
468 469
 
@@ -474,6 +475,7 @@
474 475
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
475 476
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
476 477
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
478
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
477 479
   #endif
478 480
 
479 481
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

@@ -465,6 +465,7 @@
465 465
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
466 466
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
467 467
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
468
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
468 469
    */
469 470
   //#define SDCARD_SORT_ALPHA
470 471
 
@@ -476,6 +477,7 @@
476 477
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
477 478
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
478 479
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
480
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
479 481
   #endif
480 482
 
481 483
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

@@ -465,6 +465,7 @@
465 465
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
466 466
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
467 467
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
468
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
468 469
    */
469 470
   //#define SDCARD_SORT_ALPHA
470 471
 
@@ -476,6 +477,7 @@
476 477
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
477 478
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
478 479
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
480
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
479 481
   #endif
480 482
 
481 483
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h View File

@@ -470,6 +470,7 @@
470 470
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
471 471
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
472 472
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
473
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
473 474
    */
474 475
   //#define SDCARD_SORT_ALPHA
475 476
 
@@ -481,6 +482,7 @@
481 482
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
482 483
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
483 484
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
485
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
484 486
   #endif
485 487
 
486 488
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h View File

@@ -465,6 +465,7 @@
465 465
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
466 466
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
467 467
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
468
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
468 469
    */
469 470
   //#define SDCARD_SORT_ALPHA
470 471
 
@@ -476,6 +477,7 @@
476 477
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
477 478
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
478 479
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
480
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
479 481
   #endif
480 482
 
481 483
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/makibox/Configuration_adv.h View File

@@ -463,6 +463,7 @@
463 463
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
464 464
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
465 465
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
466
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
466 467
    */
467 468
   //#define SDCARD_SORT_ALPHA
468 469
 
@@ -474,6 +475,7 @@
474 475
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
475 476
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
476 477
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
478
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
477 479
   #endif
478 480
 
479 481
   // Show a progress bar on HD44780 LCDs for SD printing

+ 2
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

@@ -463,6 +463,7 @@
463 463
    *  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
464 464
    *  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
465 465
    *  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
466
+   *  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
466 467
    */
467 468
   //#define SDCARD_SORT_ALPHA
468 469
 
@@ -474,6 +475,7 @@
474 475
     #define SDSORT_USES_RAM    false  // Pre-allocate a static array for faster pre-sorting.
475 476
     #define SDSORT_USES_STACK  false  // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
476 477
     #define SDSORT_CACHE_NAMES false  // Keep sorted items in RAM longer for speedy performance. Most expensive option.
478
+    #define SDSORT_DYNAMIC_RAM false  // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
477 479
   #endif
478 480
 
479 481
   // Show a progress bar on HD44780 LCDs for SD printing

Loading…
Cancel
Save