asdf

Fork of LSM303DLHC by brian claus

Files at this revision

API Documentation at this revision

Comitter:
goy5022
Date:
Sat Mar 29 03:06:36 2014 +0000
Parent:
4:612f7d5a822d
Commit message:
because steve thinks so;

Changed in this revision

LSM303DLHC.cpp Show annotated file Show diff for this revision Revisions of this file
LSM303DLHC.h Show annotated file Show diff for this revision Revisions of this file
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;
diff -r 612f7d5a822d -r aa4b323655dc LSM303DLHC.h
--- a/LSM303DLHC.h	Thu Feb 21 00:20:17 2013 +0000
+++ b/LSM303DLHC.h	Sat Mar 29 03:06:36 2014 +0000
@@ -3,8 +3,6 @@
 #define __LSM303DLHC_H
 #include "mbed.h"
 
-
-
 class LSM303DLHC {
     public:
         /** Create a new interface for an LSM303DLHC
@@ -21,11 +19,10 @@
          * @param mx,my,mz is the magnetometer 3d vector, written by the function
          */
          bool read(float *ax, float *ay, float *az, float *mx, float *my, float *mz);
-
+         bool read(float *ax, float *ay, float *az);
 
     private:
         I2C _LSM303;
-
          
         float ax, ay, az;
         float mx, my, mz;