gamepad library
Fork of Gamepad by
Diff: Gamepad.h
- Revision:
- 1:6d25cd49059b
- Parent:
- 0:a6288c29b936
- Child:
- 3:964a6d95acdd
diff -r a6288c29b936 -r 6d25cd49059b Gamepad.h --- a/Gamepad.h Sat Feb 04 15:31:44 2017 +0000 +++ b/Gamepad.h Sat Feb 04 16:13:18 2017 +0000 @@ -11,12 +11,26 @@ public: Gamepad(); + ~Gamepad(); N5110 *lcd; Joystick *joystick; void init(); void leds_on(); void leds_off(); + void fade_leds(float val); + + float read_pot(); + void tone(float frequency, float duration); + + bool a_pressed(); + bool b_pressed(); + bool x_pressed(); + bool y_pressed(); + bool l_pressed(); + bool r_pressed(); + bool back_pressed(); + bool start_pressed(); private: @@ -27,17 +41,32 @@ PwmOut *led_5; PwmOut *led_6; - InterruptIn *button_A(PTB9); - InterruptIn *button_B(D10); - InterruptIn *button_X(PTC17); - InterruptIn *button_Y(PTC12); // changed pin - InterruptIn *button_back(PTB19); - InterruptIn *button_start(PTC5); - InterruptIn *button_L(PTB18); - InterruptIn *button_R(PTB3); - - PwmOut *buzzer(PTC10); - AnalogIn *pot(PTB2); + InterruptIn *button_A; + InterruptIn *button_B; + InterruptIn *button_X; + InterruptIn *button_Y; // changed pin + InterruptIn *button_back; + InterruptIn *button_start; + InterruptIn *button_L; + InterruptIn *button_R; + + PwmOut *buzzer; + AnalogIn *pot; + + Timeout *timeout; + + void init_buttons(); + void tone_off(); + void a_isr(); + void b_isr(); + void x_isr(); + void y_isr(); + void l_isr(); + void r_isr(); + void back_isr(); + void start_isr(); + + bool a_flag,b_flag,x_flag,y_flag,l_flag,r_flag,back_flag,start_flag; };