Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating examples. Adding example code into examples folder by request.
- Loading branch information
NachtRaveVL
committed
Mar 20, 2017
1 parent
daf566b
commit 8e580b1
Showing
6 changed files
with
277 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
examples/CombinationPlaybackExample/CombinationPlaybackExample.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// BY8X01-16P-Arduino Combination Playback Example | ||
// In this example, files are loaded onto the MicroSD and queued using the special | ||
// playFileIndex method, which allows up to 10 songs to be queued for playback. Index is | ||
// prescribed by the FAT file system, and is generally in the order that the files were | ||
// copied to the flash drive, but not guaranteed. Indexing runs across all files in every | ||
// subfolder. A file sorter software program (such as "DriveSort" or "FAT32 Sorter") | ||
// should be used if specific file index order for playback is required. | ||
|
||
#include "BY8X01-16P.h" | ||
|
||
BY8X0116P audioController; // Library using default Serial1 UART and no busy pin hookup | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
|
||
Serial1.begin(9600); // Serial1 must be started first - only supported UART baud rate is 9600 | ||
|
||
audioController.init(); // Initializes module | ||
|
||
audioController.setEqualizerProfile(BY8X0116P_EqualizerProfile_Rock); // Sets player equalizer profile to Rock | ||
|
||
audioController.playFileIndex(0); // Queues first file on MicroSD card for playback | ||
audioController.playFileIndex(1); // Queues second file on MicroSD card for playback | ||
audioController.playFileIndex(2); // Queues third file on MicroSD card for playback | ||
audioController.playFileIndex(3); // Queues fourth file on MicroSD card for playback | ||
audioController.playFileIndex(4); // Queues fifth file on MicroSD card for playback | ||
|
||
audioController.waitPlaybackFinished(); // Blocking call that waits until all songs have completed | ||
|
||
Serial.println("All done!"); | ||
} |
43 changes: 43 additions & 0 deletions
43
examples/IndexedPlaybackExample/IndexedPlaybackExample.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// BY8X01-16P-Arduino Indexed Playback Example | ||
// In this example, folders are named "00" through "99" and files inside them are named | ||
// "001.mp3" (or .wav) through "255.mp3" (or .wav). The folder and file index passed into | ||
// playFolderFileIndex will play that specific file. Note that combination play here is | ||
// not supported so waiting between track plays is required. Having a busy pin connected | ||
// here will allow for tighter timing control between file playbacks. | ||
|
||
#include "BY8X01-16P.h" | ||
|
||
const byte busyPin = 22; | ||
BY8X0116P audioController(Serial1, busyPin); // Library using Serial1 UART and busy pin input D22 | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
|
||
Serial1.begin(9600); // Serial1 must be started first - only supported UART baud rate is 9600 | ||
|
||
audioController.init(); // Initializes module | ||
|
||
audioController.playFolderFileIndex(0, 1); // Plays "00\001.mp3" | ||
|
||
int numTracks = getNumberOfTracksInCurrentFolder(); // Gets number of tracks in current folder | ||
Serial.println(numTracks); // Should display number of tracks in the "00" folder | ||
|
||
char buffer[12]; | ||
audioController.getCurrentTrackFilename(buffer); // Gets current filename (in 8.3 format) and places it into buffer | ||
|
||
Serial.println(buffer); // Should display "001.mp3" | ||
|
||
audioController.waitBusy(); // Blocking call that waits until all songs have completed | ||
|
||
// Plays all the remaining songs in the entire folder, printing out their file name upon playback | ||
for (int i = 2; i <= numTracks; ++i) { | ||
audioController.playFolderFileIndex(0, i); | ||
|
||
audioController.getCurrentTrackFilename(buffer); | ||
Serial.println(buffer); | ||
|
||
audioController.waitBusy(); | ||
} | ||
|
||
Serial.println("All done!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// BY8X01-16P-Arduino Module Info | ||
// If one uncomments the BY8X0116P_ENABLE_DEBUG_OUTPUT define in the libraries main | ||
// header file (thus enabling debug output) the printModuleInfo() method becomes | ||
// available, which will display information about the module itself, including | ||
// initalized states, register values, current settings, etc. All calls being made will | ||
// display internal debug information about the structure of the call itself. | ||
|
||
// Uncomment this define to enable debug output. | ||
#define BY8X0116P_ENABLE_DEBUG_OUTPUT 1 | ||
|
||
#include "BY8X01-16P.h" | ||
|
||
BY8X0116P audioController; | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
|
||
audioController.printModuleInfo(); | ||
} |
Oops, something went wrong.