Browse Source

Expand on More RAM concept, address minor bugs

Scott Lahteine 10 years ago
parent
commit
785143a013
1 changed files with 11 additions and 6 deletions
  1. 11
    6
      Marlin/cardreader.cpp

+ 11
- 6
Marlin/cardreader.cpp View File

11
 
11
 
12
 CardReader::CardReader()
12
 CardReader::CardReader()
13
 {
13
 {
14
-  #if SORT_USES_MORE_RAM
14
+  #if defined(SDCARD_SORT_ALPHA) && SORT_USES_MORE_RAM
15
    sortnames = NULL;
15
    sortnames = NULL;
16
    sort_count = 0;
16
    sort_count = 0;
17
   #endif
17
   #endif
558
 
558
 
559
 void CardReader::getfilename(const uint8_t nr)
559
 void CardReader::getfilename(const uint8_t nr)
560
 {
560
 {
561
+  #if defined(SDCARD_SORT_ALPHA) && SORT_USES_MORE_RAM
562
+    if (nr < sort_count) {
563
+      strcpy(diveFilename, sortnames[nr]);
564
+      return;
565
+    }
566
+  #endif
567
+
561
   curDir=&workDir;
568
   curDir=&workDir;
562
   lsAction=LS_GetFilename;
569
   lsAction=LS_GetFilename;
563
   nrFiles=nr;
570
   nrFiles=nr;
642
  */
649
  */
643
 void CardReader::presort()
650
 void CardReader::presort()
644
 {
651
 {
645
-  #if SORT_USES_MORE_RAM
646
-    flush_presort();
647
-  #endif
652
+  flush_presort();
648
 
653
 
649
   uint16_t fileCnt = getnrfilenames();
654
   uint16_t fileCnt = getnrfilenames();
650
   if (fileCnt > 0) {
655
   if (fileCnt > 0) {
652
     if (fileCnt > SORT_LIMIT) fileCnt = SORT_LIMIT;
657
     if (fileCnt > SORT_LIMIT) fileCnt = SORT_LIMIT;
653
 
658
 
654
     #if SORT_USES_MORE_RAM
659
     #if SORT_USES_MORE_RAM
655
-      sortnames = malloc(fileCnt * sizeof(char*));
660
+      sortnames = (char**)malloc(fileCnt * sizeof(char*));
656
       sort_count = fileCnt;
661
       sort_count = fileCnt;
657
     #elif SORT_USES_RAM
662
     #elif SORT_USES_RAM
658
       char *sortnames[fileCnt];
663
       char *sortnames[fileCnt];
748
   #endif
753
   #endif
749
 }
754
 }
750
 
755
 
751
-#endif
756
+#endif // SDCARD_SORT_ALPHA
752
 
757
 
753
 void CardReader::printingHasFinished()
758
 void CardReader::printingHasFinished()
754
 {
759
 {

Loading…
Cancel
Save