modified version of MAG3110, include getX();getY();and getZ()

Dependents:   202Ahm1

Fork of MAG3110 by Aaron Huang

Revision:
6:8f4028440d15
Parent:
5:888035fbef65
--- a/MAG3110.cpp	Fri Feb 07 00:33:01 2014 +0000
+++ b/MAG3110.cpp	Thu Feb 13 01:58:54 2014 +0000
@@ -50,7 +50,7 @@
 
 // read a register per, pass first reg value, reading 2 bytes increments register
 // Reads MSB first then LSB
-int MAG3110::readVal(char regAddr)
+float MAG3110::readVal(char regAddr)
 {
     char cmd[2];
 
@@ -60,24 +60,35 @@
     cmd[0] = 0x00;
     cmd[1] = 0x00;
     _i2c.read(_i2c_address, cmd, 2);
-    return (int)( (cmd[1]|(cmd[0] << 8))); //concatenate the MSB and LSB
+    return (float)( (cmd[1]|(cmd[0] << 8))); //concatenate the MSB and LSB
 }
 
 
 float MAG3110::getHeading()
 {
-    int xVal = readVal(MAG_OUT_X_MSB);
-    int yVal = readVal(MAG_OUT_Y_MSB);
+    float xVal = readVal(MAG_OUT_X_MSB);
+    float yVal = readVal(MAG_OUT_Y_MSB);
     return (atan2((double)(yVal - _avgY),(double)(xVal - _avgX)))*180/PI;
 }
 
-void MAG3110::getValues(int *xVal, int *yVal, int *zVal)
+void MAG3110::getValues(float *xVal, float *yVal, float *zVal)
 {
     *xVal = readVal(MAG_OUT_X_MSB);
     *yVal = readVal(MAG_OUT_Y_MSB);
     *zVal = readVal(MAG_OUT_Z_MSB);
 }
-
+float MAG3110::getX()
+{
+    return readVal(MAG_OUT_X_MSB);
+}
+float MAG3110::getY()
+{
+    return readVal(MAG_OUT_Y_MSB);
+}
+float MAG3110::getZ()
+{
+    return readVal(MAG_OUT_Z_MSB);
+}
 
 void MAG3110::setCalibration(int minX, int maxX, int minY, int maxY )
 {