1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

examples: format all .ino files

This formats all the example source files using Arduino style rules.
This commit is contained in:
Ivan Grokhotkov
2018-02-19 18:30:59 +03:00
committed by Ivan Grokhotkov
parent e226251b27
commit 61cd8d8385
88 changed files with 2730 additions and 2801 deletions

View File

@ -1,33 +1,32 @@
/*
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:
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
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
created Nov 2010
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
modified 2 Feb 2014
by Scott Fitzgerald
This example code is in the public domain.
created Nov 2010
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
modified 2 Feb 2014
by Scott Fitzgerald
*/
This example code is in the public domain.
*/
#include <SPI.h>
#include <SD.h>
File root;
void setup()
{
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
@ -49,33 +48,32 @@ void setup()
Serial.println("done!");
}
void loop()
{
void loop() {
// nothing happens after setup finishes.
}
void printDirectory(File dir, int numTabs) {
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();
}
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();
}
}