Merge pull request #1409 from thinkyhead/rename_lastnr
Rename lastnr to autostart_index and...
This commit is contained in:
commit
5fbef6bed2
@ -1012,7 +1012,7 @@ void SdBaseFile::printFatTime( uint16_t fatTime) {
|
||||
* the value zero, false, is returned for failure.
|
||||
*/
|
||||
bool SdBaseFile::printName() {
|
||||
char name[13];
|
||||
char name[FILENAME_LENGTH];
|
||||
if (!getFilename(name)) return false;
|
||||
MYSERIAL.print(name);
|
||||
return true;
|
||||
@ -1135,7 +1135,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
|
||||
if (VFAT->firstClusterLow == 0 && (VFAT->sequenceNumber & 0x1F) > 0 && (VFAT->sequenceNumber & 0x1F) <= MAX_VFAT_ENTRIES)
|
||||
{
|
||||
//TODO: Store the filename checksum to verify if a none-long filename aware system modified the file table.
|
||||
n = ((VFAT->sequenceNumber & 0x1F) - 1) * 13;
|
||||
n = ((VFAT->sequenceNumber & 0x1F) - 1) * FILENAME_LENGTH;
|
||||
longFilename[n+0] = VFAT->name1[0];
|
||||
longFilename[n+1] = VFAT->name1[1];
|
||||
longFilename[n+2] = VFAT->name1[2];
|
||||
@ -1151,7 +1151,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
|
||||
longFilename[n+12] = VFAT->name3[1];
|
||||
//If this VFAT entry is the last one, add a NUL terminator at the end of the string
|
||||
if (VFAT->sequenceNumber & 0x40)
|
||||
longFilename[n+13] = '\0';
|
||||
longFilename[n+FILENAME_LENGTH] = '\0';
|
||||
}
|
||||
}
|
||||
// return if normal file or subdirectory
|
||||
|
@ -108,15 +108,17 @@ uint8_t const SOFT_SPI_SCK_PIN = 13;
|
||||
* a pure virtual function is called.
|
||||
*/
|
||||
#define USE_CXA_PURE_VIRTUAL 1
|
||||
|
||||
/** Number of UTF-16 characters per entry */
|
||||
#define FILENAME_LENGTH 13
|
||||
|
||||
/**
|
||||
* Defines for long (vfat) filenames
|
||||
*/
|
||||
/** Number of VFAT entries used. Every entry has 13 UTF-16 characters */
|
||||
#define MAX_VFAT_ENTRIES (2)
|
||||
/** Number of UTF-16 characters per entry */
|
||||
#define FILENAME_LENGTH 13
|
||||
/** Total size of the buffer used to store the long filenames */
|
||||
#define LONG_FILENAME_LENGTH (13*MAX_VFAT_ENTRIES+1)
|
||||
#define LONG_FILENAME_LENGTH (FILENAME_LENGTH*MAX_VFAT_ENTRIES+1)
|
||||
#endif // SdFatConfig_h
|
||||
|
||||
|
||||
|
@ -23,7 +23,7 @@ CardReader::CardReader()
|
||||
memset(workDirParents, 0, sizeof(workDirParents));
|
||||
|
||||
autostart_stilltocheck=true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
|
||||
lastnr=0;
|
||||
autostart_index=0;
|
||||
//power to SD reader
|
||||
#if SDPOWER > -1
|
||||
SET_OUTPUT(SDPOWER);
|
||||
@ -60,8 +60,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
|
||||
if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint
|
||||
{
|
||||
|
||||
char path[13*2];
|
||||
char lfilename[13];
|
||||
char path[FILENAME_LENGTH*2];
|
||||
char lfilename[FILENAME_LENGTH];
|
||||
createFilename(lfilename,p);
|
||||
|
||||
path[0]=0;
|
||||
@ -241,7 +241,7 @@ void CardReader::getAbsFilename(char *t)
|
||||
while(*t!=0 && cnt< MAXPATHNAMELENGTH)
|
||||
{t++;cnt++;} //crawl counter forward.
|
||||
}
|
||||
if(cnt<MAXPATHNAMELENGTH-13)
|
||||
if(cnt<MAXPATHNAMELENGTH-FILENAME_LENGTH)
|
||||
file.getFilename(t);
|
||||
else
|
||||
t[0]=0;
|
||||
@ -311,7 +311,7 @@ void CardReader::openFile(char* name,bool read, bool replace_current/*=true*/)
|
||||
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
|
||||
if(dirname_end>0 && dirname_end>dirname_start)
|
||||
{
|
||||
char subdirname[13];
|
||||
char subdirname[FILENAME_LENGTH];
|
||||
strncpy(subdirname, dirname_start, dirname_end-dirname_start);
|
||||
subdirname[dirname_end-dirname_start]=0;
|
||||
SERIAL_ECHOLN(subdirname);
|
||||
@ -408,7 +408,7 @@ void CardReader::removeFile(char* name)
|
||||
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
|
||||
if(dirname_end>0 && dirname_end>dirname_start)
|
||||
{
|
||||
char subdirname[13];
|
||||
char subdirname[FILENAME_LENGTH];
|
||||
strncpy(subdirname, dirname_start, dirname_end-dirname_start);
|
||||
subdirname[dirname_end-dirname_start]=0;
|
||||
SERIAL_ECHOLN(subdirname);
|
||||
@ -510,7 +510,7 @@ void CardReader::checkautostart(bool force)
|
||||
}
|
||||
|
||||
char autoname[30];
|
||||
sprintf_P(autoname, PSTR("auto%i.g"), lastnr);
|
||||
sprintf_P(autoname, PSTR("auto%i.g"), autostart_index);
|
||||
for(int8_t i=0;i<(int8_t)strlen(autoname);i++)
|
||||
autoname[i]=tolower(autoname[i]);
|
||||
dir_t p;
|
||||
@ -537,9 +537,9 @@ void CardReader::checkautostart(bool force)
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
lastnr=-1;
|
||||
autostart_index=-1;
|
||||
else
|
||||
lastnr++;
|
||||
autostart_index++;
|
||||
}
|
||||
|
||||
void CardReader::closefile(bool store_location)
|
||||
|
@ -50,12 +50,12 @@ public:
|
||||
public:
|
||||
bool saving;
|
||||
bool logging;
|
||||
bool sdprinting ;
|
||||
bool cardOK ;
|
||||
char filename[13];
|
||||
bool sdprinting;
|
||||
bool cardOK;
|
||||
char filename[FILENAME_LENGTH];
|
||||
char longFilename[LONG_FILENAME_LENGTH];
|
||||
bool filenameIsDir;
|
||||
int lastnr; //last number of the autostart;
|
||||
int autostart_index;
|
||||
private:
|
||||
SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
|
||||
uint16_t workDirDepth;
|
||||
@ -63,7 +63,7 @@ private:
|
||||
SdVolume volume;
|
||||
SdFile file;
|
||||
#define SD_PROCEDURE_DEPTH 1
|
||||
#define MAXPATHNAMELENGTH (13*MAX_DIR_DEPTH+MAX_DIR_DEPTH+1)
|
||||
#define MAXPATHNAMELENGTH (FILENAME_LENGTH*MAX_DIR_DEPTH+MAX_DIR_DEPTH+1)
|
||||
uint8_t file_subcall_ctr;
|
||||
uint32_t filespos[SD_PROCEDURE_DEPTH];
|
||||
char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
|
||||
|
@ -377,7 +377,7 @@ static void lcd_main_menu()
|
||||
#ifdef SDSUPPORT
|
||||
static void lcd_autostart_sd()
|
||||
{
|
||||
card.lastnr=0;
|
||||
card.autostart_index=0;
|
||||
card.setroot();
|
||||
card.checkautostart(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user