diff --git a/src/libs/SD/examples/Datalogger/Datalogger.ino b/src/libs/SD/examples/Datalogger/Datalogger.ino index fcb7a56..a023b63 100644 --- a/src/libs/SD/examples/Datalogger/Datalogger.ino +++ b/src/libs/SD/examples/Datalogger/Datalogger.ino @@ -27,11 +27,7 @@ const int chipSelect = 4; void setup() { // Open serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - + Serial.begin(115200); Serial.print("Initializing SD card..."); diff --git a/src/libs/SD/examples/DumpFile/DumpFile.ino b/src/libs/SD/examples/DumpFile/DumpFile.ino index 42bd8bc..3574652 100644 --- a/src/libs/SD/examples/DumpFile/DumpFile.ino +++ b/src/libs/SD/examples/DumpFile/DumpFile.ino @@ -27,11 +27,7 @@ const int chipSelect = 4; void setup() { // Open serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - + Serial.begin(115200); Serial.print("Initializing SD card..."); diff --git a/src/libs/SD/examples/Files/Files.ino b/src/libs/SD/examples/Files/Files.ino index cb2c1f1..1c1b83e 100644 --- a/src/libs/SD/examples/Files/Files.ino +++ b/src/libs/SD/examples/Files/Files.ino @@ -24,11 +24,7 @@ File myFile; void setup() { // Open serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - + Serial.begin(115200); Serial.print("Initializing SD card..."); diff --git a/src/libs/SD/examples/ReadWrite/ReadWrite.ino b/src/libs/SD/examples/ReadWrite/ReadWrite.ino index cd63aa5..7aa9a40 100644 --- a/src/libs/SD/examples/ReadWrite/ReadWrite.ino +++ b/src/libs/SD/examples/ReadWrite/ReadWrite.ino @@ -25,11 +25,7 @@ File myFile; void setup() { // Open serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - + Serial.begin(115200); Serial.print("Initializing SD card..."); diff --git a/src/libs/SD/examples/listfiles/listfiles.ino b/src/libs/SD/examples/listfiles/listfiles.ino index fd35d0c..55478d7 100644 --- a/src/libs/SD/examples/listfiles/listfiles.ino +++ b/src/libs/SD/examples/listfiles/listfiles.ino @@ -29,9 +29,6 @@ File root; void setup() { // Open serial communications and wait for port to open: Serial.begin(115200); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } Serial.print("Initializing SD card..."); @@ -71,11 +68,12 @@ void printDirectory(File dir, int numTabs) { // files have sizes, directories do not Serial.print("\t\t"); Serial.print(entry.size(), DEC); - Serial.print("\t\t"); - time_t ft = entry.getLastWrite(); - struct tm *tm = localtime(&ft); - // US format. Feel free to convert to your own locale... - Serial.printf("%02d-%02d-%02d %02d:%02d:%02d\n", tm->tm_mon + 1, tm->tm_mday, tm->tm_year % 100, tm->tm_hour, tm->tm_min, tm->tm_sec); + time_t cr = entry.getCreationTime(); + time_t lw = entry.getLastWrite(); + struct tm * tmstruct = localtime(&cr); + Serial.printf("\tCREATION: %d-%02d-%02d %02d:%02d:%02d", (tmstruct->tm_year) + 1900, (tmstruct->tm_mon) + 1, tmstruct->tm_mday, tmstruct->tm_hour, tmstruct->tm_min, tmstruct->tm_sec); + tmstruct = localtime(&lw); + Serial.printf("\tLAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n", (tmstruct->tm_year) + 1900, (tmstruct->tm_mon) + 1, tmstruct->tm_mday, tmstruct->tm_hour, tmstruct->tm_min, tmstruct->tm_sec); } entry.close(); } diff --git a/src/libs/SD/keywords.txt b/src/libs/SD/keywords.txt index 07717c6..9893cc9 100644 --- a/src/libs/SD/keywords.txt +++ b/src/libs/SD/keywords.txt @@ -21,12 +21,10 @@ open KEYWORD2 close KEYWORD2 seek KEYWORD2 position KEYWORD2 -size KEYWORD2 -rename KEYWORD2 +size KEYWORD2 ####################################### # Constants (LITERAL1) ####################################### FILE_READ LITERAL1 FILE_WRITE LITERAL1 -FILE_READWRITE LITERAL1 diff --git a/src/libs/SD/library.properties b/src/libs/SD/library.properties index 5091024..72210df 100644 --- a/src/libs/SD/library.properties +++ b/src/libs/SD/library.properties @@ -1,4 +1,4 @@ -name=SD(esp8266) +name=SD version=2.0.0 author=Earle F. Philhower, III maintainer=Earle F. Philhower, III diff --git a/src/libs/SD/src/SD.h b/src/libs/SD/src/SD.h index 007553a..a6bd4a6 100644 --- a/src/libs/SD/src/SD.h +++ b/src/libs/SD/src/SD.h @@ -27,13 +27,12 @@ #undef FILE_READ #define FILE_READ sdfat::O_READ #undef FILE_WRITE -#define FILE_WRITE (sdfat::O_READ | sdfat::O_WRITE | sdfat::O_CREAT | sdfat::O_APPEND) -#undef FILE_READWRITE +#define FILE_WRITE (sdfat::O_READ | sdfat::O_WRITE | sdfat::O_CREAT | sdfat::O_APPEND) #define FILE_READWRITE (sdfat::O_READ | sdfat::O_WRITE) class SDClass { public: - boolean begin(uint8_t csPin, SPISettings cfg = SPI_HALF_SPEED) { + boolean begin(uint8_t csPin, uint32_t cfg = SPI_HALF_SPEED) { SDFS.setConfig(SDFSConfig(csPin, cfg)); return (boolean)SDFS.begin(); } @@ -69,6 +68,18 @@ public: return (boolean)SDFS.exists(filepath.c_str()); } + boolean rename(const char* filepathfrom, const char* filepathto) { + return (boolean)SDFS.rename(filepathfrom, filepathto); + } + + bool info64(FSInfo64& info) { + return (boolean)SDFS.info64(info); + } + + boolean rename(const String &filepathfrom, const String &filepathto) { + return (boolean)rename(filepathfrom.c_str(), filepathto.c_str()); + } + boolean mkdir(const char *filepath) { return (boolean)SDFS.mkdir(filepath); } @@ -92,14 +103,6 @@ public: boolean rmdir(const String &filepath) { return rmdir(filepath.c_str()); } - - bool rename(const char* pathFrom, const char* pathTo) { - return (boolean)SDFS.rename(pathFrom, pathTo); - } - - bool info64(FSInfo64& info) { - return (boolean)SDFS.info64(info); - } uint8_t type() { sdfs::SDFSImpl* sd = static_cast(SDFS.getImpl().get()); @@ -184,7 +187,7 @@ private: }; -// Expose FatStructs.h helpers for MSDOS date/time for use with dateTimeCallback +// Expose FatStructs.h helpers for MS-DOS date/time for use with dateTimeCallback static inline uint16_t FAT_DATE(uint16_t year, uint8_t month, uint8_t day) { return (year - 1980) << 9 | month << 5 | day; }