Merge branch 'Marlin_v1' into revert-1154-sd_sorting
Conflicts: Marlin/cardreader.cpp Marlin/cardreader.h
This commit is contained in:
@ -50,7 +50,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;
|
||||
@ -92,16 +92,12 @@ 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;
|
||||
if (longFilename[0] != '\0' &&
|
||||
(longFilename[0] == '.' || longFilename[0] == '_')) continue;
|
||||
if ( p.name[0] == '.')
|
||||
{
|
||||
if ( p.name[1] != '.')
|
||||
continue;
|
||||
}
|
||||
|
||||
char pn0 = p.name[0];
|
||||
if (pn0 == DIR_NAME_FREE) break;
|
||||
if (pn0 == DIR_NAME_DELETED || pn0 == '.' || pn0 == '_') continue;
|
||||
char lf0 = longFilename[0];
|
||||
if (lf0 == '.' || lf0 == '_') continue;
|
||||
|
||||
if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
|
||||
filenameIsDir=DIR_IS_SUBDIR(&p);
|
||||
|
||||
@ -124,8 +120,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++;
|
||||
|
||||
}
|
||||
@ -150,9 +148,17 @@ void CardReader::initsd()
|
||||
if(root.isOpen())
|
||||
root.close();
|
||||
#ifdef SDSLOW
|
||||
if (!card.init(SPI_HALF_SPEED,SDSS))
|
||||
if (!card.init(SPI_HALF_SPEED,SDSS)
|
||||
#if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
|
||||
&& !card.init(SPI_HALF_SPEED,LCD_SDSS)
|
||||
#endif
|
||||
)
|
||||
#else
|
||||
if (!card.init(SPI_FULL_SPEED,SDSS))
|
||||
if (!card.init(SPI_FULL_SPEED,SDSS)
|
||||
#if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
|
||||
&& !card.init(SPI_FULL_SPEED,LCD_SDSS)
|
||||
#endif
|
||||
)
|
||||
#endif
|
||||
{
|
||||
//if (!card.init(SPI_HALF_SPEED,SDSS))
|
||||
@ -350,7 +356,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
|
||||
{
|
||||
@ -552,13 +559,13 @@ void CardReader::closefile(bool store_location)
|
||||
|
||||
}
|
||||
|
||||
void CardReader::getfilename(const uint8_t nr)
|
||||
void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/)
|
||||
{
|
||||
curDir=&workDir;
|
||||
lsAction=LS_GetFilename;
|
||||
nrFiles=nr;
|
||||
curDir->rewind();
|
||||
lsDive("",*curDir);
|
||||
lsDive("",*curDir,match);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user