Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of RapidMP3_check by
main.cpp
- Committer:
- vasanth
- Date:
- 2014-11-21
- Revision:
- 0:a540b792fbf0
- Child:
- 1:dbb63bd6c828
File content as of revision 0:a540b792fbf0:
#include "mbed.h"
#include "RAPIDMP3.h"
RAPIDMP3 rmp3(D8, D2); /// Tx, Rx
Serial pc(USBTX, USBRX);
int main() {
wait(1.0);
pc.puts("RAPID_MP3_V1 module demonstration\r\n");
while (1) {
// Play track till its end
rmp3.playFile("munthi.mp3");
rmp3.waitEndOfPlay();
// Play track for a specified duration
rmp3.playFile("sempove.mp3");
wait(20.0);
rmp3.stop();
wait(5.0);
// Play, pause and resume a track
rmp3.playFile("karug.mp3");
wait(10.0);
rmp3.playPause();
wait(5.0);
rmp3.playResume();
wait(5.0);
// Set volume level to 2
rmp3.volumeSet(2); // 0 is max, 9 is mute
wait(5.0);
// Increase volume one level
rmp3.volumeInc();
wait(5.0);
// Decrease volume one level
rmp3.volumeDec();
wait(5.0);
// Read and display current volume level in PC UART
uint8_t volume = rmp3.volumeGet();
pc.printf("current volume level = %d\r\n", volume);
wait(5.0);
// Read the playback status
uint8_t playStatus = rmp3.getPlaybackStatus();
if (playStatus == RMP3_BUSY) {
pc.puts("Device is busy\r\n");
// Stop the current playback
rmp3.stop();
wait(5.0);
}
pc.puts("Device is free\r\n");
wait(5.0);
// Record audio as .wav file for a specified time
rmp3.recordFile("rec_001.wav");
wait(20.0);
rmp3.stop();
// Play the recorded audio till its end
rmp3.playFile("rec_001.wav");
rmp3.waitEndOfPlay();
wait(5.0);
// loop again.
}
}
//DigitalOut myled(LED1);
///** Send Rapid MP3 response to PC */
//static void sendResponse(uint8_t response) {
// if (response == RMP3_OK) {
// pc.puts("OK\r\n");
// } else if (response == RMP3_ER) {
// pc.puts("ER\r\n");
// /// error in command
// while (1) {
// myled = !myled;
// wait(0.2f);
// }
// }
//}
//int main() {
//
// /** Application Code.....*/
// uint8_t response;
//
// pc.puts("RAPID_MP3_V1\r\n");
//
//
// /** Wait for RMP3 module Initialization (LED1 Indication) */
// response = rmp3.waitDeviceFree();
// pc.puts("Initialized Successfully\r\n");
// sendResponse(response);
// myled = 1;
// wait(1.0f);
//
//
// /** Check RMP3 module communication */
// response = rmp3.checkDevice();
// pc.puts("DEVICE CHECK\r\n");
// sendResponse(response);
// wait(1.0f);
//
//
// while (1) {
//
// /** Play an MP3 file and wait till it gets completed */
// response = rmp3.playFile("munthi.mp3");
// if (response == RMP3_OK) {
// pc.puts("TRACK 1 started...\r\n");
// rmp3.waitEndOfPlay();
// pc.puts("TRACK 1 ended\r\n");
// }
// sendResponse(response);
// wait(1.0f);
//
//
// /** Play an MP3 file and stop it after 20 seconds */
// response = rmp3.playFile("sempove.mp3");
// pc.puts("TRACK 2 started...\r\n");
// sendResponse(response);
// wait(20.0f);
// response = rmp3.stop();
// pc.puts("TRACK 2 stopped after 20 sec\r\n");
// sendResponse(response);
//
// /// wait before looping again...
// wait(5.0f);
//
// }
//
//}
