Roomba that displays room data to a C# GUI

Dependencies:   LSM9DS1_Library_cal mbed

Fork of 4180Lab2Part4 by James Plager

Revision:
1:aeb42bbdac27
Parent:
0:e693d5bf0a25
Child:
2:516dd8a72972
diff -r e693d5bf0a25 -r aeb42bbdac27 main.cpp
--- a/main.cpp	Wed Feb 03 18:47:07 2016 +0000
+++ b/main.cpp	Wed Mar 01 06:01:10 2017 +0000
@@ -1,5 +1,6 @@
 #include "mbed.h"
 #include "LSM9DS1.h"
+#include "uLCD_4DGL.h"
 #define PI 3.14159
 // Earth's magnetic field varies by location. Add or subtract
 // a declination to get a more accurate heading. Calculate
@@ -9,6 +10,7 @@
 
 DigitalOut myled(LED1);
 Serial pc(USBTX, USBRX);
+uLCD_4DGL uLCD(p28,p27,p29);
 // Calculate pitch, roll, and heading.
 // Pitch/roll calculations taken from this app note:
 // http://cache.freescale.com/files/sensors/doc/app_note/AN3461.pdf?fpsp=1
@@ -41,13 +43,15 @@
     pc.printf("Magnetic Heading: %f degress\n\r",heading);
 }
 
-
-
+float tempX = 0.0;
+float tempY = 0.0;
+float oldtempX;
+float oldtempY;
 
 int main()
 {
-    //LSM9DS1 lol(p9, p10, 0x6B, 0x1E);
-    LSM9DS1 IMU(p28, p27, 0xD6, 0x3C);
+    LSM9DS1 IMU(p9, p10, 0xd6, 0x3c);
+    //LSM9DS1 IMU(p28, p27, 0xD6, 0x3C);
     IMU.begin();
     if (!IMU.begin()) {
         pc.printf("Failed to communicate with LSM9DS1.\n");
@@ -55,6 +59,11 @@
     IMU.calibrate(1);
     IMU.calibrateMag(0);
     while(1) {
+        
+        uLCD.locate(25,25);
+    //uLCD.color(WHITE);
+    uLCD.circle(64,64,60,0xFFFFFF);
+    
         while(!IMU.tempAvailable());
         IMU.readTemp();
         while(!IMU.magAvailable(X_AXIS));
@@ -74,6 +83,18 @@
         wait(0.5);
         myled = 0;
         wait(0.5);
+        
+        oldtempX = tempX;
+        oldtempY = tempY;
+        uLCD.filled_circle(floor(128*oldtempX), floor(128*oldtempY), 6, 0x000000);    // erase old bubble
+        tempX = IMU.calcAccel(IMU.ax);
+        tempX = (tempX+1.0)/2.0;
+        tempY = IMU.calcAccel(IMU.ay);
+        tempY = (tempY+1.0)/2.0;
+        //draw filled circle based on info from IMU
+        //draw new bubble
+        uLCD.filled_circle(floor(128*tempX), floor(128*tempY), 6, 0xFFFFFF);
+        
     }
 }