Skip to content

Commit

Permalink
Merge pull request #117 from per1234/format-ref-code
Browse files Browse the repository at this point in the history
Format demo code in reference
  • Loading branch information
per1234 authored Apr 25, 2022
2 parents aa96633 + 320c019 commit 619fe19
Showing 1 changed file with 48 additions and 48 deletions.
96 changes: 48 additions & 48 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -669,29 +669,29 @@ 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);
}
}
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);
}
}
}
```

Expand Down Expand Up @@ -745,7 +745,7 @@ void setup() {
delay(2000);
Serial.println();
Serial.println("Rewinding, and repeating below:" );
Serial.println("Rewinding, and repeating below:");
Serial.println();
delay(2000);
Expand All @@ -761,7 +761,7 @@ void loop() {
void printDirectory(File dir, int numTabs) {
while (true) {
File entry = dir.openNextFile();
if (! entry) {
if (!entry) {
if (numTabs == 0)
Serial.println("** Done **");
return;
Expand Down Expand Up @@ -841,29 +841,29 @@ void loop() {
}
void printDirectory(File dir, int numTabs) {
while(true) {
File entry = dir.openNextFile();
if (! entry) {
// No more files
// Return to the first file in the directory
dir.rewindDirectory();
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);
}
}
while (true) {
File entry = dir.openNextFile();
if (!entry) {
// No more files
// Return to the first file in the directory
dir.rewindDirectory();
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);
}
}
}
```

Expand Down

0 comments on commit 619fe19

Please sign in to comment.