work nice now

Dependents:   Minimu-9v2

Fork of LSM303DLHC by brian claus

Revision:
5:5f3ae033c62d
Parent:
3:4d9465e7e10e
Child:
6:fcf7e9b8ce21
--- a/LSM303DLHC.cpp	Thu Feb 21 00:20:17 2013 +0000
+++ b/LSM303DLHC.cpp	Tue Nov 12 17:25:40 2013 +0000
@@ -111,14 +111,14 @@
     char acc[6], mag[6];
  
     if (recv(addr_acc, OUT_X_A, acc, 6) && recv(addr_mag, OUT_X_M, mag, 6)) {
-        *ax = float(short(acc[1] << 8 | acc[0]))/8192;  //32768/4=8192
-        *ay =  float(short(acc[3] << 8 | acc[2]))/8192;
-        *az =  float(short(acc[5] << 8 | acc[4]))/8192;
+        *ax = *((short*)(acc))/8192.0;  //32768/4=8192
+        *ay = *((short*)(acc+2))/8192.0;
+        *az = *((short*)(acc+4))/8192.0;
         //full scale magnetic readings are from -2048 to 2047
         //gain is x,y =1100; z = 980 LSB/gauss
-        *mx = float(short(mag[0] << 8 | mag[1]))/1100;
-        *mz = float(short(mag[2] << 8 | mag[3]))/980;
-        *my = float(short(mag[4] << 8 | mag[5]))/1100;
+        *mx = ((((short)mag[0]) << 8) | (0xff&mag[1]))/1100.0;
+        *my = ((((short)mag[2]) << 8) | (0xff&mag[3]))/1100.0;
+        *mz = ((((short)mag[4]) << 8) | (0xff&mag[5]))/980.0;
  
         return true;
     }