Updated the SD librarie because it was updated in the sdk.

This commit is contained in:
anschrammh 2021-12-19 13:10:16 +01:00
parent 5c42dfce39
commit ae72a34a80
8 changed files with 27 additions and 44 deletions

View File

@ -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...");

View File

@ -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...");

View File

@ -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...");

View File

@ -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...");

View File

@ -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();
}

View File

@ -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

View File

@ -1,4 +1,4 @@
name=SD(esp8266)
name=SD
version=2.0.0
author=Earle F. Philhower, III <earlephilhower@yahoo.com>
maintainer=Earle F. Philhower, III <earlephilhower@yahoo.com>

View File

@ -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::SDFSImpl*>(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;
}