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.
Dependencies: mbed wave_player mbed-rtos 4DGL-uLCD-SE RTOS FATFileSystem
Diff: main.cpp
- Revision:
- 11:50e44c84411c
- Parent:
- 10:21943bd35341
- Child:
- 12:0fe16c716237
--- a/main.cpp Fri Dec 05 18:16:56 2014 +0000
+++ b/main.cpp Tue Feb 20 17:54:41 2018 +0000
@@ -1,6 +1,11 @@
#include "mbed.h"
-#include "USBHostMSD.h"
+#include "rtos.h"
+#include "SDFileSystem.h"
#include "wave_player.h"
+
+
+SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
+
//LED lighting effects with sound using the RTOS
//Plays the wave file "sample.wav" on the USB flash drive
//using waveplayer code library
@@ -142,26 +147,20 @@
}
}
-//wave player plays a *.wav file to D/A and a PWM
-wave_player waver(&DACout,&PWMout);
+//wave player plays a *.wav file to D/A
+wave_player waver(&DACout);
int main()
{
- USBHostMSD msd("usb");
+
FILE *wave_file;
- //setup PWM hardware for a Class D style audio output
- PWMout.period(1.0/400000.0);
- // wait until connected to a USB device
- while(!msd.connect()) {
- Thread::wait(750);
- }
while(1) {
{
//Lighthouse demo with foghorn
Thread thread(lighthouse); //Start LED effect thread
for(int i=0; i<4; ++i) {
//open wav file and play it
- wave_file=fopen("/usb/foghorn.wav","r");
+ wave_file=fopen("/sd/foghorn.wav","r");
waver.play(wave_file); //Plays (*.wav file
fclose(wave_file);
Thread::wait(1925);
@@ -174,7 +173,7 @@
//Arc Welding with sound
Thread thread(welding);
//open wav file and play it
- wave_file=fopen("/usb/welding.wav","r");
+ wave_file=fopen("/sd/welding.wav","r");
waver.play(wave_file);
fclose(wave_file);
//end of welding demo;
@@ -185,7 +184,7 @@
//code block forces thread out of scope
Thread thread(police);
//open wav file and play it
- wave_file=fopen("/usb/emgsiren.wav","r");
+ wave_file=fopen("/sd/emgsiren.wav","r");
waver.play(wave_file);
fclose(wave_file);
//end of police light demo;
@@ -195,7 +194,7 @@
//Fire with sound
Thread thread(fire);
//open wav file and play it
- wave_file=fopen("/usb/fire.wav","r");
+ wave_file=fopen("/sd/fire.wav","r");
waver.play(wave_file);
fclose(wave_file);
//end of fire demo;
@@ -206,7 +205,7 @@
//RR Crossing Lights with Signal Bells
Thread thread(rrcrossing);
//open wav file and play it
- wave_file=fopen("/usb/SignalBell.wav","r");
+ wave_file=fopen("/sd/SignalBell.wav","r");
waver.play(wave_file);
fclose(wave_file);
//end of railroad crossing demo;