// first file is at index 1 char* file_at_index(int index) { static char name[13]; card.reset_dir(); while (index) { if (!card.get_next_name_in_dir(name)) { card.reset_dir(); return NULL; } index--; } return name; }
void ls() { char name[13]; int ret; card.reset_dir(); putstring_nl("Files found:"); while (1) { ret = card.get_next_name_in_dir(name); if (!ret) { card.reset_dir(); return; } Serial.println(name); } }
void loop() { uint8_t i, r; char c, name[15]; card.reset_dir(); // scroll through the files in the directory for (i=0; i<tracknum+1; i++) { r = card.get_next_name_in_dir(name); if (!r) { // ran out of tracks! start over tracknum = 0; return; } } putstring("\n\rPlaying "); Serial.print(name); // reset the directory so we can find the file card.reset_dir(); playcomplete(name); tracknum++; }
void loop() { if (!wave.isplaying) { // dump to the serial port just for grins ls(); delay (1000); char * filename = file_at_index(last_played); if (filename == NULL) { last_played = 1; } else { Serial.print("Playing file"); Serial.println(filename); card.reset_dir(); playfile(filename); last_played++; } } }