Control library for the Sparkfun Entertainment Trackballer breakout board.
trackballer.h
- Committer:
- Nakor
- Date:
- 2011-02-19
- Revision:
- 3:000eee36525e
- Parent:
- 2:3c680dd598b7
- Child:
- 5:0abcaea1fb07
File content as of revision 3:000eee36525e:
/* This library is for Sparkfun Entertainment's Trackballer breakout board. * The board consists (mainly) of the trackball, 4 hall effect sensors, some magnets (obviously), * a button, and 4 leds (white, red, green, blue). * * This library (trackballer) by Aaron Goselin. * 2010 Aaron Goselin. * * You are free to use this as you like, but I would prefer credits stay in tact. * */ #ifndef _TRACKBALLER_ #define _TRACKBALLER_ #include "mbed.h" //#include "PinDetect_m.h" #define TRACK_INC 0.01 class trackballer { public: trackballer(PinName button, PinName right, PinName down, PinName left, PinName up, PinName red, PinName green, PinName blue, PinName white); void getDirection(float &xPosition, float &yPosition, char &button); protected: Timer _outputTimer; DigitalIn * _buttonPin; DigitalIn * _rightPin; DigitalIn * _downPin; DigitalIn * _leftPin; DigitalIn * _upPin; PwmOut * _redLED; PwmOut * _greenLED; PwmOut * _blueLED; PwmOut * _whiteLED; int _buttonPushCounter; // counter for the number of button presses char _buttonState; // current state of the button char _lastButtonState; // previous state of the button char _upState; char _downState; char _leftState; char _rightState; char _lastUpState; char _lastDownState; char _lastLeftState; char _lastRightState; float _xPosition; float _yPosition; char _direction; }; #endif