f303k8 wav player
Dependencies: SDFileSystem mbed
Diff: main.cpp
- Revision:
- 2:203d58b06b0f
- Parent:
- 1:7a3f34b2d18b
- Child:
- 3:b3b9c58e08f2
--- a/main.cpp Thu Aug 11 08:29:22 2016 +0000 +++ b/main.cpp Tue Nov 29 12:09:35 2016 +0000 @@ -8,15 +8,13 @@ Ticker flipper; FATFS FatFs; wavPlayerOnDAC wavPlayer(PA_4); -//AnalogOut DACout(PA_4); SDFileSystem sd(PB_5, PB_4, PB_3, PA_11, "sd"); // the pinout on the mbed Cool Components workshop board DigitalOut pin(PA_12); DigitalOut pin2(PB_0); -DigitalIn button(PA_0,PullDown); +DigitalIn button(PF_1,PullDown); BusIn DipSW(PA_10,PA_9,PA_12,PB_0); - void TIM6_IRQHandler() { TIM6ClearInt(); wavPlayer.DACOutProc(); @@ -26,31 +24,51 @@ { FRESULT wavFileResult; FIL fil; - int i,j; + char fileName[10]="0.wav"; + uint8_t oldDipSW=0; + uint8_t oldButton=0; MX_TIM6_Init(); NVIC_SetVector(TIM6_DAC1_IRQn, (uint32_t)&TIM6_IRQHandler); MX_NVIC_Init(); DipSW.mode(PullDown); + f_mount(&FatFs,"",0); + printf("power ON \r\n"); + wavFileResult = f_open(&fil, "0.wav",FA_READ); - f_mount(&FatFs,"",0); -// wavFileResult = f_open(&fil, "LondonCalling_44k16bitMono.wav", FA_READ); -// wavFileResult = f_open(&fil, "LondonCalling_44k8bitMono.wav", FA_READ); - wavFileResult = f_open(&fil, "LondonCalling_44k16bitStreo.wav", FA_READ); - printf("error:%d\r\n",(int)wavFileResult); - wavPlayer.setFile(&fil); - printf("buff ok\r\n"); - while(button == 1) + while(1) { - } - printf("start\r\n"); - while(1) { + while(button.read() == 0) + { + } + if(oldDipSW != DipSW.read()) + { + f_close(&fil); + fileName[0] = DipSW.read()+0x30; + printf("name:%s\r\n",fileName); + wavFileResult = f_open(&fil, fileName, FA_READ); + } + oldDipSW = DipSW.read(); + printf("error:%d\r\n",(int)wavFileResult); + wavPlayer.setFile(&fil); + printf("start\r\n"); + wavPlayer.rampUp(); + oldButton = button.read(); + while(wavPlayer.readProc() == 0) + { + if(button.read() == 1 && oldButton == 0) + { + break; + } + oldButton = button.read(); + } + printf("END\r\n"); + wavPlayer.rewind(); + wavPlayer.rampDown(); + while(button.read() == 1 && oldButton == 1) + { + } - if(wavPlayer.readProc() == 1) - { - printf("END\r\n"); - wavPlayer.rewind(); - } } } \ No newline at end of file