The present code implements a single player squash game, using joystick to move paddle right or left. And checks the current temperature inside the device.

Dependencies:   mbed

Dependents:   Squash_Project

Files at this revision

API Documentation at this revision

Comitter:
bonnyngangu
Date:
Wed May 11 14:42:02 2016 +0000
Parent:
1:862da825ba95
Commit message:
Updated version

Changed in this revision

game.h Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
--- a/game.h	Sun May 08 21:59:21 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-#include "mbed.h"
-#include "N5110.h" // to enable access and use of the N5110 classes.
-
-#define DIRECTION_TOLERANCE 0.25 // changing to this value enables altering tolerance of joystick direction
-#ifndef GAME_H
-#define GAME_H 
-
-Ticker pollJoystick;// regular reading of the joystick position.
-Serial serial(USBTX,USBRX);// Serial for debug
-
-//create enumerated type (0,1,2,3 etc. for direction)
-//could be extended for diagonals etc.
-
-enum DirectionName {
-    UP,
-    DOWN,
-    LEFT,
-    RIGHT,
-    CENTRE,
-    UNKNOWN
-};
-
-typedef struct JoyStick Joystick;// for Joystick structure
-
-struct JoyStick {
-    float x;    // current x value
-    float x0;   // 'centred' x value
-    float y;    // current y value
-    float y0;   // 'centred' y value
-    int buttonjoystick; /// button state (assume pull-down used, so 1 = pressed, 0 = unpressed)
-    DirectionName direction;  /// current direction
-};
-
-Joystick joystick;// creating struct variables
-
-volatile int g_button_flag = 0;// setting the "g_button_flag" original value to Zero.
-
-
-// initialising joystick position.
-void calibrateJoystick();
-
-// reading the current value of joystick .
-void updateJoystick();
-
-void button_isr();
-
-int status = 1;// setting the status at the origin.
-int printFlag = 0;// this sets Flags value to Zero
-
-// enabling boolean expression. 
-bool wall = false;
-bool hit = false;
-bool bullethit = false;
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.h	Wed May 11 14:42:02 2016 +0000
@@ -0,0 +1,100 @@
+#ifndef MAIN_H
+#define MAIN_H 
+
+#include "mbed.h"
+#include "N5110.h" /// to enable access and use of the N5110 classes.
+
+#define DIRECTION_TOLERANCE 0.25 /// changing to this value enables altering tolerance of joystick direction
+
+/**
+@namespace Nokia 5110_lcd
+@brief lcd display
+*/
+///          VCC,    SCE,  RST,    D/C,   MOSI,  SCLK,   LED
+N5110 lcd (PTE26 , PTA0 , PTC4 , PTD0 , PTD2 , PTD1 , PTC3);
+/// Can also power (VCC) directly from VOUT (3.3 V) -
+/// Can give better performance due to current limitation from GPIO pin
+
+/**
+@namespace buzzer
+@brief buzzer connection
+*/
+PwmOut buzzer(PTA2); /// buzzer connection to PwmOut.
+
+/**
+@namespace button
+@brief button connection
+*/
+InterruptIn interrupt_button(PTB18); // interrupting the sleep mode.
+
+/**
+@namespace buttonjoystick
+@brief buttonjoystick connection
+*/
+DigitalIn button(PTB10); /// connections for joystick
+
+/**
+@namespace xPot
+@brief joystick movement in x-axis.
+*/
+AnalogIn xPot(PTB2); /// X-axisconnections for joystick
+
+/**
+@namespace yPot
+@brief joystick movement in y-axis.
+*/
+AnalogIn yPot(PTB3); /// Y-axisconnections for joystick
+
+Ticker pollJoystick;/// regular reading of the joystick position.
+
+Serial serial(USBTX,USBRX);/// Serial for debug
+
+/**
+create enumerated type (0,1,2,3 etc. for direction)
+could be extended for diagonals etc.
+*/
+enum DirectionName {
+    UP,
+    DOWN,
+    LEFT,
+    RIGHT,
+    CENTRE,
+    UNKNOWN
+};
+
+typedef struct JoyStick Joystick;// for Joystick structure
+
+struct JoyStick {
+    float x;    /// current x value
+    float x0;   /// 'centred' x value
+    float y;    /// current y value
+    float y0;   /// 'centred' y value
+    int buttonjoystick; /// button state (assume pull-down used, so 1 = pressed, 0 = unpressed)
+    DirectionName direction;  /// current direction
+};
+
+Joystick joystick;/// creating struct variables
+
+volatile int g_button_flag = 0;/// setting the "g_button_flag" original value to Zero.
+
+/**
+initialize the position of the joystick.
+*/
+// initialising joystick position.
+void calibrateJoystick();
+
+/**
+read the current joystick value.
+*/
+// reading the current value of joystick .
+void updateJoystick();
+
+/**
+return back button_isr value.
+*/
+void button_isr();
+
+int status = 1;/// setting the status at the origin.
+int printFlag = 0;/// this sets Flags value to Zero
+
+#endif