1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-01 03:47:23 +03:00

Merge branch 'master' into ide-1.5.x

Conflicts:
	build/shared/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino
	build/shared/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino
	libraries/LiquidCrystal/examples/CustomCharacter/CustomCharacter.ino
	libraries/SD/examples/listfiles/listfiles.ino
This commit is contained in:
Cristian Maglie
2013-11-12 09:45:56 +01:00
4 changed files with 68 additions and 63 deletions

View File

@ -1,7 +1,9 @@
/*
SD card basic file example
This example shows how to create and destroy an SD card file
Listfiles
This example shows how print out the files in a
directory on a SD card
The circuit:
* SD card attached to SPI bus as follows:
** MOSI - pin 11
@ -30,7 +32,6 @@ void setup()
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
@ -57,28 +58,27 @@ void loop()
}
void printDirectory(File dir, int numTabs) {
while (true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
//Serial.println("**nomorefiles**");
break;
}
for (uint8_t i = 0; i < numTabs; i++) {
Serial.print('\t');
}
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numTabs + 1);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
}
while(true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
break;
}
for (uint8_t i=0; i<numTabs; i++) {
Serial.print('\t');
}
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numTabs+1);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
}
}