Browse Source

Merge pull request #1188 from thinkyhead/lcd_longname

LCD Long Filename
pull/1/head
Bo Herrmannsen 10 years ago
parent
commit
140ce06692
  1. 25
      Marlin/cardreader.cpp
  2. 4
      Marlin/cardreader.h

25
Marlin/cardreader.cpp

@ -49,7 +49,7 @@ char *createFilename(char *buffer, const dir_t &p) //buffer>12characters
}
void CardReader::lsDive(const char *prepend,SdFile parent)
void CardReader::lsDive(const char *prepend, SdFile parent, const char * const match/*=NULL*/)
{
dir_t p;
uint8_t cnt=0;
@ -89,15 +89,11 @@ void CardReader::lsDive(const char *prepend,SdFile parent)
}
else
{
if (p.name[0] == DIR_NAME_FREE) break;
if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.'|| p.name[0] == '_') continue;
char pn0 = p.name[0];
if (pn0 == DIR_NAME_FREE) break;
if (pn0 == DIR_NAME_DELETED || pn0 == '.'|| pn0 == '_') continue;
if (longFilename[0] != '\0' &&
(longFilename[0] == '.' || longFilename[0] == '_')) continue;
if ( p.name[0] == '.')
{
if ( p.name[1] != '.')
continue;
}
if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
filenameIsDir=DIR_IS_SUBDIR(&p);
@ -120,7 +116,10 @@ void CardReader::lsDive(const char *prepend,SdFile parent)
}
else if(lsAction==LS_GetFilename)
{
if (cnt == nrFiles) return;
if (match != NULL) {
if (strcasecmp(match, filename) == 0) return;
}
else if (cnt == nrFiles) return;
cnt++;
}
}
@ -355,7 +354,8 @@ void CardReader::openFile(char* name,bool read, bool replace_current/*=true*/)
sdpos = 0;
SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED);
lcd_setstatus(fname);
getfilename(0, fname);
lcd_setstatus(longFilename[0] ? longFilename : fname);
}
else
{
@ -560,7 +560,7 @@ void CardReader::closefile(bool store_location)
}
void CardReader::getfilename(const uint16_t nr)
void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/)
{
#if defined(SDCARD_SORT_ALPHA) && SORT_USES_RAM && SORT_USES_MORE_RAM
if (nr < sort_count) {
@ -574,7 +574,8 @@ void CardReader::getfilename(const uint16_t nr)
lsAction=LS_GetFilename;
nrFiles=nr;
curDir->rewind();
lsDive("",*curDir);
lsDive("",*curDir,match);
}
uint16_t CardReader::getnrfilenames()

4
Marlin/cardreader.h

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

Loading…
Cancel
Save