444444444444

Dependencies:   mbed CXK

Files at this revision

API Documentation at this revision

Comitter:
Jenny121
Date:
Mon May 06 06:42:41 2019 +0000
Parent:
12:f8eb397226bc
Commit message:
1122

Changed in this revision

Ball/Ball.h Show annotated file Show diff for this revision Revisions of this file
CXK.lib Show annotated file Show diff for this revision Revisions of this file
CXK/CXK.cpp Show diff for this revision Revisions of this file
CXK/CXK.h Show diff for this revision Revisions of this file
Gamepad/Gamepad.h Show annotated file Show diff for this revision Revisions of this file
N5110/N5110.h Show annotated file Show diff for this revision Revisions of this file
cxkEngine/cxkEngine.h Show annotated file Show diff for this revision Revisions of this file
diff -r f8eb397226bc -r 45354ed42401 Ball/Ball.h
--- a/Ball/Ball.h	Mon May 06 04:11:38 2019 +0000
+++ b/Ball/Ball.h	Mon May 06 06:42:41 2019 +0000
@@ -30,23 +30,33 @@
      
      
        /** Set the balldraw 
-      lcd.drawCircle(_x,_y,_size,FILL_BLACK);
-    just draw the ball
-    _x , _y position in the lCD
-     */
+    * @ details  lcd.drawCircle(_x,_y,_size,FILL_BLACK);
+   * @ param value that updated (_x,_y, _size)
+    */
     void draw(N5110 &lcd);
     
     
-    /** Set the balldraw 
-      lcd.drawCircle(_x,_y,_size,FILL_BLACK);
-    just draw the ball
-    _x , _y position in the lCD
+    /** Set the update
+      * @details updated the _x,_y value by speed means move the ball
      */
     void update();
+    
     /// accessors and mutators
+    
+     /** Set the balldraw 
+    * @ details set the value of veocity LCD cooresponding v = {_velocity.x,_velocity.y};
+   * @ param value that updated (v)
+   * @ returns v
+    */
     void set_velocity(Vector2D v);
     Vector2D get_velocity();
     Vector2D get_pos();
+    
+     /** Set the balldraw 
+    * @ details set the value of position of LCD cooresponding p= {x,y};
+   * @ param value that updated (p)
+   * @ returns p
+    */
     void set_pos(Vector2D p);
     
 private:
diff -r f8eb397226bc -r 45354ed42401 CXK.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CXK.lib	Mon May 06 06:42:41 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Jenny121/code/CXK/#4ca1ed928a81
diff -r f8eb397226bc -r 45354ed42401 CXK/CXK.cpp
--- a/CXK/CXK.cpp	Mon May 06 04:11:38 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-#include "CXK.h"
-
-// nothing doing in the constructor and destructor
-CXK::CXK()
-{
-
-}
-
-CXK::~CXK()
-{
-
-}
-
-void CXK::init(int x,int y,int height,int width)
-{
-    _x = 67 - width/2;  
-    _y = 25 - height/2;  // y depends on height of screen and height of CXK
-    _height = height;
-    _width = width;
-    _speed = 1;  // default speed
-    _score = 0;  // start score from zero
-
-}
-
-void CXK::draw(N5110 &lcd)
-{
-    // draw CXK in screen buffer. 
-  lcd.drawCircle(_x,_y,3,FILL_TRANSPARENT);
-              lcd.drawRect(_x-3,_y-5,3,1,FILL_TRANSPARENT);
-            lcd.drawRect(_x+4,_y-5,3,1,FILL_TRANSPARENT);
-            lcd.drawRect(_x-1,_y-1,1,1,FILL_TRANSPARENT);
-            lcd.drawRect(_x+1,_y-1,1,1,FILL_TRANSPARENT);
-            lcd.drawRect(_x,_y+2,4,1,FILL_TRANSPARENT);
-}
-
-void CXK::update(Direction d,float vara)
-{
-    _speed = int(vara*10.0f);  // scale is arbitrary, could be changed in future
-
-    // update y value depending on direction of movement
-    // North is decrement as origin is at the top-left so decreasing moves up
-    if (d == N) {
-        _y-=_speed;
-    } else if (d == S) {
-        _y+=_speed;
-    } else if (d == E) {
-        _x+=_speed;
-    } else if (d == W){
-        _x-=_speed; 
-        }
-
-    
-    // check the y origin to ensure that the CXK doesn't go off screen
-    if (_y < 1) {
-        _y = 1;
-    }
-    if (_y > HEIGHT - _height - 1) {
-        _y = HEIGHT - _height - 1;
-    }
-    
-    if (_x < 1) {
-        _x = 1;
-    }
-    if (_x > WIDTH - _width-3 ) {
-        _x = WIDTH - 3;
-    }
-      
-}
-
-void CXK::add_score()
-{
-    _score++;
-}
-int CXK::get_score()
-{
-    return _score;
-}
-
-Vector2D CXK::get_pos() {
-    Vector2D p = {_x,_y};
-    return p;    
-}
\ No newline at end of file
diff -r f8eb397226bc -r 45354ed42401 CXK/CXK.h
--- a/CXK/CXK.h	Mon May 06 04:11:38 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#ifndef CXK_H
-#define CXK_H
-
-#include "mbed.h"
-#include "N5110.h"
-#include "Gamepad.h"
-
-class CXK
-{
-public:
-
-    CXK();
-    ~CXK();
-    void init(int x,int y,int height,int width);
-    void draw(N5110 &lcd);
-    void update(Direction d,float vara);
-    void add_score();
-    int get_score();
-    Vector2D get_pos();
-
-private:
-
-    int _height;
-    int _width;
-    int _x;
-    int _y;
-    int _speed;
-    int _score;
-
-};
-#endif
\ No newline at end of file
diff -r f8eb397226bc -r 45354ed42401 Gamepad/Gamepad.h
--- a/Gamepad/Gamepad.h	Mon May 06 04:11:38 2019 +0000
+++ b/Gamepad/Gamepad.h	Mon May 06 06:42:41 2019 +0000
@@ -6,6 +6,14 @@
 // Forward declaration of the classes that we use from the mbed library
 // This avoids the need for us to include the huge mbed.h header inside our
 // own library API
+
+/** Gamepad Class
+* @brief with the para and elemets of LCD pad i sLCD
+* @author Zhang Xinyu
+* @school EE of  SWJTU &leeds joint school
+* @date  MAY  2019
+*/ 
+
 namespace mbed
 {
 class AnalogIn;
@@ -17,42 +25,50 @@
 #define TOL 0.1f
 #define RAD2DEG 57.2957795131f
 
-/** Enum for direction */
+/** Enum for direction 
+* @ details defined the direction  of joysticks 
+* @ param  pushed defined the CENTRE N,NE,E,SE,S,SW,W,NW acording to agnles
+*/
 enum Direction {
-    CENTRE,  /**< joystick centred */
-    N,       /**< pushed North (0)*/
-    NE,      /**< pushed North-East (45) */
-    E,       /**< pushed East (90) */
-    SE,      /**< pushed South-East (135) */
-    S,       /**< pushed South (180) */
-    SW,      /**< pushed South-West (225) */
-    W,       /**< pushed West (270) */
-    NW       /**< pushed North-West (315) */
+    CENTRE, 
+    N,      
+    NE,   
+    E,      
+    SE,     
+    S,      
+    SW,      
+    W,       
+    NW      
 };
 
-/** Vector 2D struct */
+/** Vector 2D struct 
+* @ param float x and y for value */
 struct Vector2D {
-    float x; /**< float for x value */
-    float y; /**< float for y value */
+    float x; 
+    float y; 
 };
 
-/** Polar coordinate struct */
+/** Polar coordinate struct
+* @ param the vara magnitude 
+* @ param float for angle (in degrees) 
+* @ details the vara and angle are use by other function 
+ */
 struct Polar {
-    float vara;  /**< float for varanitude */
-    float angle; /**< float for angle (in degrees) */
+    float vara; 
+    float angle; 
 };
 
 /** Gamepad Class
-@brief Library for interfacing with ELEC2645 Gamepad PCB, University of Leeds
-@author Dr Craig A. Evans
-@author Dr Alex Valanvanis
-@date Febraury 2017
+@brief Library of the gamepad 
+@author zhang xinyu
+@date May 2019
 */
 class Gamepad
 {
     public:
     /** Gamepad events 
  * @brief List of events that can be registered on the gamepad
+ * @ param defined the button in the pad
  */
 enum GamepadEvent {
     A_PRESSED,     ///< Button A has been pressed
diff -r f8eb397226bc -r 45354ed42401 N5110/N5110.h
--- a/N5110/N5110.h	Mon May 06 04:11:38 2019 +0000
+++ b/N5110/N5110.h	Mon May 06 06:42:41 2019 +0000
@@ -40,17 +40,17 @@
 };
 
 /** N5110 Class
-@brief Library for interfacing with Nokia 5110 LCD display (https://www.sparkfun.com/products/10168) using the hardware SPI on the mbed.
+@brief just the same as the N5110 in the calss before
 @brief The display is powered from a GPIO pin meaning it can be controlled via software.  The LED backlight is also software-controllable (via PWM pin).
 @brief Can print characters and strings to the display using the included 5x7 font.
 @brief The library also implements a screen buffer so that individual pixels on the display (84 x 48) can be set, cleared and read.
 @brief The library can print primitive shapes (lines, circles, rectangles)
-@brief Acknowledgements to Chris Yan's Nokia_5110 Library.
+
 
 @brief Revision 1.3
 
-@author Craig A. Evans
-@date   7th February 2017
+@author Zhang Xinyu
+@date   MAY 2019
 
 @code
 
@@ -177,6 +177,8 @@
 
 @endcode
 */
+
+
 class N5110
 {
 private:
@@ -189,7 +191,7 @@
     DigitalOut  *_dc;
 
 // variables
-    unsigned char buffer[84][6];  // screen buffer - the 6 is for the banks - each one is 8 bits;
+    unsigned char buffer[84][6];  
 
 public:
     /** Create a N5110 object connected to the specified pins
diff -r f8eb397226bc -r 45354ed42401 cxkEngine/cxkEngine.h
--- a/cxkEngine/cxkEngine.h	Mon May 06 04:11:38 2019 +0000
+++ b/cxkEngine/cxkEngine.h	Mon May 06 06:42:41 2019 +0000
@@ -8,17 +8,46 @@
 #include "CXK.h"
 
 
+/** cxkEngine Class
+* @brief the diagram of the ball and others 
+* @author Zhang Xinyu
+* @school EE of  SWJTU &leeds joint school
+* @date  MAY  2019
+*/ 
 
 class cxkEngine
 {
 
 public:
+
+/** Constructor */
     cxkEngine();
+    
+    /** Destrctor */
     ~cxkEngine();
 
+ /** Set the cxkEngineinit  
+       * @ param value of the cxk feature of the CXK file (CXK_width, CXK_height)
+        * @ param value of the ball size of the ballfile (ball_size)
+         * @ param value of the move speed of the CXKand ball file (speed)
+    */
     void init(int CXK_width,int CXK_height,int ball_size,int speed);
+    
+    /** Set the cxkEread_Iinput
+      * @ details use CXK and BAll to read the value of direction and maganitude of joystick
+    */
     void read_input(Gamepad &pad);
+    
+
+    /** Set the cxkEupdate 
+      * @ details updated the d and vara from the read_input
+    */
     void update(Gamepad &pad);
+    
+     /** Set the CXKdraw  
+       * @ param  the score player get (cxkp_score)
+       * @ details draw the wall and basket to the game
+       */
     void draw(N5110 &lcd);
     
 private: