![](/media/cache/profiles/3dfcfb71d7f99a7b4dfa8cd7081c5e0b.jpg.50x50_q85.jpg)
FRDM-K64 USB air mouse demo
Dependencies: FXOS8700Q USBDevice mbed
Fork of FRDM-K64_USB by
USB air mouse demo modified USB Analog Joystick with Low Power Mode Demo
Diff: main.cpp
- Revision:
- 1:b9ea91c4c533
- Parent:
- 0:d50fb46005fd
- Child:
- 2:cb6377d909e0
diff -r d50fb46005fd -r b9ea91c4c533 main.cpp --- a/main.cpp Wed Jul 09 19:33:09 2014 +0000 +++ b/main.cpp Mon Jun 22 20:17:43 2015 +0000 @@ -1,28 +1,44 @@ #include "mbed.h" #include "USBMouse.h" -#include "FXOS8700Q.h" -//I2C lines for FXOS8700Q accelerometer/magnetometer -FXOS8700Q_acc acc( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); +DigitalIn RightClick(PTC6); +DigitalIn LeftClick(PTA4); +DigitalIn Click(PTC10); +DigitalOut BlueLed(LED3); USBMouse mouse; - + +AnalogIn AnIn0(A0); +AnalogIn AnIn1(A1); + int main() { - acc.enable(); - float faX, faY, faZ; + float posx, posy; + float pposx, pposy; int16_t x = 0; int16_t y = 0; + Click.mode(PullUp); while (1) { - //acc.getAxis(acc_data); - acc.getX(&faX); - acc.getY(&faY); - x = 10*faX; - y = 10*faY; + if(LeftClick) mouse.release(MOUSE_LEFT); + else mouse.press(MOUSE_LEFT); + + if(RightClick) mouse.release(MOUSE_RIGHT); + else mouse.press(MOUSE_RIGHT); + + BlueLed = Click; + posx=AnIn0.read(); + posy=AnIn1.read(); + x = -800*(posx-pposx); + y = 800*(posy-pposy); + mouse.move(x, y); - wait(0.001); + + pposx = posx; + pposy = posy; + + wait(0.01); } } \ No newline at end of file