updates
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal-eddystone by
Revision 43:0374ea4d2167, committed 2016-07-13
- Comitter:
- LancasterUniversity
- Date:
- Wed Jul 13 12:18:23 2016 +0100
- Parent:
- 42:e2869e0fa366
- Child:
- 44:bb4aa1985f37
- Commit message:
- Synchronized with git rev eead3209
Author: Joe Finney
microbit: reuse variables in recalculatePitchRoll [issue #116]
Removed redundant function calls.
Changed in this revision
source/drivers/MicroBitAccelerometer.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/drivers/MicroBitAccelerometer.cpp Wed Jul 13 12:18:22 2016 +0100 +++ b/source/drivers/MicroBitAccelerometer.cpp Wed Jul 13 12:18:23 2016 +0100 @@ -666,13 +666,13 @@ */ void MicroBitAccelerometer::recalculatePitchRoll() { - float x = (float) getX(NORTH_EAST_DOWN); - float y = (float) getY(NORTH_EAST_DOWN); - float z = (float) getZ(NORTH_EAST_DOWN); + double x = (double) getX(NORTH_EAST_DOWN); + double y = (double) getY(NORTH_EAST_DOWN); + double z = (double) getZ(NORTH_EAST_DOWN); - roll = atan2((double)getY(NORTH_EAST_DOWN), (double)getZ(NORTH_EAST_DOWN)); + roll = atan2(y, z); + pitch = atan(-x / (y*sin(roll) + z*cos(roll))); - pitch = atan(-x / (y*sin(roll) + z*cos(roll))); status |= MICROBIT_ACCEL_PITCH_ROLL_VALID; }