asdf
Fork of LSM303DLHC by
Diff: LSM303DLHC.cpp
- Revision:
- 5:aa4b323655dc
- Parent:
- 3:4d9465e7e10e
diff -r 612f7d5a822d -r aa4b323655dc LSM303DLHC.cpp --- a/LSM303DLHC.cpp Thu Feb 21 00:20:17 2013 +0000 +++ b/LSM303DLHC.cpp Sat Mar 29 03:06:36 2014 +0000 @@ -126,6 +126,21 @@ return false; } +bool LSM303DLHC::read(float *ax, float *ay, float *az) { + char acc[6]; + + if (recv(addr_acc, OUT_X_A, acc, 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 + + return true; + } + + return false; +} bool LSM303DLHC::recv(char sad, char sub, char *buf, int length) { if (length > 1) sub |= 0x80;