58 lines
1.1 KiB
C++
58 lines
1.1 KiB
C++
#include "storage.h"
|
|
|
|
File root;
|
|
|
|
|
|
void printDirectory(File dir, int numTabs) {
|
|
// Begin at the start of the directory
|
|
dir.rewindDirectory();
|
|
|
|
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'); // we'll have a nice indentation
|
|
}
|
|
// Print the 8.3 name
|
|
Serial.print(entry.name());
|
|
// Recurse for directories, otherwise print the file size
|
|
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();
|
|
}
|
|
}
|
|
|
|
void initStorage(void)
|
|
{
|
|
if(!SD.begin(A5))
|
|
{
|
|
Serial.println("Failed to init SDcard");
|
|
}
|
|
|
|
root = SD.open("/");
|
|
}
|
|
|
|
void handleStorage(void)
|
|
{
|
|
//printDirectory(root, 0);
|
|
|
|
}
|
|
|
|
File getmusicFile(void)
|
|
{
|
|
if(SD.exists("/003.WAV"))
|
|
{
|
|
return SD.open("/003.WAV");
|
|
}
|
|
}
|