テスト
Dependencies: C12832 USBHost mbed MMA7660 wave_player
Fork of app-board-Speaker by
Diff: main.cpp
- Revision:
- 16:12f30425ba88
- Parent:
- 15:46ca600425fc
- Child:
- 17:9e07a9ff6e91
--- a/main.cpp Tue Dec 13 08:02:54 2016 +0000 +++ b/main.cpp Tue Dec 13 09:17:26 2016 +0000 @@ -46,6 +46,8 @@ InterruptIn push(p14); InterruptIn right(p16); InterruptIn left(p13); +FILE *wave_file; +Mutex stdio_mutex; int i=0; int count = 0; @@ -53,12 +55,21 @@ int i_for20mm; int i_for20mm_old = 0; int scale = 0; +bool printflag = false; float mm[]={mC,mD,mE,mF,mG,mA,mB,mC*2,mD*2,mE*2,mF*2,mG*2,mA*2,mB*2,mC*4}; float mmm[]={mC,mD,mE,mF,mG,mA,mB,mC*2,mD*2,mE*2,mF*2,mG*2,mA*2,mB*2,mC*4, mD*4,mE*4,mF*4,mG*4,mA*4,mB*4};//has 21 float notes[NUM_OF_SCALE][NUM_OF_NOTES] = { {mC,mD,mE,mF,mG,mA,mB,mC*2,mD*2,mE*2,mF*2,mG*2,mA*2,mB*2,mC*4, mD*4,mE*4,mF*4,mG*4,mA*4,mB*4}, - {mC,mC,mC,mC,mC,mC,mC,mC,mC,mC,mF*2,mG*2,mA*2,mB*2,mC*4, mD*4,mE*4,mF*4,mG*4,mA*4,mB*4}}; + {mC,mC,mC,mC,mC,mC,mC,mC,mC,mC,mF*2,mG*2,mA*2,mB*2,mC*4, mD*4,mE*4,mF*4,mG*4,mA*4,mB*4}}; +void printlcd(void) +{ + stdio_mutex.lock(); + lcd.locate(10,10); + lcd.printf("scale %d", scale); + printflag=false; + stdio_mutex.unlock(); +} void intRise(void) { if(for_chat.read_ms()>THRESH); @@ -108,9 +119,8 @@ { scale++; } - //lcd.locate(10,10); - //lcd.printf("scale %d", scale); } + printflag=true; for_chat.reset(); } @@ -125,8 +135,7 @@ { scale--; } - //lcd.locate(10,10); - //lcd.printf("scale %d", scale); + printflag=true; } for_chat.reset(); } @@ -383,6 +392,10 @@ } for_chat.reset(); + if(printflag) + { + printlcd(); + } ///////////////////////////// //for debug @@ -392,8 +405,22 @@ Thread::wait(50); } } - - +void wave_file_player(void const *argument) + { + waver.play(wave_file); + fclose(wave_file); + //wave_finished = true; +} +//void lcd_thread(void const *argument) +//{ +// stdio_mutex.lock(); +// lcd.locate(0,0); +// lcd.printf("scale = %d", scale); +// //lcd.cls(); +// stdio_mutex.unlock(); +// Thread::wait(50); +// +//} int main() { wait(0.01); @@ -409,9 +436,9 @@ //Thread thread1(r_thread,(void *)"Th 1"); //Thread thread2(g_thread,(void *)"Th 2"); //Thread thread3(b_thread,(void *)"Th 3"); - //Thread thread4(count_thread,(void *)"Th 4"); - //Thread thread5(acc_thread,(void *)"Th 5"); - Thread thread6(disp_thread, (void *)"Th 6"); + //Thread thread4(count_thread,(void *)"Th 4"); + Thread thread6(disp_thread); + //Thread thread4(lcd_thread); //Thread thread7(sound_thread, (void *)"Th 7"); //for USB @@ -422,17 +449,21 @@ } //for music file - FILE *wave_file; + //FILE *wave_file; //sp1.period(1.0 / 16000.0); + stdio_mutex.lock(); wave_file = fopen("/usb/music/BGMforMBED2.wav", "r"); + + stdio_mutex.unlock(); waver.play(wave_file); - fclose(wave_file); + fclose(wave_file); + lcd.cls(); wait(0.01); while(1) { - //lcd.cls(); + } }