f
Dependencies: Speaker mbed wave_player mbed-rtos 4DGL-uLCD-SE LCD_fonts SDFileSystem_OldbutworkswithRTOS
Revision 6:bb887c1a381b, committed 2019-02-21
- Comitter:
- apaks180
- Date:
- Thu Feb 21 18:33:54 2019 +0000
- Parent:
- 5:5f393c6b02cb
- Commit message:
- f;
Changed in this revision
diff -r 5f393c6b02cb -r bb887c1a381b SDFileSystem.lib --- a/SDFileSystem.lib Thu Feb 21 16:10:42 2019 +0000 +++ b/SDFileSystem.lib Thu Feb 21 18:33:54 2019 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec +https://developer.mbed.org/users/4180_1/code/SDFileSystem_OldbutworkswithRTOS/#e6c086545857
diff -r 5f393c6b02cb -r bb887c1a381b main.cpp --- a/main.cpp Thu Feb 21 16:10:42 2019 +0000 +++ b/main.cpp Thu Feb 21 18:33:54 2019 +0000 @@ -1,6 +1,3 @@ -// example to test the mbed Lab Board lcd lib with the mbed rtos -// Pot1 changes the contrast -// Pot2 changes the speed of the sin wave #include "mbed.h" #include "rtos.h" @@ -11,100 +8,68 @@ #include "SDFileSystem.h" #include "wave_player.h" + +RawSerial pc(USBTX, USBRX); +RawSerial dev(p28,p27); AnalogOut DACout(p18); wave_player waver(&DACout); SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card uLCD_4DGL uLCD(p13,p14,p11); -//AnalogIn Pot1(p19); -//AnalogIn Pot2(p20); -//Speaker speaker(p26); PwmOut RGBLED_r(p23); PwmOut RGBLED_g(p24); PwmOut RGBLED_b(p25); -//DigitalIn joyfire(p14); -//BusIn joy(p15,p12,p13,p16); BusOut leds(LED1,LED2,LED3,LED4); - -// mutex to make the lcd lib thread safe Mutex lcd_mutex; -//// Thread 1 -//// print counter into first line and wait for 1 s -void thread1(void const *args) +//Thread screen; +//Thread lights; +//Thread audio; +//Thread count; + +void dev_recv() { - int i; - while(true) { // thread loop - lcd_mutex.lock(); - uLCD.printf("Thread1 count: %d",i); - lcd_mutex.unlock(); - i++; - Thread::wait(1000); + while(dev.readable()) { + pc.putc(dev.getc()); + } +} + +void pc_recv() +{ + while(pc.readable()) { + dev.putc(pc.getc()); } } -// -//// Thread 2 -//// print counter into third line and wait for 0,5s -//void thread2(void const *args) -//{ -// int k; -// while(true) { // thread loop -// lcd_mutex.lock(); -// LCD.locate(0,20); -// LCD.set_font((unsigned char*) Arial_9); -// LCD.printf("Thread 2 count : %d",k); -// lcd_mutex.unlock(); -// k++; -// Thread::wait(500); // wait 0.5s -// } -//} -// -//// Thread 3 -//// print a sin function in a small window -//// the value of pot 1 changes the speed of the sine wave -//void thread3(void const *args) -//{ -// int i,k,v; -// double s,a; -// k = 1; -// lcd_mutex.lock(); -// LCD.rect(89,0,127,17,1); -// lcd_mutex.unlock(); + + + +void thread1(void const *args) +{ + int i=0; + int x; // while(true) { // thread loop -// v = Pot1.read_u16(); // get value of pot 1 -// lcd_mutex.lock(); -// for (i=90; i<127; i++) { -// s = 8 * sin((long double)(i+k) /5); // pixel to print -// a = 8 * sin((long double)(i+k-1) /5); // old pixel to erase -// LCD.pixel(i,9 + (int)a ,0); // erase pixel -// LCD.pixel(i,9 + (int)s ,1); // print pixel -// } -// LCD.copy_to_lcd(); // LCD.pixel does not update the lcd -// lcd_mutex.unlock(); -// k++; -// Thread::wait(v/100); // value of pot1 / 100 + if(i==0){ + x=0xFF0000; + } + else if (i==1){ + x=0xFFFFFF; + } + else{ + x=0x0000FF; + } + lcd_mutex.lock(); + uLCD.filled_rectangle(0,0,128, 100, x); + lcd_mutex.unlock(); + i++; + i=i%3; + Thread::wait(100); // } -//} -// -//// Thread 4 -//// input pot 2 and change the contrast of LCD -//void thread4(void const *args) -//{ -// int k; -// while(true) { // thread loop -// k = Pot2.read_u16(); // get the value of poti 2 -// k = k >> 10; // need only 6 bits for contrast -// lcd_mutex.lock(); -// LCD.set_contrast(k); -// lcd_mutex.unlock(); -// Thread::wait(500); // wait 0.5s -// } -//} -//// Thread 5 -//// RGB LED +} + + void thread5(void const *args) { int i = 0; - while(true) { +// while(true) { // thread loop if(i==0){ RGBLED_r = 1; @@ -124,23 +89,22 @@ i++; i=i%3; Thread::wait(673); // wait 1.5s - } +// } } //// Thread 6 //// Speaker void thread6(void const *args) { - //while(true) { // thread loop -// speaker.PlayNote(311.1, 1, .1); -// Thread::wait(1000); // wait 1.0s -// speaker.PlayNote(0,1,0); -// Thread::wait(1000); -// } - FILE *wave_file; - printf("\n\n\nHello, wave world!\n"); +// while(true) { // thread loop + FILE *wave_file; + printf("\r\n\nHello, wave world!\n\r"); + Thread::wait(1000); wave_file=fopen("/sd/banner2.wav","r"); + if(wave_file==NULL) printf("file open error!\n\n\r"); waver.play(wave_file); fclose(wave_file); +// } + } void thread7(void const *args) @@ -149,36 +113,60 @@ while(true) { // thread loop i++; printf("thread 1: %d\n", i); - Thread::wait(200); // wait 0.25s + Thread::wait(1000); // wait 0.25s } } - +//void bluetooth(void const *args){ +// while(1){ +// if(dev.getc()=='a'){ +// Thread t6(thread6); +// } +// if(dev.getc()=='s'){ +// Thread t1(thread1); +// } +// if(dev.getc()=='l'){ +// Thread t5(thread5); +// } +// if(dev.getc()=='c'){ +// Thread t7(thread7); +// } +// Thread::wait(100); +// } +//} int main() { // int j; uLCD.cls(); - Thread t1(thread1); //start thread1 + pc.baud(9600); + dev.baud(9600); + + pc.attach(&pc_recv, Serial::RxIrq); + dev.attach(&dev_recv, Serial::RxIrq); +// Thread blue(bluetooth); + while(1) { + if(dev.getc()=='a'){ + Thread audio(thread6); + } + if(dev.getc()=='s'){ + Thread screen(thread1); + } + if(dev.getc()=='l'){ + Thread light(thread5); + } + if(dev.getc()=='c'){ + Thread count(thread7); + } +// sleep(); + } +// Thread t1(thread1); //start thread1 //Thread t2(thread2); //start thread2 //Thread t3(thread3); //start thread3 //Thread t4(thread4); //start thread4 - Thread t5(thread5); //start thread5 - Thread t6(thread6); //start thread6 - Thread t7(thread7); //start thread7 +// Thread t5(thread5); //start thread5 +// Thread t6(thread6); //start thread6 +// Thread t7(thread7); //start thread7 - while(true) { // main is the next thread -// speaker.PlayNote(311.1, 1, .1); - //Thread::wait(1000); // wait 1.0s -// speaker.PlayNote(0,1,0); - //Thread::wait(1000); -// lcd_mutex.lock(); -// uLCD.cls(); -// uLCD.media_init(); -// uLCD.set_sector_address(0x001D, 0x4C42); -// uLCD.display_video(0,0); -// lcd_mutex.unlock(); -// Thread::wait(33); // wait 0.5s - } }
diff -r 5f393c6b02cb -r bb887c1a381b mbed-rtos.lib --- a/mbed-rtos.lib Thu Feb 21 16:10:42 2019 +0000 +++ b/mbed-rtos.lib Thu Feb 21 18:33:54 2019 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#ee87e782d34f +http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#02f5cf381388
diff -r 5f393c6b02cb -r bb887c1a381b mbed.bld --- a/mbed.bld Thu Feb 21 16:10:42 2019 +0000 +++ b/mbed.bld Thu Feb 21 18:33:54 2019 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89 \ No newline at end of file
diff -r 5f393c6b02cb -r bb887c1a381b mbed.lib --- a/mbed.lib Thu Feb 21 16:10:42 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://os.mbed.com/users/gokmenascioglu/code/mbed/#a8fa94490a0a
diff -r 5f393c6b02cb -r bb887c1a381b wave_player.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wave_player.lib Thu Feb 21 18:33:54 2019 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/sravet/code/wave_player/#acc3e18e77ad
diff -r 5f393c6b02cb -r bb887c1a381b wave_player_dma.lib --- a/wave_player_dma.lib Thu Feb 21 16:10:42 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/users/ebradley6/code/wave_player_dma/#11a670498598