Skip to content

Commit 619fe19

Browse files
authored
Merge pull request #117 from per1234/format-ref-code
Format demo code in reference
2 parents aa96633 + 320c019 commit 619fe19

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

docs/api.md

+48-48
Original file line numberDiff line numberDiff line change
@@ -669,29 +669,29 @@ void loop() {
669669
}
670670
671671
void printDirectory(File dir, int numTabs) {
672-
while(true) {
673-
674-
File entry = dir.openNextFile();
675-
if (! entry) {
676-
// No more files
677-
// Serial.println("**nomorefiles**");
678-
break;
679-
}
680-
681-
for (uint8_t i=0; i<numTabs; i++) {
682-
Serial.print('\t');
683-
}
684-
685-
Serial.print(entry.name());
686-
if (entry.isDirectory()) {
687-
Serial.println("/");
688-
printDirectory(entry, numTabs+1);
689-
} else {
690-
// Files have sizes, directories do not
691-
Serial.print("\t\t");
692-
Serial.println(entry.size(), DEC);
693-
}
694-
}
672+
while (true) {
673+
674+
File entry = dir.openNextFile();
675+
if (!entry) {
676+
// No more files
677+
// Serial.println("**nomorefiles**");
678+
break;
679+
}
680+
681+
for (uint8_t i = 0; i < numTabs; i++) {
682+
Serial.print('\t');
683+
}
684+
685+
Serial.print(entry.name());
686+
if (entry.isDirectory()) {
687+
Serial.println("/");
688+
printDirectory(entry, numTabs + 1);
689+
} else {
690+
// Files have sizes, directories do not
691+
Serial.print("\t\t");
692+
Serial.println(entry.size(), DEC);
693+
}
694+
}
695695
}
696696
```
697697

@@ -745,7 +745,7 @@ void setup() {
745745
delay(2000);
746746
747747
Serial.println();
748-
Serial.println("Rewinding, and repeating below:" );
748+
Serial.println("Rewinding, and repeating below:");
749749
Serial.println();
750750
delay(2000);
751751
@@ -761,7 +761,7 @@ void loop() {
761761
void printDirectory(File dir, int numTabs) {
762762
while (true) {
763763
File entry = dir.openNextFile();
764-
if (! entry) {
764+
if (!entry) {
765765
if (numTabs == 0)
766766
Serial.println("** Done **");
767767
return;
@@ -841,29 +841,29 @@ void loop() {
841841
}
842842
843843
void printDirectory(File dir, int numTabs) {
844-
while(true) {
845-
File entry = dir.openNextFile();
846-
if (! entry) {
847-
// No more files
848-
// Return to the first file in the directory
849-
dir.rewindDirectory();
850-
break;
851-
}
852-
853-
for (uint8_t i=0; i<numTabs; i++) {
854-
Serial.print('\t');
855-
}
856-
857-
Serial.print(entry.name());
858-
if (entry.isDirectory()) {
859-
Serial.println("/");
860-
printDirectory(entry, numTabs+1);
861-
} else {
862-
// Files have sizes, directories do not
863-
Serial.print("\t\t");
864-
Serial.println(entry.size(), DEC);
865-
}
866-
}
844+
while (true) {
845+
File entry = dir.openNextFile();
846+
if (!entry) {
847+
// No more files
848+
// Return to the first file in the directory
849+
dir.rewindDirectory();
850+
break;
851+
}
852+
853+
for (uint8_t i = 0; i < numTabs; i++) {
854+
Serial.print('\t');
855+
}
856+
857+
Serial.print(entry.name());
858+
if (entry.isDirectory()) {
859+
Serial.println("/");
860+
printDirectory(entry, numTabs + 1);
861+
} else {
862+
// Files have sizes, directories do not
863+
Serial.print("\t\t");
864+
Serial.println(entry.size(), DEC);
865+
}
866+
}
867867
}
868868
```
869869

0 commit comments

Comments
 (0)