Browse Source

Merge branch 'revert-1154-sd_sorting' into Marlin_v1

daid 10 years ago
parent
commit
a5c059dcf5

+ 0
- 1
Marlin/Configuration_adv.h View File

292
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
292
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
293
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
293
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
294
 
294
 
295
-//#define SDCARD_SORT_ALPHA // Sort SD file listings in ASCII order. Find additional options in cardreader.h
296
 #define SDCARD_RATHERRECENTFIRST  //reverse file order of sd card menu display. Its sorted practically after the file system block order.
295
 #define SDCARD_RATHERRECENTFIRST  //reverse file order of sd card menu display. Its sorted practically after the file system block order.
297
 // if a file is deleted, it frees a block. hence, the order is not purely chronological. To still have auto0.g accessible, there is again the option to do that.
296
 // if a file is deleted, it frees a block. hence, the order is not purely chronological. To still have auto0.g accessible, there is again the option to do that.
298
 // using:
297
 // using:

+ 1
- 3
Marlin/SdFatConfig.h View File

111
 /**
111
 /**
112
  * Defines for long (vfat) filenames
112
  * Defines for long (vfat) filenames
113
  */
113
  */
114
-/** Number of UTF-16 characters per entry */
115
-#define FILENAME_LENGTH 13
116
 /** Number of VFAT entries used. Every entry has 13 UTF-16 characters */
114
 /** Number of VFAT entries used. Every entry has 13 UTF-16 characters */
117
 #define MAX_VFAT_ENTRIES (2)
115
 #define MAX_VFAT_ENTRIES (2)
118
 /** Number of UTF-16 characters per entry */
116
 /** Number of UTF-16 characters per entry */
119
 #define FILENAME_LENGTH 13
117
 #define FILENAME_LENGTH 13
120
 /** Total size of the buffer used to store the long filenames */
118
 /** Total size of the buffer used to store the long filenames */
121
-#define LONG_FILENAME_LENGTH (FILENAME_LENGTH*MAX_VFAT_ENTRIES+1)
119
+#define LONG_FILENAME_LENGTH (13*MAX_VFAT_ENTRIES+1)
122
 #endif  // SdFatConfig_h
120
 #endif  // SdFatConfig_h
123
 
121
 
124
 
122
 

+ 28
- 185
Marlin/cardreader.cpp View File

11
 
11
 
12
 CardReader::CardReader()
12
 CardReader::CardReader()
13
 {
13
 {
14
-  #ifdef SDCARD_SORT_ALPHA
15
-   sort_count = 0;
16
-  #endif
17
    filesize = 0;
14
    filesize = 0;
18
    sdpos = 0;
15
    sdpos = 0;
19
    sdprinting = false;
16
    sdprinting = false;
36
   autostart_atmillis=millis()+5000;
33
   autostart_atmillis=millis()+5000;
37
 }
34
 }
38
 
35
 
39
-char *createFilename(char *buffer, const dir_t &p) //buffer>12characters
36
+char *createFilename(char *buffer,const dir_t &p) //buffer>12characters
40
 {
37
 {
41
   char *pos=buffer;
38
   char *pos=buffer;
42
-  for (uint8_t i = 0; i < 11; i++) {
43
-    if (p.name[i] == ' ') continue;
44
-    if (i == 8) *pos++ = '.';
45
-    *pos++ = p.name[i];
39
+  for (uint8_t i = 0; i < 11; i++) 
40
+  {
41
+    if (p.name[i] == ' ')continue;
42
+    if (i == 8) 
43
+    {
44
+      *pos++='.';
45
+    }
46
+    *pos++=p.name[i];
46
   }
47
   }
47
-  *pos++ = 0;
48
+  *pos++=0;
48
   return buffer;
49
   return buffer;
49
 }
50
 }
50
 
51
 
52
 void CardReader::lsDive(const char *prepend, SdFile parent, const char * const match/*=NULL*/)
53
 void CardReader::lsDive(const char *prepend, SdFile parent, const char * const match/*=NULL*/)
53
 {
54
 {
54
   dir_t p;
55
   dir_t p;
55
-  uint8_t cnt=0;
56
+ uint8_t cnt=0;
56
  
57
  
57
   while (parent.readDir(p, longFilename) > 0)
58
   while (parent.readDir(p, longFilename) > 0)
58
   {
59
   {
59
     if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint
60
     if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint
60
     {
61
     {
61
 
62
 
62
-      char path[FILENAME_LENGTH*2];
63
-      char lfilename[FILENAME_LENGTH];
63
+      char path[13*2];
64
+      char lfilename[13];
64
       createFilename(lfilename,p);
65
       createFilename(lfilename,p);
65
       
66
       
66
       path[0]=0;
67
       path[0]=0;
86
       }
87
       }
87
       lsDive(path,dir);
88
       lsDive(path,dir);
88
       //close done automatically by destructor of SdFile
89
       //close done automatically by destructor of SdFile
90
+
91
+      
89
     }
92
     }
90
     else
93
     else
91
     {
94
     {
97
 
100
 
98
       if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
101
       if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
99
       filenameIsDir=DIR_IS_SUBDIR(&p);
102
       filenameIsDir=DIR_IS_SUBDIR(&p);
100
-
103
+      
104
+      
101
       if(!filenameIsDir)
105
       if(!filenameIsDir)
102
       {
106
       {
103
         if(p.name[8]!='G') continue;
107
         if(p.name[8]!='G') continue;
121
         }
125
         }
122
         else if (cnt == nrFiles) return;
126
         else if (cnt == nrFiles) return;
123
         cnt++;
127
         cnt++;
128
+        
124
       }
129
       }
125
     }
130
     }
126
   }
131
   }
129
 void CardReader::ls() 
134
 void CardReader::ls() 
130
 {
135
 {
131
   lsAction=LS_SerialPrint;
136
   lsAction=LS_SerialPrint;
137
+  if(lsAction==LS_Count)
138
+  nrFiles=0;
139
+
132
   root.rewind();
140
   root.rewind();
133
   lsDive("",root);
141
   lsDive("",root);
134
 }
142
 }
175
   }
183
   }
176
   workDir=root;
184
   workDir=root;
177
   curDir=&root;
185
   curDir=&root;
178
-  #ifdef SDCARD_SORT_ALPHA
179
-    presort();
180
-  #endif
181
   /*
186
   /*
182
   if(!workDir.openRoot(&volume))
187
   if(!workDir.openRoot(&volume))
183
   {
188
   {
194
     SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
199
     SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
195
   }*/
200
   }*/
196
   workDir=root;
201
   workDir=root;
202
+  
197
   curDir=&workDir;
203
   curDir=&workDir;
198
-  #ifdef SDCARD_SORT_ALPHA
199
-    presort();
200
-  #endif
201
 }
204
 }
202
 void CardReader::release()
205
 void CardReader::release()
203
 {
206
 {
210
   if(cardOK)
213
   if(cardOK)
211
   {
214
   {
212
     sdprinting = true;
215
     sdprinting = true;
213
-    #ifdef SDCARD_SORT_ALPHA
214
-      flush_presort();
215
-    #endif
216
   }
216
   }
217
 }
217
 }
218
 
218
 
241
     while(*t!=0 && cnt< MAXPATHNAMELENGTH) 
241
     while(*t!=0 && cnt< MAXPATHNAMELENGTH) 
242
     {t++;cnt++;}  //crawl counter forward.
242
     {t++;cnt++;}  //crawl counter forward.
243
   }
243
   }
244
-  if(cnt<MAXPATHNAMELENGTH-FILENAME_LENGTH)
244
+  if(cnt<MAXPATHNAMELENGTH-13)
245
     file.getFilename(t);
245
     file.getFilename(t);
246
   else
246
   else
247
     t[0]=0;
247
     t[0]=0;
311
       //SERIAL_ECHO("end  :");SERIAL_ECHOLN((int)(dirname_end-name));
311
       //SERIAL_ECHO("end  :");SERIAL_ECHOLN((int)(dirname_end-name));
312
       if(dirname_end>0 && dirname_end>dirname_start)
312
       if(dirname_end>0 && dirname_end>dirname_start)
313
       {
313
       {
314
-        char subdirname[FILENAME_LENGTH];
314
+        char subdirname[13];
315
         strncpy(subdirname, dirname_start, dirname_end-dirname_start);
315
         strncpy(subdirname, dirname_start, dirname_end-dirname_start);
316
         subdirname[dirname_end-dirname_start]=0;
316
         subdirname[dirname_end-dirname_start]=0;
317
         SERIAL_ECHOLN(subdirname);
317
         SERIAL_ECHOLN(subdirname);
408
       //SERIAL_ECHO("end  :");SERIAL_ECHOLN((int)(dirname_end-name));
408
       //SERIAL_ECHO("end  :");SERIAL_ECHOLN((int)(dirname_end-name));
409
       if(dirname_end>0 && dirname_end>dirname_start)
409
       if(dirname_end>0 && dirname_end>dirname_start)
410
       {
410
       {
411
-        char subdirname[FILENAME_LENGTH];
411
+        char subdirname[13];
412
         strncpy(subdirname, dirname_start, dirname_end-dirname_start);
412
         strncpy(subdirname, dirname_start, dirname_end-dirname_start);
413
         subdirname[dirname_end-dirname_start]=0;
413
         subdirname[dirname_end-dirname_start]=0;
414
         SERIAL_ECHOLN(subdirname);
414
         SERIAL_ECHOLN(subdirname);
446
       SERIAL_PROTOCOLPGM("File deleted:");
446
       SERIAL_PROTOCOLPGM("File deleted:");
447
       SERIAL_PROTOCOLLN(fname);
447
       SERIAL_PROTOCOLLN(fname);
448
       sdpos = 0;
448
       sdpos = 0;
449
-      #ifdef SDCARD_SORT_ALPHA
450
-        presort();
451
-      #endif
452
     }
449
     }
453
     else
450
     else
454
     {
451
     {
564
 
561
 
565
 void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/)
562
 void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/)
566
 {
563
 {
567
-  #if defined(SDCARD_SORT_ALPHA) && SORT_USES_RAM && SORT_USES_MORE_RAM
568
-    if (nr < sort_count) {
569
-      strcpy(filename, sortshort[nr]);
570
-      strcpy(longFilename, sortnames[nr]);
571
-      filenameIsDir = isDir[nr];
572
-      return;
573
-    }
574
-  #endif
575
   curDir=&workDir;
564
   curDir=&workDir;
576
   lsAction=LS_GetFilename;
565
   lsAction=LS_GetFilename;
577
   nrFiles=nr;
566
   nrFiles=nr;
595
 {
584
 {
596
   SdFile newfile;
585
   SdFile newfile;
597
   SdFile *parent=&root;
586
   SdFile *parent=&root;
598
-
587
+  
599
   if(workDir.isOpen())
588
   if(workDir.isOpen())
600
     parent=&workDir;
589
     parent=&workDir;
601
   
590
   
613
       workDirParents[0]=*parent;
602
       workDirParents[0]=*parent;
614
     }
603
     }
615
     workDir=newfile;
604
     workDir=newfile;
616
-    #ifdef SDCARD_SORT_ALPHA
617
-      presort();
618
-    #endif
619
   }
605
   }
620
 }
606
 }
621
 
607
 
622
 void CardReader::updir()
608
 void CardReader::updir()
623
 {
609
 {
624
-  if (workDirDepth > 0)
610
+  if(workDirDepth > 0)
625
   {
611
   {
626
     --workDirDepth;
612
     --workDirDepth;
627
     workDir = workDirParents[0];
613
     workDir = workDirParents[0];
614
+    int d;
628
     for (int d = 0; d < workDirDepth; d++)
615
     for (int d = 0; d < workDirDepth; d++)
629
       workDirParents[d] = workDirParents[d+1];
616
       workDirParents[d] = workDirParents[d+1];
630
-    #ifdef SDCARD_SORT_ALPHA
631
-      presort();
632
-    #endif
633
-  }
634
-}
635
-
636
-#ifdef SDCARD_SORT_ALPHA
637
-
638
-/**
639
- * Get the name of a file in the current directory by sort-index
640
- */
641
-void CardReader::getfilename_sorted(const uint16_t nr) {
642
-  getfilename(nr < sort_count ? sort_order[nr] : nr);
643
-}
644
-
645
-/**
646
- * Read all the files and produce a sort key
647
- *
648
- * We can do this in 3 ways...
649
- *  - Minimal RAM: Read two filenames at a time sorting along...
650
- *  - Some RAM: Buffer the directory and return filenames from RAM
651
- *  - Some RAM: Buffer the directory just for this sort
652
- */
653
-void CardReader::presort()
654
-{
655
-  flush_presort();
656
-
657
-  uint16_t fileCnt = getnrfilenames();
658
-  if (fileCnt > 0) {
659
-
660
-    if (fileCnt > SORT_LIMIT) fileCnt = SORT_LIMIT;
661
-
662
-    #if SORT_USES_RAM
663
-      #if SORT_USES_MORE_RAM
664
-        sortshort = (char**)calloc(fileCnt, sizeof(char*));
665
-        sortnames = (char**)calloc(fileCnt, sizeof(char*));
666
-      #else
667
-        char *sortnames[fileCnt];
668
-      #endif
669
-    #else
670
-      char name1[LONG_FILENAME_LENGTH+1];
671
-    #endif
672
-
673
-    #if FOLDER_SORTING != 0
674
-      #if SORT_USES_RAM && SORT_USES_MORE_RAM
675
-        isDir = (uint8_t*)calloc(fileCnt, sizeof(uint8_t));
676
-      #else
677
-        uint8_t isDir[fileCnt];
678
-      #endif
679
-    #endif
680
-
681
-    sort_order = new uint8_t[fileCnt];
682
-
683
-    if (fileCnt > 1) {
684
-
685
-      // Init sort order. If using RAM then read all filenames now.
686
-      for (uint16_t i=0; i<fileCnt; i++) {
687
-        sort_order[i] = i;
688
-        #if SORT_USES_RAM
689
-          getfilename(i);
690
-          sortnames[i] = strdup(longFilename[0] ? longFilename : filename);
691
-          #if SORT_USES_MORE_RAM
692
-            sortshort[i] = strdup(filename);
693
-          #endif
694
-          // char out[30];
695
-          // sprintf_P(out, PSTR("---- %i %s %s"), i, filenameIsDir ? "D" : " ", sortnames[i]);
696
-          // SERIAL_ECHOLN(out);
697
-          #if FOLDER_SORTING != 0
698
-            isDir[i] = filenameIsDir;
699
-          #endif
700
-        #endif
701
-      }
702
-
703
-      // Bubble Sort
704
-      for (uint16_t i=fileCnt; --i;) {
705
-        bool cmp, didSwap = false;
706
-        for (uint16_t j=0; j<i; ++j) {
707
-          uint16_t s1 = j, s2 = j+1, o1 = sort_order[s1], o2 = sort_order[s2];
708
-          #if SORT_USES_RAM
709
-            #if FOLDER_SORTING != 0
710
-              cmp = (isDir[o1] == isDir[o2]) ? (strcasecmp(sortnames[o1], sortnames[o2]) > 0) : isDir[FOLDER_SORTING > 0 ? o1 : o2];
711
-            #else
712
-              cmp = strcasecmp(sortnames[o1], sortnames[o2]) > 0;
713
-            #endif
714
-          #else
715
-            getfilename(o1);
716
-            strcpy(name1, longFilename[0] ? longFilename : filename);
717
-            #if FOLDER_SORTING != 0
718
-              bool dir1 = filenameIsDir;
719
-            #endif
720
-            getfilename(o2);
721
-            char *name2 = longFilename[0] ? longFilename : filename;
722
-            #if FOLDER_SORTING != 0
723
-              cmp = (dir1 == filenameIsDir) ? (strcasecmp(name1, name2) > 0) : (FOLDER_SORTING > 0 ? dir1 : !dir1);
724
-            #else
725
-              cmp = strcasecmp(name1, name2) > 0;
726
-            #endif
727
-          #endif
728
-          if (cmp) {
729
-            sort_order[s1] = o2;
730
-            sort_order[s2] = o1;
731
-            didSwap = true;
732
-          }
733
-        }
734
-        if (!didSwap) break;
735
-      }
736
-
737
-      #if SORT_USES_RAM && !SORT_USES_MORE_RAM
738
-        for (uint16_t i=0; i<fileCnt; ++i) free(sortnames[i]);
739
-      #endif
740
-    }
741
-    else {
742
-      sort_order[0] = 0;
743
-      #if SORT_USES_RAM && SORT_USES_MORE_RAM
744
-        sortnames = (char**)malloc(sizeof(char*));
745
-        sortshort = (char**)malloc(sizeof(char*));
746
-        isDir = (uint8_t*)malloc(sizeof(uint8_t));
747
-        getfilename(0);
748
-        sortnames[0] = strdup(longFilename[0] ? longFilename : filename);
749
-        sortshort[0] = strdup(filename);
750
-        isDir[0] = filenameIsDir;
751
-      #endif
752
-    }
753
-
754
-    sort_count = fileCnt;
755
-  }
756
-}
757
-
758
-void CardReader::flush_presort() {
759
-  if (sort_count > 0) {
760
-    #if SORT_USES_RAM && SORT_USES_MORE_RAM
761
-      for (uint8_t i=0; i<sort_count; ++i) {
762
-        free(sortshort[i]);
763
-        free(sortnames[i]);
764
-      }
765
-      free(sortshort);
766
-      free(sortnames);
767
-    #endif
768
-    delete sort_order;
769
-    sort_count = 0;
770
   }
617
   }
771
 }
618
 }
772
 
619
 
773
-#endif // SDCARD_SORT_ALPHA
774
 
620
 
775
 void CardReader::printingHasFinished()
621
 void CardReader::printingHasFinished()
776
 {
622
 {
794
           enquecommand_P(PSTR(SD_FINISHED_RELEASECOMMAND));
640
           enquecommand_P(PSTR(SD_FINISHED_RELEASECOMMAND));
795
       }
641
       }
796
       autotempShutdown();
642
       autotempShutdown();
797
-      #ifdef SDCARD_SORT_ALPHA
798
-        presort();
799
-      #endif
800
     }
643
     }
801
 }
644
 }
802
 #endif //SDSUPPORT
645
 #endif //SDSUPPORT

+ 6
- 28
Marlin/cardreader.h View File

3
 
3
 
4
 #ifdef SDSUPPORT
4
 #ifdef SDSUPPORT
5
 
5
 
6
-#define MAX_DIR_DEPTH 10          // Maximum folder depth
7
-
8
-#ifdef SDCARD_SORT_ALPHA
9
-  #define SORT_USES_RAM false      // Buffer while sorting, else re-read from SD
10
-  #define SORT_USES_MORE_RAM false // Always keep the directory in RAM
11
-  #define SORT_LIMIT 256           // Maximum number of sorted items
12
-  #define FOLDER_SORTING -1        // -1=above  0=none  1=below
13
-#endif
6
+#define MAX_DIR_DEPTH 10
14
 
7
 
15
 #include "SdFile.h"
8
 #include "SdFile.h"
16
 enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
9
 enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
46
   void updir();
39
   void updir();
47
   void setroot();
40
   void setroot();
48
 
41
 
49
-#ifdef SDCARD_SORT_ALPHA
50
-  void presort();
51
-  void flush_presort();
52
-  void getfilename_sorted(const uint16_t nr);
53
-#endif
54
-
55
 
42
 
56
   FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
43
   FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
57
   FORCE_INLINE bool eof() { return sdpos>=filesize ;};
44
   FORCE_INLINE bool eof() { return sdpos>=filesize ;};
63
 public:
50
 public:
64
   bool saving;
51
   bool saving;
65
   bool logging;
52
   bool logging;
66
-  bool sdprinting;
67
-  bool cardOK;
68
-  char filename[FILENAME_LENGTH];
53
+  bool sdprinting ;  
54
+  bool cardOK ;
55
+  char filename[13];
69
   char longFilename[LONG_FILENAME_LENGTH];
56
   char longFilename[LONG_FILENAME_LENGTH];
70
   bool filenameIsDir;
57
   bool filenameIsDir;
71
   int lastnr; //last number of the autostart;
58
   int lastnr; //last number of the autostart;
72
 private:
59
 private:
73
   SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
60
   SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
74
   uint16_t workDirDepth;
61
   uint16_t workDirDepth;
75
-#ifdef SDCARD_SORT_ALPHA
76
-  uint16_t sort_count;
77
-  uint8_t *sort_order;
78
-  #if SORT_USES_MORE_RAM
79
-    char **sortshort;
80
-    char **sortnames;
81
-    uint8_t *isDir;
82
-  #endif
83
-#endif
84
   Sd2Card card;
62
   Sd2Card card;
85
   SdVolume volume;
63
   SdVolume volume;
86
   SdFile file;
64
   SdFile file;
87
   #define SD_PROCEDURE_DEPTH 1
65
   #define SD_PROCEDURE_DEPTH 1
88
-  #define MAXPATHNAMELENGTH (FILENAME_LENGTH*MAX_DIR_DEPTH+MAX_DIR_DEPTH+1)
66
+  #define MAXPATHNAMELENGTH (13*MAX_DIR_DEPTH+MAX_DIR_DEPTH+1)
89
   uint8_t file_subcall_ctr;
67
   uint8_t file_subcall_ctr;
90
   uint32_t filespos[SD_PROCEDURE_DEPTH];
68
   uint32_t filespos[SD_PROCEDURE_DEPTH];
91
   char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
69
   char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
97
   bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
75
   bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
98
   
76
   
99
   LsAction lsAction; //stored for recursion.
77
   LsAction lsAction; //stored for recursion.
100
-  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.
78
+  int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
101
   char* diveDirName;
79
   char* diveDirName;
102
   void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
80
   void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
103
 };
81
 };

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

295
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
295
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
296
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
296
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
297
 
297
 
298
-//#define SDCARD_SORT_ALPHA // Sort SD file listings in ASCII order. Find additional options in cardreader.h
299
 #define SDCARD_RATHERRECENTFIRST  //reverse file order of sd card menu display. Its sorted practically after the file system block order.
298
 #define SDCARD_RATHERRECENTFIRST  //reverse file order of sd card menu display. Its sorted practically after the file system block order.
300
 // if a file is deleted, it frees a block. hence, the order is not purely chronological. To still have auto0.g accessible, there is again the option to do that.
299
 // if a file is deleted, it frees a block. hence, the order is not purely chronological. To still have auto0.g accessible, there is again the option to do that.
301
 // using:
300
 // using:

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

287
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
287
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
288
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
288
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
289
 
289
 
290
-//#define SDCARD_SORT_ALPHA // Sort SD file listings in ASCII order. Find additional options in cardreader.h
291
 #define SDCARD_RATHERRECENTFIRST  //reverse file order of sd card menu display. Its sorted practically after the filesystem block order. 
290
 #define SDCARD_RATHERRECENTFIRST  //reverse file order of sd card menu display. Its sorted practically after the filesystem block order. 
292
 // if a file is deleted, it frees a block. hence, the order is not purely cronological. To still have auto0.g accessible, there is again the option to do that.
291
 // if a file is deleted, it frees a block. hence, the order is not purely cronological. To still have auto0.g accessible, there is again the option to do that.
293
 // using:
292
 // using:

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

291
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
291
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
292
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
292
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
293
 
293
 
294
-//#define SDCARD_SORT_ALPHA // Sort SD file listings in ASCII order. Find additional options in cardreader.h
295
 #define SDCARD_RATHERRECENTFIRST  //reverse file order of sd card menu display. Its sorted practically after the file system block order.
294
 #define SDCARD_RATHERRECENTFIRST  //reverse file order of sd card menu display. Its sorted practically after the file system block order.
296
 // if a file is deleted, it frees a block. hence, the order is not purely chronological. To still have auto0.g accessible, there is again the option to do that.
295
 // if a file is deleted, it frees a block. hence, the order is not purely chronological. To still have auto0.g accessible, there is again the option to do that.
297
 // using:
296
 // using:

+ 11
- 18
Marlin/ultralcd.cpp View File

886
     card.getWorkDirName();
886
     card.getWorkDirName();
887
     if(card.filename[0]=='/')
887
     if(card.filename[0]=='/')
888
     {
888
     {
889
-      #if SDCARDDETECT == -1
889
+#if SDCARDDETECT == -1
890
         MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
890
         MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
891
-      #endif
891
+#endif
892
     }else{
892
     }else{
893
         MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
893
         MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
894
     }
894
     }
897
     {
897
     {
898
         if (_menuItemNr == _lineNr)
898
         if (_menuItemNr == _lineNr)
899
         {
899
         {
900
-            #if defined(SDCARD_RATHERRECENTFIRST) && !defined(SDCARD_SORT_ALPHA)
901
-              int nr = fileCnt-1-i;
900
+            #ifndef SDCARD_RATHERRECENTFIRST
901
+              card.getfilename(i);
902
             #else
902
             #else
903
-              int nr = i;
903
+              card.getfilename(fileCnt-1-i);
904
             #endif
904
             #endif
905
-
906
-            #ifdef SDCARD_SORT_ALPHA
907
-              card.getfilename_sorted(nr);
908
-            #else
909
-              card.getfilename(nr);
910
-            #endif
911
-
912
-            if (card.filenameIsDir) {
913
-              MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename);
914
-            }
915
-            else {
916
-              MENU_ITEM(sdfile, MSG_CARD_MENU, card.filename, card.longFilename);
905
+            if (card.filenameIsDir)
906
+            {
907
+                MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename);
908
+            }else{
909
+                MENU_ITEM(sdfile, MSG_CARD_MENU, card.filename, card.longFilename);
917
             }
910
             }
918
         }else{
911
         }else{
919
             MENU_ITEM_DUMMY();
912
             MENU_ITEM_DUMMY();
1090
   #endif // SR_LCD_2W_NL
1083
   #endif // SR_LCD_2W_NL
1091
 #endif//!NEWPANEL
1084
 #endif//!NEWPANEL
1092
 
1085
 
1093
-#if defined(SDSUPPORT) && defined(SDCARDDETECT) && (SDCARDDETECT > 0)
1086
+#if defined (SDSUPPORT) && defined(SDCARDDETECT) && (SDCARDDETECT > 0)
1094
     pinMode(SDCARDDETECT,INPUT);
1087
     pinMode(SDCARDDETECT,INPUT);
1095
     WRITE(SDCARDDETECT, HIGH);
1088
     WRITE(SDCARDDETECT, HIGH);
1096
     lcd_oldcardstatus = IS_SD_INSERTED;
1089
     lcd_oldcardstatus = IS_SD_INSERTED;

Loading…
Cancel
Save