Control library for the Sparkfun Entertainment Trackballer breakout board.
trackballer.h
- Committer:
- Nakor
- Date:
- 2011-02-19
- Revision:
- 0:2743c73d648d
- Child:
- 1:0129b1984b5a
File content as of revision 0:2743c73d648d:
/* 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 /** The 7fold game is a simple number game. 7 slots (horizontally) are filled one * at a time with numbers 1 through 7. If the number of digits vertically or horizontally * add up to the value of a digit in that row (that are touching) then those digits are removed. * * This uses the serially controlled uOLEDs by 4D Systems. * * This is a private library written by Aaron Goselin. While this may change in the future, * in the case of accidental posting to the internet in general, use of this library by an * individual or organization other than Aaron Goselin is prohibited. * * Example: * @code * // Draw text on the screen. * // Accessing from main() * #include "mbed.h" * #include "uOLED.h" * #include "uOLED_watch.h" * #include "games/7fold/7fold.h" * * uOLED SGC(p9, p10, p11); * uOLED_watch watch(&SGC); * 7fold 7fold(); * * int main() * { * // Draws 7fold main menu. * monkey.draw7foldMainMenu(); * } * @endcode */ class trackballer { public: /** Create an instance of the 7fold class. * * Accepts a pointer to the 7fold class. * * Example: * @code * uOLED_menus menus(&SGC, &watch); * @endcode */ 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; }; #endif