Digital Joystick
Joystick.cpp
- Committer:
- LeoHsueh
- Date:
- 2015-02-21
- Revision:
- 5:31e3324d4c4b
- Parent:
- 4:beeaa40d49fa
- Child:
- 6:d354f6e3bd9b
File content as of revision 5:31e3324d4c4b:
#include "Joystick.h" /** 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::Joystick(PinName up, PinName down, PinName left, PinName right, PinName press) : _up(up), _down(down), _left(left), _right(right), _press(press) { } /** Function: getStatus * Read the joystick status * * Variables: * returns - A uint8_t values representing the bits */ uint8_t Joystick::getStatus() { uint8_t ret = 0; if (!_up) { ret |= JOY_UP; } if (!_down) { ret |= JOY_DOWN; } if (!_left) { ret |= JOY_LEFT; } if (!_right) { ret |= JOY_RIGHT; } if (!_press) { ret |= JOY_PRESS; } return ret; }