Digital Joystick
Joystick.h
- Committer:
- LeoHsueh
- Date:
- 2015-02-21
- Revision:
- 5:31e3324d4c4b
- Parent:
- 3:83b40e07476f
- Child:
- 6:d354f6e3bd9b
File content as of revision 5:31e3324d4c4b:
//remove repetition #ifndef MBED_JOYSTICK_H #define MBED_JOYSTICK_H //required to use mbed functions #include "mbed.h" #define JOY_UP 0x01 #define JOY_DOWN 0x02 #define JOY_LEFT 0x04 #define JOY_RIGHT 0x08 #define JOY_PRESS 0x10 /** Class: Joystick * * Used for reading from an digital joystick * * Example: * * > #include "mbed.h" * * > Joystick joystick(P2_3, P0_15, P2_4, P0_16, P0_17); */ class Joystick { public: /** Create a Joystick HID for using regular mbed pins * * @param up Joystick Up * @param down Joystick Down * @param left Joystick Left * @param right Joystick Right * @param press Joystick Press */ Joystick(PinName up, PinName down, PinName left, PinName right, PinName press); /** Function: getStatus * Read the joystick status * * Variables: * returns - A uint8_t values representing the bits */ uint8_t getStatus(); private: /** Regular mbed pins bus */ DigitalIn _up, _down, _left, _right, _press; }; #endif