lol

Dependencies:   MMA8451Q

Fork of Application by Mateusz Kowalik

Files at this revision

API Documentation at this revision

Comitter:
danix
Date:
Sun Jan 21 22:28:30 2018 +0000
Parent:
11:b3f2a8bdac4d
Commit message:
Working acelerometer and mouse

Changed in this revision

MMA8451Q.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Sun Jan 21 22:28:30 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
--- a/main.cpp	Sat Dec 16 10:26:48 2017 +0000
+++ b/main.cpp	Sun Jan 21 22:28:30 2018 +0000
@@ -1,28 +1,24 @@
 #include "mbed.h"
+#include "USBMouse.h"
 #include "USBSerial.h"
+#include "MMA8451Q.h"
 
 DigitalOut  myled(LED1);
-
+USBMouse mouse;
+//USBSerial serial;
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+  
 int main() {
-    //confSysClock();     //Configure system clock (72MHz HSE clock, 48MHz USB clock)
-    //SYSTEM CLOCK changed in stm32f4xx_hal.c
-    USBSerial usbSerial;
-    Serial serial(PTE20, PTE21);
-    
-    
-    while(1) {
-        if(serial.readable())
-        {
-            //usbSerial.putc(serial.getc());
-        }
-        myled = !myled;
-        if(usbSerial.readable()) //if there is any character to read from usbSerial
-        {
-        usbSerial.putc('c');
-          usbSerial.putc('h');
-          usbSerial.putc('u');
-          usbSerial.putc('j');
-           usbSerial.getc();           
-        }
+    //USBSerial usbSerial;
+MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+    float x, y, z;
+
+    while (1) {
+        x = (acc.getAccX()*10);
+        y = (acc.getAccY()*10);
+        z = (acc.getAccZ()*10);
+        printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n", x, y, z);
+        mouse.move(x, y);
+        wait(0.01);
     }
 }
\ No newline at end of file