Zhang Xin yu
/
ZhangXinyu201090208
zhangxinyu01text
Diff: Gamepad/Gamepad.h
- Revision:
- 12:3952ba0683c7
- Parent:
- 5:3c9407e2fe55
- Child:
- 13:29336cfc67b9
--- a/Gamepad/Gamepad.h Tue Apr 17 08:00:08 2018 +0000 +++ b/Gamepad/Gamepad.h Mon May 06 06:09:02 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 mag; /**< float for magnitude */ - 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 @@ -144,11 +160,11 @@ */ bool check_event(GamepadEvent const id); - /** Get magnitude of joystick movement + /** Get varanitude of joystick movement * @returns value in range 0.0 to 1.0 */ - float get_mag(); + float get_vara(); /** Get angle of joystick movement * @returns value in range 0.0 to 359.9. 0.0 corresponds to N, 180.0 to S. -1.0 is central @@ -171,9 +187,9 @@ Vector2D get_mapped_coord(); // x,y mapped to circle /** Gets polar coordinates of the joystick - * @returns a struct contains mag and angle + * @returns a struct contains vara and angle */ - Polar get_polar(); // mag and angle in struct form + Polar get_polar(); // vara and angle in struct form private: void init_buttons();