My ELEC2645 project. Nikollao Sulollari. 200804685

Dependencies:   N5110 SoftPWM mbed

Fork of Treasure_Hunt by ELEC2645 (2015/16)

main.h

Committer:
Nikollao
Date:
2016-03-26
Revision:
5:ffa498d7071f
Parent:
4:f31bdc212241
Child:
6:c11bb31a06b3

File content as of revision 5:ffa498d7071f:

/**
@file main.h
@brief Header file contains functions and variables
@brief Treasure Hunt - Embedded Systems Project
@brief Revision 1.0
@author Nikollao Sulollari
@Date 26/03/2016
*/

#ifndef MAIN_H
#define MAIN_H
#include "mbed.h"


/**
@nameSpace led
@brief GPO output for status of LED
*/
DigitalOut r_led(LED_RED);
DigitalOut g_led(LED_GREEN);
DigitalOut b_led(LED_BLUE);

// K64F on-board switches
InterruptIn sw2(SW2);
InterruptIn sw3(SW3);

InterruptIn button(PTB2);
AnalogIn xPot(PTB3);
AnalogIn yPot(PTB10);
PwmOut speaker(PTC11);

/**
Displays an error message
*/
void error();

/**
set-up serial port
*/
void init_serial();

/**
 set-up the on-board LEDs and switches
*/
void init_K64F();

/**
Set-up random variables and game menu
*/
void init_game();

/**
Set-up flag to 1
*/

/**
Set-up flag to 1
*/
void timer_isr();

/**
Set-up flag to 1
*/

/**
Set-up flag to 1
*/
void game_timer_isr();

/**
Set-up flag to 1
*/
void sw2_isr();

/**
Set-up flag to 1
*/
void sw3_isr();

/**
Set-up flag to 1
*/
void button_isr();

/**
Set-up flag to 1
*/
void timeout_isr();

/**
Set current position to default position of Joystick
*/
void calibrateJoystick();

/**
Update the values of the joystick to get current position
*/
void updateJoystick();

/**
Create an enemy rectangular shape
*/
void enemyRect();

/**
Create circle shape enemy
*/
void enemyCircle();

/**
creates the hero of the game
*/
void hero();

/**
Shows the right direction
*/
void guidance();

/**
Locates obstacles in the screen
*/
void obstacles();

/**
Gets enemies depending on the level
*/
void enemies();

/**
Get s vslue of the .y position, control menu
*/
int menu();

/**
Check for intrersection
@param i loops through x direction
@param j loops through y direction
@returns the number of pixels aroun the hero detected
*/
int intersection(int i, int j);

volatile int rectY; /*! <set the Y coordinate of the rectangular enemy> */

volatile int rectX ;/*! <set the X coordinate of the rectangular enemy> */

volatile int circleX;/*! <set the Y coordinate of the circular enemy> */

volatile int circleY;/*! <set the X coordinate of the circular enemy> */

volatile int heroX;/*! <set the X coordinate of the hero> */

volatile int heroY;/*! <set the Y coordinate of the hero> */

volatile int level = 0; /*! <set level of the game> */

volatile int g_timer_flag = 0; /*! <set timer flag in the isr, timer trigger interrupt> */

volatile int g_game_timer_flag = 0;  /*! <set timer flag in the isr, timer trigger interrupt> */

volatile int g_sw2_flag = 0;  /*! <set timer flag in the isr, event trigger interrupt> */

volatile int g_sw3_flag = 0;  /*! <set timer flag in the isr, event trigger interrupt> */

volatile int g_button_flag = 0;  /*! <set timer flag in the isr, event trigger interrupt> */

volatile int option = 0;  /*! <set option to generate menut> */

volatile int play = 0; /*! <used as a variable to check if its the first try*/

volatile int tries = 0;/*! <saves number of trials> */

int reset = 0; /*! <updates level of the game> */

int check[10][10];/*! <array used to check for intersection> */

#endif