Project Submission (late)
Dependencies: mbed
Diff: main.cpp
- Revision:
- 3:83e79d31930c
- Parent:
- 2:43bb635db736
--- a/main.cpp Fri May 10 10:51:19 2019 +0000 +++ b/main.cpp Fri May 10 14:52:28 2019 +0000 @@ -1,3 +1,14 @@ +/* +ELEC2645 Embedded Systems Project +School of Electronic & Electrical Engineering +University of Leeds +Name: Thomas Caine +Username: el175c +Student ID Number: 201127594 +Date: 10/05/2019 +*/ + + #include "mbed.h" #include "Gamepad.h" #include "N5110.h" @@ -9,9 +20,20 @@ #include "DefeatMenu.h" #include "VictoryMenu.h" +/* Note: +If it were up to me almost everything in this file would be in a Game object and main would only have game.init(); game.run(); in it +Unfortunately I have been plagued by L6312W the empty execution region error (not the warning) all the way through this project +and this is as good as I could get it in terms of object orientation. +As far as I'm aware this error is a bug with the mbed compiler of this version but it can be worked around. +Dock marks as you see fit for not encapsulating the other headers into a single class. +(but the other classes are nice and object-oriented, right?) +*/ + + N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad gamepad; - +/** Causes the currentMenu's button index to be decremented, moving the cursor to the higher button +*/ void buttonPressedUp() { if (currentMenu->buttonIndex > 0) { currentMenu->buttonIndex -= 1; @@ -20,6 +42,8 @@ printf("currentMenu->buttonIndex = %d\n", currentMenu->buttonIndex); } +/** Causes the currentMenu's button index to be incremented, moving the cursor to the lower button +*/ void buttonPressedDown() { if (currentMenu->buttonIndex < (currentMenu->numOfButtons - 1)) { currentMenu->buttonIndex += 1; @@ -33,6 +57,8 @@ bool arrowFlickFlag = 1; int ingameTime; +/** Funciton for drawing the ingame Timer + */ void drawTimer() { lcd.drawRect(1,1,20,8,FILL_WHITE); std::stringstream ss; @@ -40,17 +66,27 @@ std::string timeStr = "Time:" + ss.str(); lcd.printString(timeStr.c_str(), 1,0); } +/** Timer increment/decrement function + * @brief depending on the timerFlag (toggled on or off) it will count up or down + */ void timerFunc() { if (timerFlag) ingameTime--; else ingameTime++; } + +/** Funciton making the button selection arrow flicker + * @brief aesthetically pleasing (i think). + */ void selectionArrowFunc() { arrowFlickFlag = !arrowFlickFlag; }; - +/** The main function + * Due to constantly getting Empty Execution region errors this is a lot more full than it should be + * refer to note at the top of main.cpp for more comments on the issue. + */ int main() { gamepad.init(); lcd.init();