Complete Build
Dependencies: 4DGL-uLCD-SE1 Motor SDFileSystem X_NUCLEO_53L0A1 mbed-rtos mbed BotwithWavePlayerLevel
Fork of BotWithBluetoothLIDARV2 by
Diff: main.cpp
- Revision:
- 13:ab6bbdd2447a
- Parent:
- 12:af37c8938aaf
- Child:
- 14:cc2e4fbaffd8
--- a/main.cpp Fri Oct 06 01:20:24 2017 +0000 +++ b/main.cpp Fri Oct 06 04:33:17 2017 +0000 @@ -3,8 +3,9 @@ #include "uLCD_4DGL.h" #include "SDFileSystem.h" #include "wave_player.h" +//nclude "picojpeg.h" - +Serial blues(p13,p14); SDFileSystem sd(p5, p6, p7, p9, "sd"); //SD card AnalogOut DACout(p18); @@ -17,21 +18,30 @@ PwmOut myled(LED1); uLCD_4DGL uLCD(p28,p27,p30); - +Mutex ourMutex; Thread thread2; Thread thread3; Thread thread4; +Thread thread5; float y=0.0; + int c=80; + int d=1; +char bnum=0; +char current='1'; +int color=YELLOW; void t2() { while (true) { int a=20; int r=8; + + ourMutex.lock(); uLCD.background_color(BLACK); uLCD.cls(); uLCD.filled_circle(a, 80-(y*80)+25, r, BLUE); uLCD.line(3,25,13,25,RED); uLCD.line(3,105,13,105,RED); + ourMutex.unlock(); //while(b<100){ // uLCD.filled_circle(a, b, r, BLUE); @@ -56,25 +66,88 @@ void t3() { while (true) { - - Thread::wait(1000); + FILE *wave_file; + + wave_file=fopen("/sd/Bee Gees - Stayin' Alive.wav","r"); + waver.play(wave_file); + fclose(wave_file); + Thread::wait(1000); } } void t4() { while (true) { + + ourMutex.lock(); - Thread::wait(1000); + if(c==70){ + d=20; + } + if(c==110){ + d=-20; + } + + uLCD.filled_circle(c, 64 , 10, WHITE); + uLCD.filled_circle(c, 64 , 8, color); + Thread::wait(50); + uLCD.filled_circle(c, 64 , 10, BLACK); + c=c+d; + uLCD.filled_circle(c, 64 , 10, color); + uLCD.filled_circle(c, 64 , 8, WHITE); + Thread::wait(50); + uLCD.filled_circle(c, 64 , 10, BLACK); + + ourMutex.unlock(); + Thread::wait(50); } } +void t5(){ + + while(true){ + + + if(blues.readable()==1){ + ourMutex.lock(); + if (blues.getc()=='!') { + if (blues.getc()=='B') { //button data + bnum = blues.getc(); //button number + if ((bnum>='1')&&(bnum<='4')) //is a number button 1..4 + current=bnum; + } + } + + } + + if(current=='1'){ + color=YELLOW; + } + if(current=='2'){ + color=BLUE; + } + if(current=='3'){ + color=0x551A8B; + } + if(current=='4'){ + color=GREEN; + } + + ourMutex.unlock(); + + Thread::wait(50); + } + + } + + + int main() { thread2.start(t2); thread3.start(t3); thread4.start(t4); - + thread5.start(t5); while(1) { for(double x=0.0; x <= 3.14159; x = x + 0.0314159) {