Class to interface with Sparkfun's Blackberry Trackball Breakout Board.
Dependents: BBTrackball_Sample
Revision 2:7715a78a7175, committed 2011-12-09
- Comitter:
- AdamGreen
- Date:
- Fri Dec 09 19:25:47 2011 +0000
- Parent:
- 1:94c8e1e74dc1
- Commit message:
Changed in this revision
BBTrackball.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/BBTrackball.h Fri Dec 09 19:07:54 2011 +0000 +++ b/BBTrackball.h Fri Dec 09 19:25:47 2011 +0000 @@ -45,12 +45,43 @@ * Example: * @code #include <mbed.h> +#include <USBMouse.h> #include "BBTrackball.h" int main() { - // UNDONE: Add something to this section. - return 0; + static const CBBTrackball::SColour GreenColour = { 0, 255, 0, 0 }; + static CBBTrackball Trackball(p20, // BLU + p25, // RED + p26, // GRN + p10, // WHT + p5, // UP + p6, // DWN + p7, // LFT + p8, // RHT + p9); // BTN + static USBMouse Mouse; + + // Turn the green LED on. + Trackball.SetColour(&GreenColour); + + for(;;) + { + CBBTrackball::SState TrackballState; + int DeltaX; + int DeltaY; + + Trackball.GetState(&TrackballState); + + // NOTE: The breakout board is rotated 90 degrees on my breadboard. + DeltaX = TrackballState.Up - TrackballState.Down; + DeltaY = TrackballState.Right - TrackballState.Left; + + Mouse.update(DeltaX, + DeltaY, + TrackballState.ButtonPressed ? MOUSE_LEFT : 0, + 0); + } } * @endcode */ @@ -89,13 +120,21 @@ * pins, and initializes the required interrupt handling. * * @param BluePin The mbed pin which is connected to the BLU pin of the breakout board. + * Must be a pin on which the mbed supports PwmOut. * @param RedPin The mbed pin which is connected to the RED pin of the breakout board. + * Must be a pin on which the mbed supports PwmOut. * @param GreenPin The mbed pin which is connected to the GRN pin of the breakout board. + * Must be a pin on which the mbed supports PwmOut. * @param WhitePin The mbed pin which is connected to the WHT pin of the breakout board. + * Must be a pin on which the mbed supports PwmOut. * @param UpPin The mbed pin which is connected to the UP pin of the breakout board. + * Must be a pin on which the mbed supports InterruptIn. * @param DownPin The mbed pin which is connected to the DWN pin of the breakout board. + * Must be a pin on which the mbed supports InterruptIn. * @param LeftPin The mbed pin which is connected to the LFT pin of the breakout board. + * Must be a pin on which the mbed supports InterruptIn. * @param RightPin The mbed pin which is connected to the RHT pin of the breakout board. + * Must be a pin on which the mbed supports InterruptIn. * @param ButtonPin The mbed pin which is connected to the BTN pin of the breakout board. */ CBBTrackball(PinName BluePin,