Created
November 15, 2014 12:37
-
-
Save ss23/4259b2bfb00d398b1860 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void getAccelerometerData(int16_t * result) { | |
//int regAddress = 0x32; //first axis-acceleration-data register on the ADXL345 | |
int regAddress = 0x30; // One before the first, to see if we were just off by two bytes | |
byte buff[A_TO_READ]; | |
readFrom(ACC, regAddress, A_TO_READ, buff); //read the acceleration data from the ADXL345 | |
//each axis reading comes in 10 bit resolution, ie 2 bytes. Least Significat Byte first!! | |
//thus we are converting both bytes in to one int | |
result[0] = (((int)buff[1]) << 8) | buff[0]; | |
result[1] = (((int)buff[3])<< 8) | buff[2]; | |
result[2] = (((int)buff[5]) << 8) | buff[4]; | |
result[3] = (((int)buff[6]) << 8) | buff[7]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment