gamepad library
Fork of Gamepad by
Diff: Gamepad.h
- Revision:
- 11:ff86b2ffce01
- Parent:
- 10:a13d2f9d8a14
- Child:
- 12:1b0b6355da4f
--- a/Gamepad.h Tue Feb 07 11:53:37 2017 +0000 +++ b/Gamepad.h Thu Mar 02 18:34:42 2017 +0000 @@ -38,6 +38,45 @@ */ class Gamepad { +private: + PwmOut *_led1; + PwmOut *_led2; + PwmOut *_led3; + PwmOut *_led4; + PwmOut *_led5; + PwmOut *_led6; + + InterruptIn *_button_A; + InterruptIn *_button_B; + InterruptIn *_button_X; + InterruptIn *_button_Y; + InterruptIn *_button_back; + InterruptIn *_button_start; + InterruptIn *_button_L; + InterruptIn *_button_R; + InterruptIn *_button_joystick; + + AnalogIn *_vert; + AnalogIn *_horiz; + + PwmOut *_buzzer; + AnalogIn *_pot; + + Timeout *_timeout; + + bool _a_flag; + bool _b_flag; + bool _x_flag; + bool _y_flag; + bool _l_flag; + bool _r_flag; + bool _back_flag; + bool _start_flag; + bool _joy_flag; + + // centred x,y values + float _x0; + float _y0; public: @@ -59,7 +98,7 @@ /** Set all LEDs to duty-cycle *@param value in range 0.0 to 1.0 */ - void leds(float val); + void leds(float val) const; /** Set LED to duty-cycle *@param value in range 0.0 to 1.0 @@ -94,7 +133,7 @@ /** Read potentiometer *@returns potentiometer value in range 0.0 to 1.0 */ - float read_pot(); + float read_pot() const; /** Play tone on piezo * @param frequency in Hz @@ -179,32 +218,6 @@ Polar get_polar(); // mag and angle in struct form private: - - PwmOut *_led1; - PwmOut *_led2; - PwmOut *_led3; - PwmOut *_led4; - PwmOut *_led5; - PwmOut *_led6; - - InterruptIn *button_A; - InterruptIn *button_B; - InterruptIn *button_X; - InterruptIn *button_Y; - InterruptIn *button_back; - InterruptIn *button_start; - InterruptIn *button_L; - InterruptIn *button_R; - InterruptIn *button_joystick; - - AnalogIn *vert; - AnalogIn *horiz; - - PwmOut *buzzer; - AnalogIn *pot; - - Timeout *timeout; - void init_buttons(); void tone_off(); @@ -217,12 +230,6 @@ void back_isr(); void start_isr(); void joy_isr(); - - bool a_flag,b_flag,x_flag,y_flag,l_flag,r_flag,back_flag,start_flag,joy_flag; - - // centred x,y values - float _x0; - float _y0; }; #endif \ No newline at end of file