Simple (basic) snake game

Dependencies:   N5110 mbed

Revision:
4:d1f0cf1ea11b
Parent:
3:79d3148204e1
diff -r 79d3148204e1 -r d1f0cf1ea11b main.h
--- a/main.h	Mon May 09 00:54:45 2016 +0000
+++ b/main.h	Mon May 09 01:55:29 2016 +0000
@@ -11,31 +11,60 @@
 #include "N5110.h"
 #define DIRECTION_TOLERANCE 0.01
 
-// LCD Object
+//Objects/Pin activation 
+/**
+@namespace lcd
+@brief Creates N5110 object to allow interaction with lcd
+*/
 N5110 lcd(PTE26 , PTA0 , PTC4 , PTD0 , PTD2 , PTD1 , PTC3);
-// Serial Communication with PC
+
+/**
+@namespace Serial
+@brief Creates Serial Communication with PC
+*/
 Serial pc(USBTX, USBRX);
-// Analog inputs
-AnalogIn joy_x(PTB2);
-AnalogIn joy_y(PTB3);
-AnalogIn pot(PTB10);
-// Buttons
+
+
+/**
+@namespace AnalogueIn
+@brief Creates connection with Joystick & potentiometer
+*/
+AnalogIn joy_x(PTB2);  // joysitc x directions potentiometer
+AnalogIn joy_y(PTB3); // joystick y directions potentiometer 
+AnalogIn pot(PTB10); // brightness adjusting potentiometer
+
+/**
+@namespace Buttons
+@brief Digital Inputs for joy button and pcb button
+*/
+
 DigitalIn joy_button(PTB11); //  needs pull-down (active high)
 InterruptIn pcb_button(PTB18); // needs pull-down (active high)
 // PWM Output (LED and Buzzer)
-PwmOut pcb_led(PTC2);
-PwmOut pcb_buzzer(PTA2);
+PwmOut pcb_led(PTC2);  // Green LED
+PwmOut pcb_buzzer(PTA2); // sound speaker
 
-// Ticker for joystick update
-Ticker joystick_update_ticker;
-Ticker brightness_update_ticker;
+/**
+@namespace Ticker
+@brief Creates ticker update for joystick& potentiometer adjustment
+*/
+Ticker joystick_update_ticker; // read values of joystick
+Ticker brightness_update_ticker; // read values of potentiometer
 
-// Initialising board board
+/**
+Initialises the K64F display and presents the welcome screen
+@returns void
+*/
 void init_K64F();
-// Welcome screen
-void welcomeScreen();
+
+void welcomeScreen(); /*!< Welcome screen*/
+
+
 
-// Defining possible joystick directions (enum)
+
+/** Defining possible joystick directions (enum)
+@returns void
+*/
 enum DirectionName {
     UP,
     DOWN,
@@ -45,7 +74,9 @@
     UNKNOWN
 };
 
-// Joystick type definition
+/** struct for Joystick, containing x,y values, button status, direction and centered values
+@returns void
+*/
 struct JoyStick {
     double x;    /// current x value
     double x0;   /// 'centred' x value
@@ -55,13 +86,17 @@
     DirectionName direction;  // current direction
 } joystick;
 
-// Apple type definition
+/** struct for Apple, containing x,y values
+@returns void*/
+
 struct AppleType {
     int x; // Apple X
     int y; // Apple Y
 };
 
-// Defining possible states of the game (enum)
+/**  Defining possible states of the game (enum)
+@returns void*/
+
 enum GAME_STATES {
         INIT, // 0
         WAIT_FOR_USER, // 1
@@ -71,29 +106,32 @@
 
 GAME_STATES game_state = INIT; // Default state of the game
 
-// Global variables
-volatile int g_pcb_button_flag = 0;
+
+volatile int g_pcb_button_flag = 0; /*!<Global variables*/
+
+
+/** Function prototypes @returns void*/
 
-// Function prototypes
-void calibrateJoystick();
-void updateJoystick();
-void updateBrightness();
-void snakeGame();
+void calibrateJoystick(); /*!< initial positions in the range 0.0 to 1.0*/
+void updateJoystick();/*!< read current joystick values relative to calibrated values*/
+void updateBrightness(); /*!< updates brightness of screen based on potentiometer reading*/
+void snakeGame(); /*!< executres full functionality of game */
 
-// These functions are used to map game
-// field of 20x11 to the LCD screen which is 84x48
+/**These functions are used to map game
+@returns void*/
 
-// Enable square (4x4 pixels) at x, y
-void drawBlock(int field_x, int field_y);
-// Draw Apple (4x4 pixels) at x, y
-void drawApple(int field_x, int field_y);
-// Disable square (4x4 pixels) at x, y
-void eraseBlock(int field_x, int field_y);
-// Get the status of the square (4x4 pixels) at x, y
-int getBlock(int field_x, int field_y);
-// Place an apple at random location (returns food structure)
-AppleType placeRandomApple();
-// pcb_button interrupt function
-void pcb_button_isr();
-// This function make LED blink and buzzer make a sound
-void blinkLEDandBuzz();
\ No newline at end of file
+void drawBlock(int field_x, int field_y); /*!< Enable square (4x4 pixels) at x, y */
+
+void drawApple(int field_x, int field_y);/*!< Draw Apple (4x4 pixels) at x, y*/
+
+void eraseBlock(int field_x, int field_y); /*!< Disable square (4x4 pixels) at x, y*/
+
+
+int getBlock(int field_x, int field_y); /*!<Get the status of the square (4x4 pixels) at x, y*/
+
+AppleType placeRandomApple(); /*!< Place an apple at random location (returns food structure)*/
+
+void pcb_button_isr(); /*!< pcb_button interrupt function*/
+
+
+void blinkLEDandBuzz();/*!< This function make LED blink and buzzer make a sound*/
\ No newline at end of file