My ELEC2645 project. Nikollao Sulollari. 200804685
Dependencies: N5110 SoftPWM mbed
Fork of Treasure_Hunt by
Diff: main.cpp
- Revision:
- 11:53caf3d944a9
- Parent:
- 9:ce2d9c42edea
- Child:
- 12:f591f1965abd
- Child:
- 13:359d3aa66352
--- a/main.cpp Wed Apr 27 17:09:13 2016 +0000 +++ b/main.cpp Thu Apr 28 16:29:06 2016 +0000 @@ -9,17 +9,39 @@ int main() { lcd.init(); + button.rise(&button_isr); ///assign rise with ISR + button1.rise(&button1_isr); init_K64F(); init_serial(); - button.fall(&button_isr); ///assign rise with ISR + + /*while(1) { + + lcd.clear(); + if (g_button_flag) { + lcd.printString("button is ON!",0,0); + } else { + lcd.printString("button is OFF!",0,0); + } + if (g_button1_flag) { + lcd.printString("button1 is ON",0,4); + lcd.refresh(); + }else { + lcd.printString("button1 is OFF!",0,4); + lcd.refresh(); + } + wait(0.2); + lcd.refresh(); + }*/ + init_game(); ///initialize game calibrateJoystick(); ///calibrate joystick ticker.attach(&timer_isr,0.1); ///attach ticker with ISR every 0.1 sec reset = level; ///set reset = level to check later if level has increased - buzzer = 0.5; - buzzer.period(1/4000); + // buzzer.start(); //buzzer.write(0.5); + //buzzer.period_ms(4); + menu(); while (1) { @@ -76,12 +98,12 @@ // resistors that are enabled by default using InterruptIn sw2.mode(PullNone); sw3.mode(PullNone); - button.mode(PullUp); + button.mode(PullDown); + button1.mode(PullDown); } void timer_isr () { - g_timer_flag = 1; } @@ -105,6 +127,11 @@ g_button_flag =1; } +void button1_isr() { + + g_button1_flag =1; +} + void timeout_isr() { if (button) {