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:
- 73:1b03202c987a
- Parent:
- 72:ade25d595dc9
- Child:
- 74:d76be537bafd
--- a/main.cpp Fri May 08 12:42:59 2015 +0000 +++ b/main.cpp Sun May 10 06:58:58 2015 +0000 @@ -3,13 +3,13 @@ @brief Program implementation */ -#include "PowerControl/PowerControl.h" +#include "PowerControl/PowerControl.h"//for sleep modes +#include "PowerControl/EthernetPowerControl.h"//for Ethernet Power Down #include "mbed.h" #include "N5110.h" #include "beep.h" #include "tower.h" #include <ctime> -#include <cstdlib> ///writes to CFG file. void write() @@ -1084,8 +1084,9 @@ drawBackground();//draw background while(1) { + //print score - top left of display - char buffer[14];//create buffer for string + char buffer [14];//create buffer for string int length = sprintf(buffer,"Level:%d",score);//insert buffer lcd.printString(buffer,3,0);//display @@ -1153,8 +1154,7 @@ startrek();//clears unset pixels, keeps set pixels //Exit Menu (Back button pressed)// - if(buttonFlagB) { - //rightness(1.0); + if(buttonFlagB) { buttonFlagB = 0;//reset flags buttonFlagA = 0; actionButtons(); @@ -1243,7 +1243,7 @@ newButtonA = buttonFlagA; -//////////////////////difficulty menu //////////////////////////////////// +//================ Difficulty menu ======================= if ((option == 0)&&(buttonFlagA)) { //rightness(1.0); buttonFlagA = 0;//reset flag @@ -1254,8 +1254,7 @@ actionButtons(); difficultyMenu(subOption);//presents difficulty options - if(buttonFlagB) { - //rightness(1.0); + if(buttonFlagB) { buttonFlagB = 0;//reset flags buttonFlagA = 0; lcd.clear();//clear screen @@ -1336,7 +1335,6 @@ } else { joystick.direction = UNKNOWN; } - //set flag for printing printFlag = 1; } @@ -1349,6 +1347,7 @@ int main() { + PHY_PowerDown();//powers down the Ethernet ledP = 1;//power LED on randomise();//randomises falling hazards (initial values only) calibrateJoystick();//get centred values of joystick @@ -1356,7 +1355,7 @@ lcd.init();//initialise screen drawWelcome();//welcome screen - lcd.clear();//clear pixels + lcd.clear();//clear screen buttonA.mode(PullDown);//pull down buttonA buttonB.mode(PullDown);//pull down buttonB @@ -1376,7 +1375,6 @@ mainMenu(mainOption);//presents main menu options actionButtons();//sound light when buttons pressed - // if 'Play Game' selected if ((mainOption == 0)&&(buttonFlagA)) { buttonFlagA = 0;