SharpShooter
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
Diff: main.cpp
- Revision:
- 1:8a3fa9e90572
- Parent:
- 0:137546fb5da1
- Child:
- 5:f51cdddf541e
--- a/main.cpp Thu Oct 27 21:23:02 2016 +0000 +++ b/main.cpp Thu Oct 27 23:10:15 2016 +0000 @@ -3,12 +3,16 @@ #include "uLCD_4DGL.h" #include "SDFileSystem.h" #include "wave_player.h" +#include "Nav_Switch.h" +#include "rtos.h" DigitalOut myled(LED1); /*uLCD instantiation*/ uLCD_4DGL uLCD(p9,p10,p11); // serial tx, serial rx, reset pin; +Nav_Switch myNav( p24, p25, p26, p27, p28); //up, down, left, right, fire + Mutex mutex; /* wave player instantiation*/ @@ -16,44 +20,6 @@ AnalogOut DACout(p18); wave_player waver(&DACout); -/* Control shooter*/ -void lcd_thread1(void const *args) { - int dist = 40; - while (true) { - if (red != 0) { - mutex.lock(); - uLCD.cls(); - uLCD.locate(64,64); - uLCD.color(0xFFFF00); //yellow text - uLCD.background_color(0xFFA500); //orange - uLCD.filled_rectangle(64-dist, 64-dist, 64+dist, 64+dist, 0xff0000); //red square - uLCD.text_mode(OPAQUE); - uLCD.printf("Charmander!!"); - mutex.unlock(); - //Thread::wait(1000); - } - } -} - -/*makes different colored circle every time the bell sound sounds*/ -void lcd_thread2(void const *args) { - int rad = 40; - while (true) { - if (blue == 1) { - mutex.lock(); - uLCD.cls(); - uLCD.locate(64,64); - uLCD.color(0xFFFF00); //yellow text - uLCD.background_color(0x0000ff); //blue background - uLCD.filled_circle(64, 64, rad, 0xB7D5E9); //light blue circle - uLCD.text_mode(OPAQUE); - uLCD.printf("Bulbasaur!!"); - //uLCD.filled_rectangle(64-25, 64-25, 64+25, 64+25, 0x336600); - mutex.unlock(); - } - } -} - /*play wav file on sd and when playing led1 turns on*/ void wav_thread3(void const *args) { while (1) { @@ -64,26 +30,22 @@ } } -void light_thread4(void const *args) { +void switch_thread5(void const *args) { while (true) { - red = 0; - blue = 1; - green = 0; - - Thread::wait(1000); - - red = 0.8; - blue = 0; - green = 0; - - Thread::wait(1000); + if(myNav.fire()) myled=!myled; + if(myNav.up()) myled=!myled; + if(myNav.down()) myled=!myled; + if(myNav.right()) myled=!myled; + if(myNav.left()) myled=!myled; + //Thread::wait(500); } } - + int main() { - Thread thread1(lcd_thread1); - Thread thread2(lcd_thread2); - Thread thread3(wav_thread3); - Thread thread4(light_thread4); - while(1); + myled=0; + //Thread thread2(switch_thread5); + //Thread thread3(wav_thread3); + while(1) { + + } }