SMARTWAV Audio processor, control the SmartWAV module with communication to a PC via mbed USB Port under an Hyperterminal session 9600/1 stop bit/ no parity/ no flow control
main.cpp@0:34c937ac8da0, 2012-02-12 (annotated)
- Committer:
- emmanuelchio
- Date:
- Sun Feb 12 01:33:00 2012 +0000
- Revision:
- 0:34c937ac8da0
1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emmanuelchio | 0:34c937ac8da0 | 1 | /**************************************************************************************/ |
emmanuelchio | 0:34c937ac8da0 | 2 | /*SMARTWAV intelligent embedded sWav processor unit |
emmanuelchio | 0:34c937ac8da0 | 3 | those examples are for use the SMARTWAV with the mbed microcontoller, just connect tx,rx,and reset |
emmanuelchio | 0:34c937ac8da0 | 4 | Board: |
emmanuelchio | 0:34c937ac8da0 | 5 | http://vizictechnologies.com/#/smart-wav/4559021187 |
emmanuelchio | 0:34c937ac8da0 | 6 | |
emmanuelchio | 0:34c937ac8da0 | 7 | This example requires pre-loaded content to the micro SD card, sWav .WAV files! |
emmanuelchio | 0:34c937ac8da0 | 8 | |
emmanuelchio | 0:34c937ac8da0 | 9 | www.vizictechnologies.com |
emmanuelchio | 0:34c937ac8da0 | 10 | Vizic Technologies copyright 2012 */ |
emmanuelchio | 0:34c937ac8da0 | 11 | /**************************************************************************************/ |
emmanuelchio | 0:34c937ac8da0 | 12 | /**************************************************************************************/ |
emmanuelchio | 0:34c937ac8da0 | 13 | |
emmanuelchio | 0:34c937ac8da0 | 14 | /**************************************************************************************/ |
emmanuelchio | 0:34c937ac8da0 | 15 | //This demo require a mbed connection to a PC with an Hyperterminal sesion opened at 9600bps/1 stop bits/ no parity/flow control none |
emmanuelchio | 0:34c937ac8da0 | 16 | /**************************************************************************************/ |
emmanuelchio | 0:34c937ac8da0 | 17 | |
emmanuelchio | 0:34c937ac8da0 | 18 | #include "mbed.h" |
emmanuelchio | 0:34c937ac8da0 | 19 | #include "SMARTWAV.h" |
emmanuelchio | 0:34c937ac8da0 | 20 | |
emmanuelchio | 0:34c937ac8da0 | 21 | SMARTWAV sWav(p13,p14,p15); //(TX,RX,Reset); |
emmanuelchio | 0:34c937ac8da0 | 22 | |
emmanuelchio | 0:34c937ac8da0 | 23 | Serial pc(USBTX, USBRX); |
emmanuelchio | 0:34c937ac8da0 | 24 | |
emmanuelchio | 0:34c937ac8da0 | 25 | //Global Variables |
emmanuelchio | 0:34c937ac8da0 | 26 | char playList[500]; //an array for storing the retrieved list of Audio files |
emmanuelchio | 0:34c937ac8da0 | 27 | char dirList[500]; //an array for storing the retrieved list of Folders/Dirs |
emmanuelchio | 0:34c937ac8da0 | 28 | |
emmanuelchio | 0:34c937ac8da0 | 29 | |
emmanuelchio | 0:34c937ac8da0 | 30 | /************************************************************************************************/ |
emmanuelchio | 0:34c937ac8da0 | 31 | /************************************************************************************************/ |
emmanuelchio | 0:34c937ac8da0 | 32 | /************************************************************************************************/ |
emmanuelchio | 0:34c937ac8da0 | 33 | /************************************************************************************************/ |
emmanuelchio | 0:34c937ac8da0 | 34 | int main() { |
emmanuelchio | 0:34c937ac8da0 | 35 | char name[9]={0}; |
emmanuelchio | 0:34c937ac8da0 | 36 | |
emmanuelchio | 0:34c937ac8da0 | 37 | sWav.reset(); //physically reset SMARTWAV |
emmanuelchio | 0:34c937ac8da0 | 38 | |
emmanuelchio | 0:34c937ac8da0 | 39 | pc.printf("Welcome to the SmartWAV PC demo! getting microSD contents...\n\r\n\r"); |
emmanuelchio | 0:34c937ac8da0 | 40 | |
emmanuelchio | 0:34c937ac8da0 | 41 | wait_ms(50); |
emmanuelchio | 0:34c937ac8da0 | 42 | sWav.getFolderList(dirList); |
emmanuelchio | 0:34c937ac8da0 | 43 | wait_ms(50); |
emmanuelchio | 0:34c937ac8da0 | 44 | sWav.getFileList(playList); |
emmanuelchio | 0:34c937ac8da0 | 45 | |
emmanuelchio | 0:34c937ac8da0 | 46 | pc.printf("Folders/Dirs:\n\r"); |
emmanuelchio | 0:34c937ac8da0 | 47 | pc.printf(dirList); |
emmanuelchio | 0:34c937ac8da0 | 48 | pc.printf("\n\r\n\r"); |
emmanuelchio | 0:34c937ac8da0 | 49 | pc.printf("Audio Files/Songs:\n\r"); |
emmanuelchio | 0:34c937ac8da0 | 50 | pc.printf(playList); |
emmanuelchio | 0:34c937ac8da0 | 51 | pc.printf("\n\r\n\r"); |
emmanuelchio | 0:34c937ac8da0 | 52 | pc.printf("Press 'T' play, 'P' pause/resume, 'R' rewind, 'N' next song, 'S' stop:(case sensitive)\n\r\n\r"); |
emmanuelchio | 0:34c937ac8da0 | 53 | |
emmanuelchio | 0:34c937ac8da0 | 54 | while (1){ |
emmanuelchio | 0:34c937ac8da0 | 55 | switch(pc.getc()){ |
emmanuelchio | 0:34c937ac8da0 | 56 | case 'T': |
emmanuelchio | 0:34c937ac8da0 | 57 | sWav.playTracks(); |
emmanuelchio | 0:34c937ac8da0 | 58 | break; |
emmanuelchio | 0:34c937ac8da0 | 59 | |
emmanuelchio | 0:34c937ac8da0 | 60 | case 'P': |
emmanuelchio | 0:34c937ac8da0 | 61 | sWav.pausePlay(); |
emmanuelchio | 0:34c937ac8da0 | 62 | wait_ms(500); |
emmanuelchio | 0:34c937ac8da0 | 63 | while(pc.getc()!='P'); //while no 'P' character is pressed again |
emmanuelchio | 0:34c937ac8da0 | 64 | sWav.pausePlay(); |
emmanuelchio | 0:34c937ac8da0 | 65 | break; |
emmanuelchio | 0:34c937ac8da0 | 66 | |
emmanuelchio | 0:34c937ac8da0 | 67 | case 'R': |
emmanuelchio | 0:34c937ac8da0 | 68 | sWav.rewindTrack(); |
emmanuelchio | 0:34c937ac8da0 | 69 | break; |
emmanuelchio | 0:34c937ac8da0 | 70 | |
emmanuelchio | 0:34c937ac8da0 | 71 | case 'N': |
emmanuelchio | 0:34c937ac8da0 | 72 | sWav.nextTrack(); |
emmanuelchio | 0:34c937ac8da0 | 73 | break; |
emmanuelchio | 0:34c937ac8da0 | 74 | |
emmanuelchio | 0:34c937ac8da0 | 75 | case 'S': |
emmanuelchio | 0:34c937ac8da0 | 76 | sWav.stopTrack(); |
emmanuelchio | 0:34c937ac8da0 | 77 | break; |
emmanuelchio | 0:34c937ac8da0 | 78 | |
emmanuelchio | 0:34c937ac8da0 | 79 | default: |
emmanuelchio | 0:34c937ac8da0 | 80 | break; |
emmanuelchio | 0:34c937ac8da0 | 81 | } |
emmanuelchio | 0:34c937ac8da0 | 82 | wait_ms(500); |
emmanuelchio | 0:34c937ac8da0 | 83 | pc.printf("Current Song Name:"); |
emmanuelchio | 0:34c937ac8da0 | 84 | sWav.getFileName(name); |
emmanuelchio | 0:34c937ac8da0 | 85 | pc.printf(name); |
emmanuelchio | 0:34c937ac8da0 | 86 | pc.printf(" play Status:"); |
emmanuelchio | 0:34c937ac8da0 | 87 | if(sWav.getStatus()){ |
emmanuelchio | 0:34c937ac8da0 | 88 | pc.printf("Active "); |
emmanuelchio | 0:34c937ac8da0 | 89 | }else{ |
emmanuelchio | 0:34c937ac8da0 | 90 | pc.printf("non Active "); |
emmanuelchio | 0:34c937ac8da0 | 91 | } |
emmanuelchio | 0:34c937ac8da0 | 92 | pc.printf("\r"); |
emmanuelchio | 0:34c937ac8da0 | 93 | wait_ms(500); |
emmanuelchio | 0:34c937ac8da0 | 94 | } |
emmanuelchio | 0:34c937ac8da0 | 95 | } |