USB HID Mouse demo for NXP Freedom Development Platform. Move automatically the mouse cursor circularly on the computer screen

Dependencies:   USBDevice mbed

Committer:
GregC
Date:
Thu Dec 31 17:03:42 2015 +0000
Revision:
0:004692590ee7
USB HID Mouse demo for NXP Freedom Development Platform. Move automatically the mouse cursor circularly on the computer screen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GregC 0:004692590ee7 1 #include "mbed.h"
GregC 0:004692590ee7 2 #include "USBMouse.h"
GregC 0:004692590ee7 3 #include <math.h>
GregC 0:004692590ee7 4
GregC 0:004692590ee7 5 USBMouse mouse(ABS_MOUSE);
GregC 0:004692590ee7 6
GregC 0:004692590ee7 7 int main(void)
GregC 0:004692590ee7 8 {
GregC 0:004692590ee7 9 uint16_t x_center = (X_MAX_ABS - X_MIN_ABS)/2;
GregC 0:004692590ee7 10 uint16_t y_center = (Y_MAX_ABS - Y_MIN_ABS)/2;
GregC 0:004692590ee7 11 uint16_t x_screen = 0;
GregC 0:004692590ee7 12 uint16_t y_screen = 0;
GregC 0:004692590ee7 13
GregC 0:004692590ee7 14 uint32_t x_origin = x_center;
GregC 0:004692590ee7 15 uint32_t y_origin = y_center;
GregC 0:004692590ee7 16 uint32_t radius = 5000;
GregC 0:004692590ee7 17 uint32_t angle = 0;
GregC 0:004692590ee7 18
GregC 0:004692590ee7 19 while (1)
GregC 0:004692590ee7 20 {
GregC 0:004692590ee7 21 x_screen = x_origin + cos((double)angle*3.14/180.0)*radius;
GregC 0:004692590ee7 22 y_screen = y_origin + sin((double)angle*3.14/180.0)*radius;
GregC 0:004692590ee7 23
GregC 0:004692590ee7 24 mouse.move(x_screen, y_screen);
GregC 0:004692590ee7 25 angle += 3;
GregC 0:004692590ee7 26 wait(0.01);
GregC 0:004692590ee7 27 }
GregC 0:004692590ee7 28 }