A class to handle reading, scaling and filtering horizontal and vertical position, and rise/fall interrupts for the button.
Diff: Joystick.h
- Revision:
- 2:8805f880e231
- Parent:
- 1:e55694d8a418
- Child:
- 3:83b40e07476f
diff -r e55694d8a418 -r 8805f880e231 Joystick.h --- a/Joystick.h Tue Sep 28 15:01:13 2010 +0000 +++ b/Joystick.h Tue Sep 28 15:04:50 2010 +0000 @@ -5,23 +5,29 @@ //required to use mbed functions #include "mbed.h" +/** Struct: joyhv + * + * Used for holding a horizontal and vertical position as doubles + */ struct joyhv { double h; double v; }; /** Class: Joystick + * * Used for reading from an analog joystick * * Example: + * * > #include "mbed.h" + * * > Joystick joy(p20, p19, p18); */ class Joystick { public: /** Constructor: Joystick - * * * Variables: * b - DigitalIn pin for button @@ -30,7 +36,7 @@ */ Joystick(PinName b, PinName h, PinName v); - /* Function: read + /** Function: read * Read the joystick position, represented as a joyhv value - h and v are doubles in the range [0.0, 1.0] * * Variables: @@ -39,7 +45,7 @@ */ joyhv read(); - /* Function: getV + /** Function: getV * Read the joystick's vertical position, represented as a double value in the range [0.0, 1.0] * * Variables: @@ -48,7 +54,7 @@ */ double getV(); - /* Function: getH + /** Function: getH * Read the joystick's horizontal position, represented as a double value in the range [0.0, 1.0] * * Variables: @@ -57,7 +63,7 @@ */ double getH(); - /* Function: rise + /** Function: rise * Attach a function to call when a rising edge occurs on the button input * * Variables: @@ -65,7 +71,7 @@ */ void rise (void (*fptr)(void)); - /* Function: fall + /** Function: fall * Attach a function to call when a falling edge occurs on the button input * * Variables: @@ -73,7 +79,7 @@ */ void fall (void (*fptr)(void)); - /* Function: operator joyhv + /** Function: operator joyhv * An operator shorthand for <read()> * * The joyhv() operator can be used as a shorthand for <read()> to simplify common code sequences