Library for Sparkfun analog joystick
Fork of SparkfunAnalogJoystick by
Revision 4:98f381ce9b3a, committed 2016-04-26
- Comitter:
- Mpmart08
- Date:
- Tue Apr 26 18:24:37 2016 +0000
- Parent:
- 3:2b40241a7675
- Commit message:
- stuff
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 2b40241a7675 -r 98f381ce9b3a SparkfunAnalogJoystick.cpp --- a/SparkfunAnalogJoystick.cpp Mon Mar 09 21:11:22 2015 +0000 +++ b/SparkfunAnalogJoystick.cpp Tue Apr 26 18:24:37 2016 +0000 @@ -28,7 +28,11 @@ //! Y axis value float SparkfunAnalogJoystick::yAxis(){ - return (VERT-0.5)*2; + float val = (VERT-0.5)*2; + if (val < 0) + return val * 10.0/9.0; + else + return val; } //! Calculate the angle value in a polar coordinate system @@ -57,5 +61,10 @@ float maxdistance=sqrt(1+oneAxis*oneAxis); float temp=horz*horz+vert*vert; return sqrt(temp)/maxdistance; +} -} \ No newline at end of file +// set callback function for select button +//void SparkfunAnalogJoystick::set_callback(void (*select_hit_callback)(void)) { +// SEL.attach_deasserted(select_hit_callback); +// SEL.setSampleFrequency(); +//} \ No newline at end of file
diff -r 2b40241a7675 -r 98f381ce9b3a SparkfunAnalogJoystick.h --- a/SparkfunAnalogJoystick.h Mon Mar 09 21:11:22 2015 +0000 +++ b/SparkfunAnalogJoystick.h Tue Apr 26 18:24:37 2016 +0000 @@ -8,6 +8,7 @@ #define SPARKFUN_ANALOG_JOYSTICK #include "mbed.h" +#include "PinDetect.h" /** Joystick class. * User Interface to use Sparkfun Joystick Module @@ -28,10 +29,13 @@ float angle(); // Distance value in polar coordinates float distance(); + // select callback function + //void set_callback(void (*select_hit_callback)(void)); protected: AnalogIn VERT; AnalogIn HORZ; + //PinDetect SEL; DigitalIn SEL; };