This library enables users to communicate with the ADXL345 accelerometer through the I2C bus on the mbed. The API names are similar and work nearly the same way as those made in the SPI libraries for the ADXL345.

Dependencies:   mbed

Fork of ADXL345_I2C by Peter Swanson

Revision:
2:c2067856a052
Parent:
1:d9412b56f98a
--- a/ADXL345_I2C.cpp	Thu May 12 01:19:36 2011 +0000
+++ b/ADXL345_I2C.cpp	Mon Oct 02 08:28:52 2017 +0000
@@ -131,14 +131,14 @@
 }
 
 
-void ADXL345_I2C::getOutput(int* readings){
+void ADXL345_I2C::getOutput(int16_t* readings){
     char buffer[6];    
     multiByteRead(ADXL345_DATAX0_REG, buffer, 6);
     
-    readings[0] = (int)buffer[1] << 8 | (int)buffer[0];
-    readings[1] = (int)buffer[3] << 8 | (int)buffer[2];
-    readings[2] = (int)buffer[5] << 8 | (int)buffer[4];
-
+    readings[0] = (int16_t)buffer[1] << 8 | (int16_t)buffer[0];
+    readings[1] = (int16_t)buffer[3] << 8 | (int16_t)buffer[2];
+    readings[2] = (int16_t)buffer[5] << 8 | (int16_t)buffer[4];
+    //printf("raw data : %d\t%d\t%d\t%d\t%d\t%d\n",buffer[0],buffer[1],buffer[2],buffer[3],buffer[4],buffer[5]);
 }