Lab2Part3

Dependencies:   4DGL-uLCD-SE LSM9DS1_Library_cal mbed

Files at this revision

API Documentation at this revision

Comitter:
bdragon52
Date:
Wed Sep 13 21:14:04 2017 +0000
Commit message:
lab2part3

Changed in this revision

4DGL-uLCD-SE.lib Show annotated file Show diff for this revision Revisions of this file
LSM9DS1_Library_cal.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 98e654b8abce 4DGL-uLCD-SE.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/4DGL-uLCD-SE.lib	Wed Sep 13 21:14:04 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ECE-4180-Labs1/code/4DGL-uLCD-SE/#64a1accfbcac
diff -r 000000000000 -r 98e654b8abce LSM9DS1_Library_cal.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LSM9DS1_Library_cal.lib	Wed Sep 13 21:14:04 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/4180_1/code/LSM9DS1_Library_cal/#36abf8e18ade
diff -r 000000000000 -r 98e654b8abce main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Sep 13 21:14:04 2017 +0000
@@ -0,0 +1,143 @@
+#include "mbed.h"
+#include "uLCD_4DGL.h"
+#include "LSM9DS1.h"
+
+ 
+uLCD_4DGL uLCD(p28,p27,p30); // serial tx, serial rx, reset pin;
+Serial pc(USBTX, USBRX);
+LSM9DS1 imu(p9, p10, 0xD6, 0x3C); 
+
+int main()
+{
+    
+    
+    //void readAccel();
+ 
+/**
+*Read the accelerometer output registers.
+*This function will read all six accelerometer output registers.
+*The readings are stored in the class' ax, ay, and az variables. Read
+*those _after_ calling readAccel().
+**/
+
+    imu.begin();
+    if (!imu.begin()) {
+       
+    }
+    imu.calibrate();
+
+
+    
+    int x=64,y=64;
+    uLCD.background_color(BLACK);
+    
+    uLCD.filled_circle(64, 64, 45, BLUE);
+    uLCD.filled_circle(64, 64, 43, BLACK);
+    uLCD.filled_circle(64, 64, 12, BLUE);
+    uLCD.filled_circle(64, 64, 10, BLACK);
+    
+     uLCD.filled_circle(x, y, 8, YELLOW);
+        //bounce off edge walls and slow down a bit?
+   while(1){
+        float oldx=x;
+        float oldy=y;
+        imu.readAccel();
+        float accX=imu.ax;
+        float accY=imu.ay;
+        
+        //0 15800
+        //64 128
+        
+        //247
+        if(accX>0){
+           x=oldx+2;
+            }
+        if(accX<0){
+           x=oldx-2;
+            }
+            
+         if(accY>0){
+            y=oldy+2;
+            }
+        if(accY<0){
+            y=oldy-2;
+            }
+
+
+          
+
+       if(x>(x/109)){
+            x=64+(accX/(200));
+            }
+
+        if(x<(x/109)){
+            x=64-(accX/200);
+            }
+         
+       if(y>(y/109)){
+            y=64+(accY/200);
+            }
+
+        if(y<(y/109)){
+            y=64-(accY/200);
+            }
+               
+
+
+
+
+
+
+
+
+
+
+
+
+
+ //x=64+15800/(4*x);
+ // x=64-15800/(4*x);       
+        if(x<32){
+            x=32;
+            }
+
+        if(x>96){
+            x=96;
+            }
+            
+         if(y<32){
+            y=32;
+            }
+
+        if(y>96){
+            y=96;
+            }
+               
+            
+            
+            
+       int posx=x;
+       int posy=y;
+       uLCD.filled_circle(oldx, oldy, 8, BLACK);
+       uLCD.filled_circle(64, 64, 12, BLUE);
+       uLCD.filled_circle(64, 64, 10, BLACK);
+       uLCD.filled_circle(posx, posy, 8, YELLOW);
+       
+       
+       pc.printf("X: %f\n", accX);
+       pc.printf("Y: %f\n", accY);
+       
+       wait(.05);
+       
+
+
+
+        }  
+        
+       
+        
+        
+    }
+//......more code demos can be found in main.cpp
+
+ 
\ No newline at end of file
diff -r 000000000000 -r 98e654b8abce mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Sep 13 21:14:04 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/a330f0fddbec
\ No newline at end of file