Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Cosmic_Pi_STM32_i2c
Diff: LSM303D.cpp
- Revision:
- 2:8cd0c3c11b48
- Parent:
- 1:f93f4bc7a889
- Child:
- 3:9e595dd5d97e
diff -r f93f4bc7a889 -r 8cd0c3c11b48 LSM303D.cpp
--- a/LSM303D.cpp	Wed Feb 03 21:01:57 2016 +0000
+++ b/LSM303D.cpp	Mon Feb 08 17:57:22 2016 +0000
@@ -109,14 +109,13 @@
     char acc[6], mag[6];
  
     if (recv(addr_acc_mag, OUT_X_A, acc, 6) && recv(addr_acc_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;
-        //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;
+        *ax = float(short(acc[1] << 8 | acc[0]))*0.061;  //32768/4=8192
+        *ay =  float(short(acc[3] << 8 | acc[2]))*0.061;
+        *az =  float(short(acc[5] << 8 | acc[4]))*0.061;
+        //+-4gauss
+        *mx = float(short(mag[0] << 8 | mag[1]))*0.16;
+        *mz = float(short(mag[2] << 8 | mag[3]))*0.16;
+        *my = float(short(mag[4] << 8 | mag[5]))*0.16;
  
         return true;
     }