Kenji Arai / Mbed OS Change_USBMSD_and_USBSerial
Revision:
0:c6dea1f647f6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/2_USB_Mouse/main.cpp	Mon Jan 06 10:56:13 2020 +0000
@@ -0,0 +1,27 @@
+//#define EXAMPLE_2_MOUSE
+#ifdef EXAMPLE_2_MOUSE
+
+#include "mbed.h"
+#include "USBMouse.h"
+
+USBMouse mouse;
+
+int main() {
+    int16_t x = 0;
+    int16_t y = 0;
+    int32_t radius = 10;
+    int32_t angle = 0;
+
+    while (true) {
+        //will cause mouse to move in a circle
+        x = cos((double)angle*3.14/180.0)*radius;
+        y = sin((double)angle*3.14/180.0)*radius;
+
+        //will move mouse x, y away from its previous position on the screen
+        mouse.move(x, y);
+        angle += 3;
+        ThisThread::sleep_for(1);
+    }
+}
+
+#endif  // EXAMPLE_2_MOUSE