Filip Maksimovic HW2 repository
Dependencies: MMA8451Q TSI TextLCD USBDevice mbed tsi_sensor
Revision 0:6ee2b447a1c5, committed 2014-09-12
- Comitter:
- fil
- Date:
- Fri Sep 12 22:53:06 2014 +0000
- Child:
- 1:e6873017e1d2
- Commit message:
- this little piece of shit works;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8451Q.lib Fri Sep 12 22:53:06 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TSI.lib Fri Sep 12 22:53:06 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/TSI/#1a60ef257879
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Fri Sep 12 22:53:06 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/USBDevice/#335f2506f422
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Sep 12 22:53:06 2014 +0000 @@ -0,0 +1,55 @@ +#include "mbed.h" +#include "MMA8451Q.h" +#include "TSISensor.h" +#include "USBKeyboard.h" +#define MMA8451_I2C_ADDRESS (0x1d<<1) + +int main(void) { + MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); + TSISensor tsi; + PwmOut rled(LED_RED); + PwmOut gled(LED_GREEN); + PwmOut bled(LED_BLUE); + Serial pc(USBTX, USBRX); + USBKeyboard keyboard; + + rled = 1.0; bled = 0.0; gled = 1.0; + + // Begin the big fat fatty loop + while (1) { + gled = 1.0; bled = 0.0; rled = 1.0; + + // Instantiate the touch 'buffer' + int x[2] = {0,0}; + + // Get touch pad sensor reading + int t = tsi.readDistance(); + + // Test if the touch pad is being groped + x[0] = tsi.readDistance(); + + while(t != 0) { + gled = 0.0; + x[1] = x[0]; + x[0] = tsi.readDistance(); + // test for a left swipe + if (x[0] > x[1] + 20) { + // i swiped right + // key = spacebar + bled = 0.0; rled = 1.0; gled = 1.0; + keyboard.keyCode(' ',0); + } + // from experience, x[1] is the actual output 'value' booya :) + x[1] = x[0]; x[0] = tsi.readDistance(); + + if (tsi.readDistance() == 0) + break; // get out of the fucking loop you piece of shit + + // built-in loop delay + wait(0.1); + } + + // now i get into the nitty gritty - how do i extract the keys themselves + wait(0.1); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Sep 12 22:53:06 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsi_sensor.lib Fri Sep 12 22:53:06 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Kojto/code/tsi_sensor/#f64097679f27