Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SD record and list functions #278

Open
jshoek opened this issue Dec 29, 2018 · 1 comment
Open

SD record and list functions #278

jshoek opened this issue Dec 29, 2018 · 1 comment

Comments

@jshoek
Copy link

jshoek commented Dec 29, 2018

Having trouble listing pre-recorded songs from SD card using Audio Shield Board. Songs can be played fine, but would like to list them on ILI9341 LCD screen. I found the following code for listing files from the SD documentation of functions, but it always returns empty. Wondering if this is even the correct code to use with the Audio Shield Board. Does anyone know if this works? If not, any recommendations?

This part is in setup:

root = SD.open("/");
printDirectory(root, 0);
Serial.println("done!");

This is the subroutine:

void printDirectory(File dir, int numTabs) {
while (true) {

File entry =  dir.openNextFile();
if (! entry) {
  // no more files
  Serial.print("No more files, last entry = "); Serial.println(numTabs);
  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();

}

Hardware & Software

Board Teensy 3.2
Audio Shield Board
Arduino IDE version 1.8.5
Teensyduino version 1.42

@FrankBoesing
Copy link
Contributor

FrankBoesing commented Dec 30, 2018

Please ask in the forum, here is is wrong place for questions, and this has nothing to do with the audio library - its the SD library. Then, please post the complete code in the forum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants