a

Fork of ADXL345_I2C by Ian Molesworth

Files at this revision

API Documentation at this revision

Comitter:
s1210160
Date:
Fri Jul 31 10:23:02 2015 +0000
Parent:
1:92fa975dab32
Commit message:
a

Changed in this revision

ADXL345_I2C.cpp Show annotated file Show diff for this revision Revisions of this file
ADXL345_I2C.h Show annotated file Show diff for this revision Revisions of this file
diff -r 92fa975dab32 -r 475c5366629a ADXL345_I2C.cpp
--- a/ADXL345_I2C.cpp	Wed Feb 02 07:01:39 2011 +0000
+++ b/ADXL345_I2C.cpp	Fri Jul 31 10:23:02 2015 +0000
@@ -340,12 +340,16 @@
 
 void ADXL345_I2C::getOutput(int* readings){
     
-      char buffer[2];
+      char buffer[2] = {0, 0};
     
     TwoByteRead(ADXL345_DATAX0_REG, buffer);
     readings[0] = (int)buffer[1] << 8 | (int)buffer[0];
+    buffer[0] = 0;
+    buffer[1] = 0;
     TwoByteRead(ADXL345_DATAY0_REG, buffer);
     readings[1] = (int)buffer[1] << 8 | (int)buffer[0];
+    buffer[0] = 0;
+    buffer[1] = 0;
     TwoByteRead(ADXL345_DATAZ0_REG, buffer);
     readings[2] = (int)buffer[1] << 8 | (int)buffer[0];
 
diff -r 92fa975dab32 -r 475c5366629a ADXL345_I2C.h
--- a/ADXL345_I2C.h	Wed Feb 02 07:01:39 2011 +0000
+++ b/ADXL345_I2C.h	Fri Jul 31 10:23:02 2015 +0000
@@ -91,15 +91,17 @@
 #define ADXL345_12HZ5       0x07
 #define ADXL345_6HZ25       0x06
 
-#define ADXL345_ID          0x1D
-#define ADXL345_I2C_READ    0x3B
-#define ADXL345_I2C_WRITE   0x3A
+#define ADXL345_ID          0x53
+#define ADXL345_I2C_READ    0xA6
+#define ADXL345_I2C_WRITE   0xA7
 #define ADXL345_MULTI_BYTE  0x60
 
 #define ADXL345_X           0x00
 #define ADXL345_Y           0x01
 #define ADXL345_Z           0x02
 
+#define M_PI 3.1415926535897932384626433832795
+
 /**
  * ADXL345 triple axis, digital interface, accelerometer.
  */