Adventure game written for ECE2035 at the Georgia Institute of Technology

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Revision:
4:cdc54191ff07
Parent:
2:0876296d9473
--- a/hardware.cpp	Wed Apr 18 20:18:51 2018 +0000
+++ b/hardware.cpp	Tue May 22 19:13:03 2018 +0000
@@ -4,6 +4,8 @@
 #include "globals.h"
 
 #include "hardware.h"
+#include "mbed.h"
+
 
 // We need to actually instantiate all of the globals (i.e. declare them once
 // without the extern keyword). That's what this file does!
@@ -36,14 +38,36 @@
     return ERROR_NONE;
 }
 
+int butt1;
+
+void debounce(){
+    int _counter = 0;
+    int _samples = 10;
+    int _shadow = 0;
+    
+    if (!button1) { 
+        if (_counter < _samples) _counter++; 
+        if (_counter == _samples) _shadow = 1; 
+    }
+    else { 
+        if (_counter > 0) _counter--; 
+        if (_counter == 0) _shadow = 0; 
+    }
+    butt1 = _shadow;
+}
+
 GameInputs read_inputs() 
 {
+    Ticker ticker;
+    //ticker.attach(&debounce, 1000);
     GameInputs in;
     acc.readXGravity(&in.ax);
     acc.readYGravity(&in.ay);
     acc.readZGravity(&in.az);
-    //uLCD.printf("%f\n", in.ax);
-    in.b1 = button1;
+    //uLCD.locate(1,1);
+    //uLCD.printf("%f\n", butt1);
+    
+    in.b1 = button1;//butt1;
     in.b2 = button2;
     in.b3 = button3;
     return in;