Referred coursework template 2019

Dependencies:   X_NUCLEO_IKS01A3 USBDevice

Revision:
5:9a6db486eca9
Parent:
3:9f8fadc965fc
--- a/main.cpp	Mon Jun 03 09:58:27 2019 +0000
+++ b/main.cpp	Fri Jul 19 13:56:50 2019 +0000
@@ -39,6 +39,7 @@
 /* Includes */
 #include "mbed.h"
 #include "XNucleoIKS01A3.h"
+#include "USBMouse.h"
 
 /* Instantiate the expansion board */
 static XNucleoIKS01A3 *mems_expansion_board = XNucleoIKS01A3::instance(D14, D15, D4, D5, A3, D6, A4);
@@ -87,6 +88,8 @@
   return str;
 }
 
+USBMouse mouse;
+
 /* Simple main function */
 int main() {
   uint8_t id;
@@ -94,6 +97,11 @@
   char buffer1[32], buffer2[32];
   int32_t axes[3];
   
+    int16_t x = 0;
+    int16_t y = 0;
+    int32_t radius = 10;
+    int32_t angle = 0;
+  
   /* Enable all sensors */
   hum_temp->enable();
   press_temp->enable();
@@ -146,6 +154,12 @@
     acc_gyro->get_g_axes(axes);
     printf("LSM6DSO [gyro/mdps]:   %6d, %6d, %6d\r\n", axes[0], axes[1], axes[2]);
 
-    wait(1.5);
+    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;
+    wait(0.001);
   }
 }