Essai d'application Lycée Malraux NSI
Dependencies: BLE_API nRF51822 mbed-dev-bin
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