Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.h File Reference
Header file containing functions prototypes, defines and global variables. More...
Go to the source code of this file.
Data Structures | |
| struct | State |
Namespaces | |
| namespace | lcd |
This allows the mbed to interface with the N5110 screen. | |
| namespace | b1 |
Sets up a button that allows for interrupts to be called on pin PTB19. | |
| namespace | b2 |
Sets up a button that allows for interrupts to be called on pin PTB18. | |
| namespace | xPot |
Sets up the potentiometer that determines the horizontal position of the joystick. | |
| namespace | yPot |
Sets up the potentiometer that determines the vertical position of the joystick. | |
| namespace | ticker |
A ticker that is attatched to a time based interrupt to allow the screen to periodically refresh. | |
| namespace | timer |
A timer that is used as the seed to generate a random number for asteroid creation. | |
Functions | |
| void | b1_isr () |
| A function which alters the b1 flag from 0 to 1 when an interrupt occurs. | |
| void | b2_isr () |
| A function which alters the b2 flag from 0 to 1 when an interrupt occurs. | |
| void | timer_isr () |
| A function which alters the timer flag from 0 to 1 when the time interrupt occurs. | |
| void | calibrateJoystick () |
| Reads the initial positon of the joystick and sets this as centered. | |
| void | updateJoystick () |
| Compares the current positon of the joystick to the centred position of the joystick and calculates which way the joystick has been pushed. | |
| void | game () |
| The main game function in it the. | |
| void | shoots () |
| A function that reads the ships direction and fires a bullet in that direction. | |
| void | asteroidMove () |
| A function that using random numbers determines which size asteroid to generate and from which direction The function also checks to see if there is a bullet or ship in front of it, if there isn't the asteroid moves forward. | |
| void | checkbullet () |
| checks to see if the bullet has left the screen without hitting anything if it has the bullet is erased | |
Variables | |
| volatile int | g_b1_flag = 0 |
| volatile int | g_b2_flag = 0 |
| volatile int | g_timer_flag = 0 |
| int | score = 0 |
| int | bullet_number = 0 |
| int | shipDirection = 0 |
| int | game_over = 0 |
| int | printFlag = 0 |
| int | state = 1 |
| int | direction = UP |
| int | settings = 0 |
| STyp | fsm [8] |
Detailed Description
Header file containing functions prototypes, defines and global variables.
Shows examples of creating Doxygen documentation. Revision 1.0.
- Date:
- March 2015
Definition in file main.h.
Function Documentation
| void asteroidMove | ( | ) |
A function that using random numbers determines which size asteroid to generate and from which direction The function also checks to see if there is a bullet or ship in front of it, if there isn't the asteroid moves forward.
the random variable number is used to assign the type of asteroid
| void b1_isr | ( | ) |
| void b2_isr | ( | ) |
| void calibrateJoystick | ( | ) |
| void checkbullet | ( | ) |
| void game | ( | ) |
| void shoots | ( | ) |
| void timer_isr | ( | ) |
| void updateJoystick | ( | ) |
Variable Documentation
| int bullet_number = 0 |
| int direction = UP |
{
{0,{0,1,1,1,1,7,7,7,0}},
{1,{0,1,2,2,2,2,0,0,1}},
{2,{1,1,2,3,3,3,3,1,2}},
{3,{2,2,2,3,4,4,4,4,3}},
{4,{5,3,3,3,4,5,5,5,4}},
{5,{6,6,4,4,4,5,6,6,5}},
{6,{7,7,7,5,5,5,6,7,6}},
{7,{0,0,0,0,6,6,6,7,7}},
}
The FSM has 9 possible inputs and 8 possible outcomes the inputs are taken from the joystick direction and go as following UP = 0, UPRIGHT = 1, RIGHT = 2, DOWNRIGHT = 3, DOWN = 4, DOWNLEFT = 5, LEFT = 6, UPLEFT = 7, STAY = 8 The ships direction follows the same pattern and the FSM aims to get the ship to face that direction in the quickest way possible If the joystick is pushed in a direction completly opposite to the ship the ship will spin clockwise
| volatile int g_b1_flag = 0 |
| volatile int g_b2_flag = 0 |
| volatile int g_timer_flag = 0 |
| int game_over = 0 |
| int printFlag = 0 |
| int score = 0 |
| int settings = 0 |
| int shipDirection = 0 |
Generated on Tue Jul 12 2022 16:35:19 by
1.7.2