Implemented first Hangar-Service
Dependencies: CalibrateMagneto QuaternionMath
Fork of SML2 by
Diff: Accelerometer.cpp
- Revision:
- 40:8e852115fe55
- Parent:
- 32:d37447aec6b4
- Child:
- 43:6251c0169f4f
--- a/Accelerometer.cpp Tue May 19 14:18:30 2015 +0000 +++ b/Accelerometer.cpp Tue May 26 11:28:37 2015 +0000 @@ -43,15 +43,18 @@ { // Check comments in the read() function of the Gyroscope for more info why we read bytes one by one. uint8_t buffer[6]; - + /* for (size_t i = 0; i < 6; i++) buffer[i] = read_reg(0x02 + i); - + */ + + read_reg(0x02, buffer, sizeof buffer); + const int16_t x = *(reinterpret_cast<const int16_t*>(buffer + 0)) / 16; const int16_t y = *(reinterpret_cast<const int16_t*>(buffer + 2)) / 16; const int16_t z = *(reinterpret_cast<const int16_t*>(buffer + 4)) / 16; - const float accel_resolution = 0.0009765625; + const float accel_resolution = 0.9765625; - return Vector3(x, y, z) * accel_resolution; + return Vector3(x, y, z);// * accel_resolution; }