problem 2 for HW 2

Dependencies:   4DGL-uLCD-SE 4180_LSM9DS0_lab LSM9DS0 mbed

Fork of 4180_LSM9DS0_lab by Allen Wild

Files at this revision

API Documentation at this revision

Comitter:
lzzcd001
Date:
Wed Feb 18 14:50:45 2015 +0000
Parent:
5:942e184c4977
Commit message:
problem 2 for HW 2

Changed in this revision

HW2_P2.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/HW2_P2.lib	Wed Feb 18 14:50:45 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/aswild/code/4180_LSM9DS0_lab/#942e184c4977
--- a/main.cpp	Mon Feb 02 21:51:57 2015 +0000
+++ b/main.cpp	Wed Feb 18 14:50:45 2015 +0000
@@ -18,6 +18,7 @@
 // Verify that the pin assignments below match your breadboard
 LSM9DS0 imu(p9, p10, LSM9DS0_G_ADDR, LSM9DS0_XM_ADDR);
 Serial pc(USBTX, USBRX);
+Serial device(p13, p14);
 
 #ifdef PART_4
 uLCD_4DGL lcd(p28, p27, p30);X
@@ -47,7 +48,6 @@
 {
     setup();  //Setup sensor and Serial
     pc.printf("------ LSM0DS0 Demo -----------\n");
-
     while (true)
     {
     	// TODO - add code here to read compass or accelerometer data
@@ -59,7 +59,21 @@
     	//		float heading = imu.calcHeading();
     	// Remember that x = length*cos(heading) and y = length*sin(heading)
     	// to convert from degrees to radians (for sin/cos functions), multiply by pi/180
-		
+    	imu.readMag();
+		imu.readAccel();
+		imu.readTemp();
+		float heading = imu.calcHeading();
+        //if(device.readable()) {
+        //    pc.putc(device.getc());
+        //}
+		//if(pc.readable()) {
+        //    device.putc(pc.getc());
+        //}
+		pc.printf("Accelaration_x: %d\n", imu.ax_raw);
+		pc.printf("Accelaration_y: %d\n", imu.ay_raw);
+		pc.printf("Accelaration_z: %d\n", imu.az_raw);
+		pc.printf("Temperature in C: %2.4f\n", imu.temperature_c);
+		pc.printf("Heading: %2.4f\n", heading);
 		wait_ms(REFRESH_TIME_MS);
 	}
 }