mirror of
https://github.com/LilyGO/TTGO-T2-ESP32.git
synced 2024-09-21 02:18:30 +00:00
Delete ESP32_T2 Sd_test.ino
This commit is contained in:
parent
a7417e5fe6
commit
4fa357d097
@ -1,83 +0,0 @@
|
||||
|
||||
#include <mySD.h>
|
||||
|
||||
File root;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Initializing SD card...");
|
||||
/* initialize SD library with SPI pins */
|
||||
if (!SD.begin(23, 5, 19, 18)) {
|
||||
Serial.println("initialization failed!");
|
||||
return;
|
||||
}
|
||||
Serial.println("initialization done.");
|
||||
/* Begin at the root "/" */
|
||||
root = SD.open("/");
|
||||
if (root) {
|
||||
printDirectory(root, 0);
|
||||
root.close();
|
||||
} else {
|
||||
Serial.println("error opening test.txt");
|
||||
}
|
||||
/* open "test.txt" for writing */
|
||||
root = SD.open("test.txt", FILE_WRITE);
|
||||
/* if open succesfully -> root != NULL
|
||||
then write string "Hello world!" to it
|
||||
*/
|
||||
if (root) {
|
||||
root.println("Hello world!");
|
||||
root.flush();
|
||||
/* close the file */
|
||||
root.close();
|
||||
} else {
|
||||
/* if the file open error, print an error */
|
||||
Serial.println("error opening test.txt");
|
||||
}
|
||||
delay(1000);
|
||||
/* after writing then reopen the file and read it */
|
||||
root = SD.open("test.txt");
|
||||
if (root) {
|
||||
/* read from the file until there's nothing else in it */
|
||||
while (root.available()) {
|
||||
/* read the file and print to Terminal */
|
||||
Serial.write(root.read());
|
||||
}
|
||||
root.close();
|
||||
} else {
|
||||
Serial.println("error opening test.txt");
|
||||
}
|
||||
|
||||
Serial.println("done!");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
void printDirectory(File dir, int numTabs) {
|
||||
|
||||
while(true) {
|
||||
File entry = dir.openNextFile();
|
||||
if (! entry) {
|
||||
break;
|
||||
}
|
||||
for (uint8_t i=0; i<numTabs; i++) {
|
||||
Serial.print('\t'); // we'll have a nice indentation
|
||||
}
|
||||
// Print the name
|
||||
Serial.print(entry.name());
|
||||
/* Recurse for directories, otherwise print the file size */
|
||||
if (entry.isDirectory()) {
|
||||
Serial.println("/");
|
||||
printDirectory(entry, numTabs+1);
|
||||
} else {
|
||||
/* files have sizes, directories do not */
|
||||
Serial.print("\t\t");
|
||||
Serial.println(entry.size());
|
||||
}
|
||||
entry.close();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user