ELEC2645 (2018/19) / Mbed 2 deprecated el17yfk

Dependencies:   mbed FXOS8700CQ mbed-rtos

Revision:
12:71683453f66a
Parent:
0:1da4db5de653
Child:
22:f8f36e88b2ca
--- a/Gamepad/Gamepad.cpp	Sun Apr 14 15:56:58 2019 +0000
+++ b/Gamepad/Gamepad.cpp	Mon Apr 15 01:38:53 2019 +0000
@@ -194,6 +194,29 @@
     return d;
 }
 
+void Gamepad::init_input()
+{
+    // turn on pull-downs as other side of button is connected to 3V3
+    // button is 0 when not pressed and 1 when pressed
+    _button_A->mode(PullDown);
+    _button_B->mode(PullDown);
+    _button_X->mode(PullDown);
+    _button_Y->mode(PullDown);
+    _button_back->mode(PullDown);
+    _button_start->mode(PullDown);
+    _button_L->mode(PullDown);
+    _button_R->mode(PullDown);
+    // therefore setup rising edge interrupts
+    _button_A->rise(callback(this,&Gamepad::a_isr));
+    _button_B->rise(callback(this,&Gamepad::b_isr));
+    _button_X->rise(callback(this,&Gamepad::x_isr));
+    _button_Y->rise(callback(this,&Gamepad::y_isr));
+    _button_L->rise(callback(this,&Gamepad::l_isr));
+    _button_R->rise(callback(this,&Gamepad::r_isr));
+    _button_start->rise(callback(this,&Gamepad::start_isr));
+    _button_back->rise(callback(this,&Gamepad::back_isr));
+}
+
 ///////////////////// private methods ////////////////////////
 
 void Gamepad::tone_off()