Analog joystick library
Diff: Joystick.h
- Revision:
- 1:8e384c3393dd
- Parent:
- 0:649b59b2fb26
--- a/Joystick.h Tue Feb 07 13:01:48 2017 +0000 +++ b/Joystick.h Mon Jan 27 15:28:02 2020 +0000 @@ -41,7 +41,7 @@ #include "Joystick.h" // y x button -Joystick joystick(PTB10,PTB11,PTC16); +Joystick joystick(PTB11,PTB10); int main() { @@ -61,10 +61,7 @@ Direction d = joystick.get_direction(); printf("Direction = %i\n",d); - - if (joystick.button_pressed() ) { - printf("Button Pressed\n"); - } + wait(0.5); } @@ -78,8 +75,8 @@ { public: - // y-pot x-pot button - Joystick(PinName vertPin,PinName horizPin,PinName clickPin); + // y-pot x-pot + Joystick(PinName vertPin,PinName horizPin); void init(); // needs to be called at start with joystick centred float get_mag(); // polar @@ -88,16 +85,11 @@ Vector2D get_mapped_coord(); // x,y mapped to circle Direction get_direction(); // N,NE,E,SE etc. Polar get_polar(); // mag and angle in struct form - bool button_pressed(); // read button flag set in ISR when button pressed private: AnalogIn *vert; AnalogIn *horiz; - InterruptIn *click; - - int _click_flag; // flag set in ISR - void click_isr(); // ISR on button press // centred x,y values float _x0;