by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
main.cpp@0:e339343b3624, 2013-06-16 (annotated)
- Committer:
- robt
- Date:
- Sun Jun 16 15:30:33 2013 +0000
- Revision:
- 0:e339343b3624
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
robt | 0:e339343b3624 | 1 | /* Program Example 12.5: Emulating a USB mouse |
robt | 0:e339343b3624 | 2 | */ |
robt | 0:e339343b3624 | 3 | #include "mbed.h" // include mbed library |
robt | 0:e339343b3624 | 4 | #include "USBMouse.h" // include USB Mouse library |
robt | 0:e339343b3624 | 5 | USBMouse mouse; // define USBMouse interface |
robt | 0:e339343b3624 | 6 | |
robt | 0:e339343b3624 | 7 | int dx[]={40,0,-40,0}; // relative x position co-ordinates |
robt | 0:e339343b3624 | 8 | int dy[]={0,40,0,-40}; // relative y position co-ordinates |
robt | 0:e339343b3624 | 9 | |
robt | 0:e339343b3624 | 10 | int main() { |
robt | 0:e339343b3624 | 11 | while (1) { |
robt | 0:e339343b3624 | 12 | for (int i=0; i<4; i++) { // scroll through position co-ordinates |
robt | 0:e339343b3624 | 13 | mouse.move(dx[i],dy[i]); // move mouse to co-ordinate |
robt | 0:e339343b3624 | 14 | wait(0.2); |
robt | 0:e339343b3624 | 15 | } |
robt | 0:e339343b3624 | 16 | } |
robt | 0:e339343b3624 | 17 | } |
robt | 0:e339343b3624 | 18 |