Test
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
Fork of rtos_basic by
Revision 12:0db14346f701, committed 2017-10-13
- Comitter:
- elee328
- Date:
- Fri Oct 13 22:24:05 2017 +0000
- Parent:
- 11:0309bef74ba8
- Commit message:
- asd
Changed in this revision
diff -r 0309bef74ba8 -r 0db14346f701 4DGL-uLCD-SE.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/4DGL-uLCD-SE.lib Fri Oct 13 22:24:05 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/4180_1/code/4DGL-uLCD-SE/#2cb1845d7681
diff -r 0309bef74ba8 -r 0db14346f701 SDFileSystem.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Fri Oct 13 22:24:05 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec
diff -r 0309bef74ba8 -r 0db14346f701 main.cpp --- a/main.cpp Wed Feb 15 14:04:02 2017 -0600 +++ b/main.cpp Fri Oct 13 22:24:05 2017 +0000 @@ -1,22 +1,117 @@ #include "mbed.h" #include "rtos.h" +#include "wave_player.h" +#include "SDFileSystem.h" +#include "uLCD_4DGL.h" DigitalOut led1(LED1); DigitalOut led2(LED2); -Thread thread; - -void led2_thread() { + +AnalogOut DACout(p18); +wave_player waver(&DACout); +uLCD_4DGL uLCD(p28, p27, p29); // serial tx, serial rx, reset pin; +SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card +PwmOut red(p25); +PwmOut green(p24); +PwmOut blue(p23); + + + +Mutex lcd_mutex; + +FILE *wave_file; + +int height = 15; +int height2 = 15; + +FILE *fp; +void wav_thread() { + while (true) { - led2 = !led2; + bool play = true; + int vol = 1; + fp = fopen("/sd/wavfiles/tt.wav", "r"); + waver.play(fp, &play, &vol); Thread::wait(1000); + + } } +void lcd_thread1() + { + while (true) + { + for (int x = 0; x < 13; x++) + { + lcd_mutex.lock(); + uLCD.filled_circle(25,height,15,BLACK); + height += 7; + uLCD.filled_circle(25,height,15,WHITE); + lcd_mutex.unlock(); + Thread::wait(100); + } + for (int x = 0; x < 13; x++) + { + lcd_mutex.lock(); + uLCD.filled_circle(25,height,15,BLACK); + height -= 7; + uLCD.filled_circle(25,height,15,WHITE); + lcd_mutex.unlock(); + Thread::wait(100); + } + } + } + void lcd_thread2() + { + while (true) + { + for (int x = 0; x < 13; x++) + { + lcd_mutex.lock(); + uLCD.filled_circle(60,height2,15,BLACK); + height2 += 7; + uLCD.filled_circle(60,height2,15,WHITE); + lcd_mutex.unlock(); + Thread::wait(100); + } + for (int x = 0; x < 13; x++) + { + lcd_mutex.lock(); + uLCD.filled_circle(60,height2,15,BLACK); + height2 -= 7; + uLCD.filled_circle(60,height2,15,WHITE); + lcd_mutex.unlock(); + Thread::wait(100); + } + } + } int main() { - thread.start(led2_thread); + + + + + //uLCD.cls(); + + Thread thread1; + Thread thread2; + Thread thread3; + thread1.start(lcd_thread2); + thread2.start(lcd_thread1); + thread3.start(wav_thread); while (true) { - led1 = !led1; - Thread::wait(500); + for (float x=0.45; x >= 0; x -= 0.025) { + red = x; + green = x; + blue = x; + Thread::wait(100); + } + for (float x = 0; x <= 0.45; x += 0.025) { + red = x; + green = x; + blue = x; + Thread::wait(100); + } } }
diff -r 0309bef74ba8 -r 0db14346f701 wave_player.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wave_player.lib Fri Oct 13 22:24:05 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/sravet/code/wave_player/#acc3e18e77ad