Selaa lähdekoodia

Rebase to Marlin_v1

Scott Lahteine 10 vuotta sitten
vanhempi
commit
f21cce0b28
2 muutettua tiedostoa jossa 16 lisäystä ja 15 poistoa
  1. 14
    13
      Marlin/cardreader.cpp
  2. 2
    2
      Marlin/cardreader.h

+ 14
- 13
Marlin/cardreader.cpp Näytä tiedosto

@@ -49,7 +49,7 @@ char *createFilename(char *buffer, const dir_t &p) //buffer>12characters
49 49
 }
50 50
 
51 51
 
52
-void  CardReader::lsDive(const char *prepend,SdFile parent)
52
+void CardReader::lsDive(const char *prepend, SdFile parent, const char * const match/*=NULL*/)
53 53
 {
54 54
   dir_t p;
55 55
   uint8_t cnt=0;
@@ -89,16 +89,12 @@ void  CardReader::lsDive(const char *prepend,SdFile parent)
89 89
     }
90 90
     else
91 91
     {
92
-      if (p.name[0] == DIR_NAME_FREE) break;
93
-      if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.'|| p.name[0] == '_') continue;
92
+      char pn0 = p.name[0];
93
+      if (pn0 == DIR_NAME_FREE) break;
94
+      if (pn0 == DIR_NAME_DELETED || pn0 == '.'|| pn0 == '_') continue;
94 95
       if (longFilename[0] != '\0' &&
95 96
           (longFilename[0] == '.' || longFilename[0] == '_')) continue;
96
-      if ( p.name[0] == '.')
97
-      {
98
-        if ( p.name[1] != '.')
99
-        continue;
100
-      }
101
-
97
+      
102 98
       if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
103 99
       filenameIsDir=DIR_IS_SUBDIR(&p);
104 100
 
@@ -120,7 +116,10 @@ void  CardReader::lsDive(const char *prepend,SdFile parent)
120 116
       } 
121 117
       else if(lsAction==LS_GetFilename)
122 118
       {
123
-        if (cnt == nrFiles) return;
119
+        if (match != NULL) {
120
+          if (strcasecmp(match, filename) == 0) return;
121
+        }
122
+        else if (cnt == nrFiles) return;
124 123
         cnt++;
125 124
       }
126 125
     }
@@ -355,7 +354,8 @@ void CardReader::openFile(char* name,bool read, bool replace_current/*=true*/)
355 354
       sdpos = 0;
356 355
       
357 356
       SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED);
358
-      lcd_setstatus(fname);
357
+      getfilename(0, fname);
358
+      lcd_setstatus(longFilename[0] ? longFilename : fname);
359 359
     }
360 360
     else
361 361
     {
@@ -560,7 +560,7 @@ void CardReader::closefile(bool store_location)
560 560
   
561 561
 }
562 562
 
563
-void CardReader::getfilename(const uint16_t nr)
563
+void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/)
564 564
 {
565 565
   #if defined(SDCARD_SORT_ALPHA) && SORT_USES_RAM && SORT_USES_MORE_RAM
566 566
     if (nr < sort_count) {
@@ -574,7 +574,8 @@ void CardReader::getfilename(const uint16_t nr)
574 574
   lsAction=LS_GetFilename;
575 575
   nrFiles=nr;
576 576
   curDir->rewind();
577
-  lsDive("",*curDir);
577
+  lsDive("",*curDir,match);
578
+  
578 579
 }
579 580
 
580 581
 uint16_t CardReader::getnrfilenames()

+ 2
- 2
Marlin/cardreader.h Näytä tiedosto

@@ -35,7 +35,7 @@ public:
35 35
   void getStatus();
36 36
   void printingHasFinished();
37 37
 
38
-  void getfilename(const uint16_t nr);
38
+  void getfilename(uint16_t nr, const char* const match=NULL);
39 39
   uint16_t getnrfilenames();
40 40
   
41 41
   void getAbsFilename(char *t);
@@ -99,7 +99,7 @@ private:
99 99
   LsAction lsAction; //stored for recursion.
100 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.
101 101
   char* diveDirName;
102
-  void lsDive(const char *prepend,SdFile parent);
102
+  void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
103 103
 };
104 104
 extern CardReader card;
105 105
 #define IS_SD_PRINTING (card.sdprinting)

Loading…
Peruuta
Tallenna