My fork
Dependencies: BLE_API nRF51822-bluetooth-mdw
Fork of microbit-dal by
Diff: source/drivers/MicroBitAccelerometer.cpp
- Revision:
- 40:948486a56c9d
- Parent:
- 39:112df23f039f
- Child:
- 41:da05ec75cd5d
--- a/source/drivers/MicroBitAccelerometer.cpp Wed Jul 13 12:18:18 2016 +0100 +++ b/source/drivers/MicroBitAccelerometer.cpp Wed Jul 13 12:18:20 2016 +0100 @@ -197,6 +197,7 @@ this->shake.z = 0; this->shake.count = 0; this->shake.timer = 0; + this->shake.freefall = 1; this->shake.impulse_3 = 1; this->shake.impulse_6 = 1; this->shake.impulse_8 = 1; @@ -421,11 +422,18 @@ impulseSigma = 0; } + if (force < MICROBIT_ACCELEROMETER_FREEFALL_THRESHOLD && !shake.freefall) + { + MicroBitEvent e(MICROBIT_ID_GESTURE, MICROBIT_ACCELEROMETER_EVT_FREEFALL); + shake.freefall = 1; + impulseSigma = 0; + } + // Reset the impulse event onve the acceleration has subsided. if (impulseSigma < MICROBIT_ACCELEROMETER_GESTURE_DAMPING) impulseSigma++; else - shake.impulse_3 = shake.impulse_6 = shake.impulse_8 = 0; + shake.impulse_3 = shake.impulse_6 = shake.impulse_8 = shake.freefall = 0; // Determine what it looks like we're doing based on the latest sample...