Control library for the Sparkfun Entertainment Trackballer breakout board.

Committer:
Nakor
Date:
Sat Feb 19 19:15:13 2011 +0000
Revision:
1:0129b1984b5a
Parent:
0:2743c73d648d
Child:
2:3c680dd598b7
Ooops, old documentation needed to be removed.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Nakor 0:2743c73d648d 1 /* This library is for Sparkfun Entertainment's Trackballer breakout board.
Nakor 0:2743c73d648d 2 * The board consists (mainly) of the trackball, 4 hall effect sensors, some magnets (obviously),
Nakor 0:2743c73d648d 3 * a button, and 4 leds (white, red, green, blue).
Nakor 0:2743c73d648d 4 *
Nakor 0:2743c73d648d 5 * This library (trackballer) by Aaron Goselin.
Nakor 0:2743c73d648d 6 * 2010 Aaron Goselin.
Nakor 0:2743c73d648d 7 *
Nakor 0:2743c73d648d 8 * You are free to use this as you like, but I would prefer credits stay in tact.
Nakor 0:2743c73d648d 9 *
Nakor 0:2743c73d648d 10 */
Nakor 0:2743c73d648d 11
Nakor 0:2743c73d648d 12 #ifndef _TRACKBALLER_
Nakor 0:2743c73d648d 13 #define _TRACKBALLER_
Nakor 0:2743c73d648d 14
Nakor 0:2743c73d648d 15 #include "mbed.h"
Nakor 0:2743c73d648d 16 //#include "PinDetect_m.h"
Nakor 0:2743c73d648d 17
Nakor 0:2743c73d648d 18 #define TRACK_INC 0.02
Nakor 0:2743c73d648d 19
Nakor 0:2743c73d648d 20
Nakor 1:0129b1984b5a 21
Nakor 0:2743c73d648d 22 class trackballer {
Nakor 0:2743c73d648d 23
Nakor 0:2743c73d648d 24 public:
Nakor 0:2743c73d648d 25
Nakor 0:2743c73d648d 26
Nakor 0:2743c73d648d 27
Nakor 1:0129b1984b5a 28
Nakor 0:2743c73d648d 29 trackballer(PinName button, PinName right, PinName down, PinName left, PinName up, PinName red, PinName green, PinName blue, PinName white);
Nakor 0:2743c73d648d 30
Nakor 0:2743c73d648d 31 void getDirection(float &xPosition, float &yPosition);
Nakor 0:2743c73d648d 32
Nakor 0:2743c73d648d 33
Nakor 0:2743c73d648d 34
Nakor 0:2743c73d648d 35
Nakor 0:2743c73d648d 36 protected:
Nakor 0:2743c73d648d 37 Timer _outputTimer;
Nakor 0:2743c73d648d 38
Nakor 0:2743c73d648d 39 DigitalIn * _buttonPin;
Nakor 0:2743c73d648d 40 DigitalIn * _rightPin;
Nakor 0:2743c73d648d 41 DigitalIn * _downPin;
Nakor 0:2743c73d648d 42 DigitalIn * _leftPin;
Nakor 0:2743c73d648d 43 DigitalIn * _upPin;
Nakor 0:2743c73d648d 44
Nakor 0:2743c73d648d 45 PwmOut * _redLED;
Nakor 0:2743c73d648d 46 PwmOut * _greenLED;
Nakor 0:2743c73d648d 47 PwmOut * _blueLED;
Nakor 0:2743c73d648d 48 PwmOut * _whiteLED;
Nakor 0:2743c73d648d 49
Nakor 0:2743c73d648d 50 int _buttonPushCounter; // counter for the number of button presses
Nakor 0:2743c73d648d 51
Nakor 0:2743c73d648d 52 char _buttonState; // current state of the button
Nakor 0:2743c73d648d 53 char _lastButtonState; // previous state of the button
Nakor 0:2743c73d648d 54
Nakor 0:2743c73d648d 55 char _upState;
Nakor 0:2743c73d648d 56 char _downState;
Nakor 0:2743c73d648d 57 char _leftState;
Nakor 0:2743c73d648d 58 char _rightState;
Nakor 0:2743c73d648d 59 char _lastUpState;
Nakor 0:2743c73d648d 60 char _lastDownState;
Nakor 0:2743c73d648d 61 char _lastLeftState;
Nakor 0:2743c73d648d 62 char _lastRightState;
Nakor 0:2743c73d648d 63
Nakor 0:2743c73d648d 64 float _xPosition;
Nakor 0:2743c73d648d 65 float _yPosition;
Nakor 0:2743c73d648d 66
Nakor 0:2743c73d648d 67
Nakor 0:2743c73d648d 68 char _direction;
Nakor 0:2743c73d648d 69
Nakor 0:2743c73d648d 70
Nakor 0:2743c73d648d 71 };
Nakor 0:2743c73d648d 72
Nakor 0:2743c73d648d 73 #endif