A retro gaming programme, designed for use on a portable embedded system. Incorporates power saving techniques.
Dependencies: ConfigFile N5110 PowerControl beep mbed
Diff: main.cpp
- Revision:
- 14:c2c969e1c6e8
- Parent:
- 13:a1b3a373c5a4
- Child:
- 15:ff3eb0091453
--- a/main.cpp Fri Apr 17 01:20:47 2015 +0000 +++ b/main.cpp Fri Apr 17 16:12:40 2015 +0000 @@ -7,16 +7,37 @@ #include "N5110.h" #include "beep.h" #include "tower.h" +#include "PowerControl/PowerControl.h" #include <ctime> #include <cstdlib> +Ticker timer;//timer to read state of buttons every 0.25 seconds + +int buttonFlagA; +int buttonFlagB; + +void timerExpiredA() +{ + if(buttonA != 0) { + buttonFlagA = 1; + actionButtons(); + } +} + +void timerExpiredB() +{ + if(buttonB != 0) { + buttonFlagB = 1; + actionButtons(); + } +} + + int main() { ledR = 1;//power LED on - - randomise(); - + randomise();//randomises falling hazards (initial values only) calibrateJoystick();//get centred values of joystick pollJoystick.attach(&updateJoystick,1.0/10.0);//read joystick 10 times per second @@ -27,10 +48,9 @@ int exitFlag = 0;//exit flag int mainOption = 0;//counter for main menu int exitOption = 0;//counter for exit menu - int option = 0;//counter for options menu - int subOption = 0;//counter for sub options menu - int fxOption = 0;//counter for Sound FX menu - + + timer.attach(&timerExpired, 0.25);//checks state of buttons + while(1) { drawMainMenu();//draws main menu mainMenu(mainOption);//presents main menu options @@ -45,7 +65,7 @@ } // if 'option' selected if((mainOption == 2)&&(buttonA == 1)) { - optionsMenu(option, subOption, fxOption); + optionsMenu(); } } }