Control library for the Sparkfun Entertainment Trackballer breakout board.
Diff: trackballer.h
- Revision:
- 2:3c680dd598b7
- Parent:
- 1:0129b1984b5a
- Child:
- 3:000eee36525e
--- a/trackballer.h Sat Feb 19 19:15:13 2011 +0000 +++ b/trackballer.h Sat Feb 19 19:31:22 2011 +0000 @@ -1,73 +1,73 @@ -/* 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.02 - - - -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); - - - - -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; - - -}; - +/* 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.02 + + + +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 \ No newline at end of file