Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed-dev-bin nRF51822
Diff: source/drivers/MicroBitAccelerometer.cpp
- Revision:
- 6:2e1c2e0d8c7a
- Parent:
- 1:8aa5cdb4ab67
- Child:
- 37:b624ae5e94a5
diff -r f0f1cecd65d8 -r 2e1c2e0d8c7a source/drivers/MicroBitAccelerometer.cpp
--- a/source/drivers/MicroBitAccelerometer.cpp Thu Apr 07 11:59:19 2016 +0100
+++ b/source/drivers/MicroBitAccelerometer.cpp Thu Apr 07 23:39:31 2016 +0100
@@ -641,7 +641,8 @@
float y = (float) getY(NORTH_EAST_DOWN);
float z = (float) getZ(NORTH_EAST_DOWN);
- roll = atan2(getY(NORTH_EAST_DOWN), getZ(NORTH_EAST_DOWN));
+ roll = atan2((double)getY(NORTH_EAST_DOWN), (double)getZ(NORTH_EAST_DOWN));
+
pitch = atan(-x / (y*sin(roll) + z*cos(roll)));
status |= MICROBIT_ACCEL_PITCH_ROLL_VALID;
}
@@ -707,4 +708,4 @@
{80000, 0x28},
{160000, 0x30},
{640000, 0x38}
-};
+};
\ No newline at end of file