FRDM-K64 USB air mouse demo
Dependencies: FXOS8700Q USBDevice mbed
main.cpp@0:d50fb46005fd, 2014-07-09 (annotated)
- Committer:
- APanecatl
- Date:
- Wed Jul 09 19:33:09 2014 +0000
- Revision:
- 0:d50fb46005fd
rev 1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
APanecatl | 0:d50fb46005fd | 1 | #include "mbed.h" |
APanecatl | 0:d50fb46005fd | 2 | #include "USBMouse.h" |
APanecatl | 0:d50fb46005fd | 3 | #include "FXOS8700Q.h" |
APanecatl | 0:d50fb46005fd | 4 | |
APanecatl | 0:d50fb46005fd | 5 | //I2C lines for FXOS8700Q accelerometer/magnetometer |
APanecatl | 0:d50fb46005fd | 6 | FXOS8700Q_acc acc( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); |
APanecatl | 0:d50fb46005fd | 7 | |
APanecatl | 0:d50fb46005fd | 8 | USBMouse mouse; |
APanecatl | 0:d50fb46005fd | 9 | |
APanecatl | 0:d50fb46005fd | 10 | int main() |
APanecatl | 0:d50fb46005fd | 11 | { |
APanecatl | 0:d50fb46005fd | 12 | acc.enable(); |
APanecatl | 0:d50fb46005fd | 13 | float faX, faY, faZ; |
APanecatl | 0:d50fb46005fd | 14 | int16_t x = 0; |
APanecatl | 0:d50fb46005fd | 15 | int16_t y = 0; |
APanecatl | 0:d50fb46005fd | 16 | |
APanecatl | 0:d50fb46005fd | 17 | while (1) |
APanecatl | 0:d50fb46005fd | 18 | { |
APanecatl | 0:d50fb46005fd | 19 | //acc.getAxis(acc_data); |
APanecatl | 0:d50fb46005fd | 20 | acc.getX(&faX); |
APanecatl | 0:d50fb46005fd | 21 | acc.getY(&faY); |
APanecatl | 0:d50fb46005fd | 22 | x = 10*faX; |
APanecatl | 0:d50fb46005fd | 23 | y = 10*faY; |
APanecatl | 0:d50fb46005fd | 24 | |
APanecatl | 0:d50fb46005fd | 25 | mouse.move(x, y); |
APanecatl | 0:d50fb46005fd | 26 | wait(0.001); |
APanecatl | 0:d50fb46005fd | 27 | } |
APanecatl | 0:d50fb46005fd | 28 | } |