w4spiusbmouse
Dependencies: FXOS8700Q USBDevice mbed
Revision 0:5030214d976d, committed 2017-01-12
- Comitter:
- occle
- Date:
- Thu Jan 12 15:46:35 2017 +0000
- Commit message:
- w4spiusbmouse
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FXOS8700Q.lib Thu Jan 12 15:46:35 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/JimCarver/code/FXOS8700Q/#5553a64d0762
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Thu Jan 12 15:46:35 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/USBDevice/#0c6524151939
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jan 12 15:46:35 2017 +0000 @@ -0,0 +1,43 @@ +#include "mbed.h" +#include "USBMouse.h" +#include "FXOS8700Q.h" + +//I2C lines for FXOS8700Q accelerometer/magnetometer +FXOS8700Q_acc acc( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); +DigitalIn leftbutton(SW2); //SW2 will be assigned to the left mouse button +DigitalIn rightbutton(SW3); //SW3 will be assigned to the right mouse button + + +USBMouse mouse; + +int main() +{ + acc.enable(); //enable the accelerometer + float faX, faY, faZ; + int16_t x = 0; + int16_t y = 0; + + while (1) + { + //acc.getAxis(acc_data); + acc.getX(&faX); + acc.getY(&faY); + acc.getZ(&faZ); + x = 10*faX; + y = 10*faY; + + mouse.move(x, y); //move mouse dependant on the postion of the rotation of the mbed + + if(leftbutton==0){ + mouse.press(MOUSE_LEFT); + } + else{mouse.release(MOUSE_LEFT);} + + if(rightbutton==0){ + mouse.press(MOUSE_RIGHT); + } + else{mouse.release(MOUSE_RIGHT);} + + wait(0.001); //updates position every 0.001 seconds + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jan 12 15:46:35 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/024bf7f99721 \ No newline at end of file