Advanced Operating Systems - Final Project A @ Tokyo Tech ////////////// Author: Chu Van Thiem and Sidik Soleman ////////////// A WAVE file player on the MBED Application Board with an interface to a software on PC via a TCP connection. ////////////// Main functions: 1. Browse files of an attached USB flash 2. The list of the files of the attached USB are displayed on the LCD 3. Use an joystick to select a WAVE file and give an instruction to play that file 4. Adjust the volume using a potentiometer 5. Output audio to the analog audio out jack ////////////// Software (https://github.com/thiemcv/VS/tree/master/Terminal): 1. Connect with the MBED application board via Ethernet connection 2. Read the list of files stored on the USB flash 3. Write files to the USB flash

Dependencies:   C12832_lcd EthernetInterface USBHost mbed-rtos mbed wave_player

Committer:
aos
Date:
Sun Feb 02 10:49:19 2014 +0000
Revision:
1:3b567aa3b09e
Child:
2:5bc47e544b8d
Final Project V1: Integrated WAV player + USB file management via ethernet connection

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aos 1:3b567aa3b09e 1 #include "player.h"
aos 1:3b567aa3b09e 2
aos 1:3b567aa3b09e 3 C12832_LCD lcd;
aos 1:3b567aa3b09e 4 AnalogOut DACout(p18);
aos 1:3b567aa3b09e 5 /* joystick location */
aos 1:3b567aa3b09e 6 DigitalIn Up(p15);
aos 1:3b567aa3b09e 7 DigitalIn Down(p12);
aos 1:3b567aa3b09e 8 DigitalIn Left(p13);
aos 1:3b567aa3b09e 9 DigitalIn Right(p16);
aos 1:3b567aa3b09e 10 DigitalIn Play(p14);
aos 1:3b567aa3b09e 11 AnalogIn ain(p19);
aos 1:3b567aa3b09e 12
aos 1:3b567aa3b09e 13 Ticker ticker;
aos 1:3b567aa3b09e 14 Ticker tickervolume;
aos 1:3b567aa3b09e 15 int joyup=0,joydown=0,joyplay=0;
aos 1:3b567aa3b09e 16 wave_player waver(&DACout);
aos 1:3b567aa3b09e 17 volatile int joyvalue=0;
aos 1:3b567aa3b09e 18 float aout = 0;
aos 1:3b567aa3b09e 19 FILE *wave_file;
aos 1:3b567aa3b09e 20
aos 1:3b567aa3b09e 21 // Custom Function
aos 1:3b567aa3b09e 22 void play(char* song){
aos 1:3b567aa3b09e 23 wave_file=fopen(song,"r");
aos 1:3b567aa3b09e 24 waver.play(wave_file);
aos 1:3b567aa3b09e 25 fclose(wave_file);
aos 1:3b567aa3b09e 26 }
aos 1:3b567aa3b09e 27
aos 1:3b567aa3b09e 28 void welcome(){
aos 1:3b567aa3b09e 29 lcd.cls();
aos 1:3b567aa3b09e 30 lcd.locate(15,0);
aos 1:3b567aa3b09e 31 lcd.printf("MBED Player");
aos 1:3b567aa3b09e 32 Thread::wait(1);
aos 1:3b567aa3b09e 33 lcd.cls();
aos 1:3b567aa3b09e 34 }
aos 1:3b567aa3b09e 35
aos 1:3b567aa3b09e 36 void print(vector<string> *listoffile, int current){
aos 1:3b567aa3b09e 37 lcd.cls();
aos 1:3b567aa3b09e 38 int nsong = listoffile->size();
aos 1:3b567aa3b09e 39 lcd.locate(0,0);
aos 1:3b567aa3b09e 40 lcd.printf("Song Title (%d/%d)",(current+1),nsong);
aos 1:3b567aa3b09e 41 lcd.locate(0,9);
aos 1:3b567aa3b09e 42 lcd.printf("-------------------------------");
aos 1:3b567aa3b09e 43 if (nsong == 0){
aos 1:3b567aa3b09e 44 lcd.locate(0,15);
aos 1:3b567aa3b09e 45 lcd.printf("No File Song");
aos 1:3b567aa3b09e 46 } else {
aos 1:3b567aa3b09e 47 lcd.printf("> %s",(listoffile->at(current)).c_str());
aos 1:3b567aa3b09e 48 }
aos 1:3b567aa3b09e 49 }
aos 1:3b567aa3b09e 50
aos 1:3b567aa3b09e 51 /* JoyValue = 1: up, 2: down, 3: play */
aos 1:3b567aa3b09e 52 void joystickcontrol(){
aos 1:3b567aa3b09e 53 if (Up){
aos 1:3b567aa3b09e 54 if (joyup<NSAMPLE) joyup++;
aos 1:3b567aa3b09e 55 if (joyup==NSAMPLE){ joyvalue=1; joyup=0;}
aos 1:3b567aa3b09e 56 }
aos 1:3b567aa3b09e 57 if (Down){
aos 1:3b567aa3b09e 58 if (joydown<NSAMPLE) joydown++;
aos 1:3b567aa3b09e 59 if (joydown==NSAMPLE) { joyvalue=2; joydown = 0;}
aos 1:3b567aa3b09e 60 }
aos 1:3b567aa3b09e 61 if (Play){
aos 1:3b567aa3b09e 62 if (joyplay<NSAMPLE) joyplay++;
aos 1:3b567aa3b09e 63 if (joyplay==NSAMPLE) { joyvalue=3; joyplay=0;}
aos 1:3b567aa3b09e 64 }
aos 1:3b567aa3b09e 65 }
aos 1:3b567aa3b09e 66
aos 1:3b567aa3b09e 67 void controlvolume(){
aos 1:3b567aa3b09e 68 waver.volume = (float)ain;
aos 1:3b567aa3b09e 69 }