Port of LSM303DLHC with modified registers to work with LSM303D
Revision 2:8cd0c3c11b48, committed 2016-02-08
- Comitter:
- bclaus
- Date:
- Mon Feb 08 17:57:22 2016 +0000
- Parent:
- 1:f93f4bc7a889
- Commit message:
- update;
Changed in this revision
LSM303D.cpp | Show annotated file Show diff for this revision Revisions of this file |
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; }