Browse Source

Support for 10 level deep SD folder hierarchy

Scott Lahteine 12 years ago
parent
commit
a5cd582665
2 changed files with 17 additions and 7 deletions
  1. 13
    6
      Marlin/cardreader.cpp
  2. 4
    1
      Marlin/cardreader.h

+ 13
- 6
Marlin/cardreader.cpp View File

18
    saving = false;
18
    saving = false;
19
    logging = false;
19
    logging = false;
20
    autostart_atmillis=0;
20
    autostart_atmillis=0;
21
+   workDirDepth = 0;
22
+   memset(workDirParents, 0, sizeof(workDirParents));
21
 
23
 
22
    autostart_stilltocheck=true; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
24
    autostart_stilltocheck=true; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
23
    lastnr=0;
25
    lastnr=0;
521
   }
523
   }
522
   else
524
   else
523
   {
525
   {
524
-    workDirParentParent=workDirParent;
525
-    workDirParent=*parent;
526
-    
526
+    if (workDirDepth < MAX_DIR_DEPTH) {
527
+      for (int d = ++workDirDepth; d--;)
528
+        workDirParents[d+1] = workDirParents[d];
529
+      workDirParents[0]=*parent;
530
+    }
527
     workDir=newfile;
531
     workDir=newfile;
528
   }
532
   }
529
 }
533
 }
530
 
534
 
531
 void CardReader::updir()
535
 void CardReader::updir()
532
 {
536
 {
533
-  if(!workDir.isRoot())
537
+  if(workDirDepth > 0)
534
   {
538
   {
535
-    workDir=workDirParent;
536
-    workDirParent=workDirParentParent;
539
+    --workDirDepth;
540
+    workDir = workDirParents[0];
541
+    int d;
542
+    for (int d = 0; d < workDirDepth; d++)
543
+      workDirParents[d] = workDirParents[d+1];
537
   }
544
   }
538
 }
545
 }
539
 
546
 

+ 4
- 1
Marlin/cardreader.h View File

3
 
3
 
4
 #ifdef SDSUPPORT
4
 #ifdef SDSUPPORT
5
 
5
 
6
+#define MAX_DIR_DEPTH 10
7
+
6
 #include "SdFile.h"
8
 #include "SdFile.h"
7
 enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
9
 enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
8
 class CardReader
10
 class CardReader
53
   bool filenameIsDir;
55
   bool filenameIsDir;
54
   int lastnr; //last number of the autostart;
56
   int lastnr; //last number of the autostart;
55
 private:
57
 private:
56
-  SdFile root,*curDir,workDir,workDirParent,workDirParentParent;
58
+  SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
59
+  uint16_t workDirDepth;
57
   Sd2Card card;
60
   Sd2Card card;
58
   SdVolume volume;
61
   SdVolume volume;
59
   SdFile file;
62
   SdFile file;

Loading…
Cancel
Save