Analog Joystick Library
Fork of SparkfunAnalogJoystick by
Revision 3:2b40241a7675, committed 2015-03-09
- Comitter:
- happinesstaker
- Date:
- Mon Mar 09 21:11:22 2015 +0000
- Parent:
- 2:4761030c1a7d
- Commit message:
- Doxygen Added
Changed in this revision
SparkfunAnalogJoystick.cpp | Show annotated file Show diff for this revision Revisions of this file |
SparkfunAnalogJoystick.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4761030c1a7d -r 2b40241a7675 SparkfunAnalogJoystick.cpp --- a/SparkfunAnalogJoystick.cpp Mon Mar 09 21:01:23 2015 +0000 +++ b/SparkfunAnalogJoystick.cpp Mon Mar 09 21:11:22 2015 +0000 @@ -9,30 +9,29 @@ #define M_PI 3.14159265358979323846 -/** My HelloWorld class. - * Used for printing "Hello World" on USB serial. +/** Constructor of Joystick object */ SparkfunAnalogJoystick::SparkfunAnalogJoystick(PinName vert, PinName horz, PinName sel): VERT(vert), HORZ(horz), SEL(sel) { SEL.mode(PullUp); } -// Get the button status +//! Get the button status int SparkfunAnalogJoystick::button(){ return 1-SEL; } -// X axis value, reverse the value to get the x value in a normal Cartesian coordinate system +//! X axis value, reverse the value to get the x value in a normal Cartesian coordinate system float SparkfunAnalogJoystick::xAxis(){ return -(HORZ-0.5)*2; } -// Y axis value +//! Y axis value float SparkfunAnalogJoystick::yAxis(){ return (VERT-0.5)*2; } -// Calculate the angle value in a polar coordinate system +//! Calculate the angle value in a polar coordinate system float SparkfunAnalogJoystick::angle(){ float horz=-(HORZ-0.5)*2; float vert=(VERT-0.5)*2; @@ -47,7 +46,7 @@ return angle; } -// Calculate the normalized distance value in a polar coordinate system +//! Calculate the normalized distance value in a polar coordinate system float SparkfunAnalogJoystick::distance(){ float horz=-(HORZ-0.5)*2; float vert=(VERT-0.5)*2;
diff -r 4761030c1a7d -r 2b40241a7675 SparkfunAnalogJoystick.h --- a/SparkfunAnalogJoystick.h Mon Mar 09 21:01:23 2015 +0000 +++ b/SparkfunAnalogJoystick.h Mon Mar 09 21:11:22 2015 +0000 @@ -1,13 +1,22 @@ +/** Analog Joystick APIs + * Used as a user interface for Sparkfun Analog Joystick Module + * @file SparkfunAnalogJoystick.h + * @author Yuan,ZHANG; Jiajie,YANG + */ + #ifndef SPARKFUN_ANALOG_JOYSTICK #define SPARKFUN_ANALOG_JOYSTICK #include "mbed.h" +/** Joystick class. + * User Interface to use Sparkfun Joystick Module + */ class SparkfunAnalogJoystick { public: - // Constructor + // Constructor of Joystick object SparkfunAnalogJoystick(PinName, PinName, PinName); // Get the button status, 1 for on and 0 for off int button();