updates
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal-eddystone by
Revision 42:e2869e0fa366, committed 2016-07-13
- Comitter:
- LancasterUniversity
- Date:
- Wed Jul 13 12:18:22 2016 +0100
- Parent:
- 41:da05ec75cd5d
- Child:
- 43:0374ea4d2167
- Commit message:
- Synchronized with git rev ece079c7
Author: Joe Finney
microbit: FREEFALL gesture event is now damped
After further testing, dmaping is required on FREEFALL event (but not impulse
events) to avoid false positives.
Changed in this revision
--- a/inc/drivers/MicroBitAccelerometer.h Wed Jul 13 12:18:21 2016 +0100 +++ b/inc/drivers/MicroBitAccelerometer.h Wed Jul 13 12:18:22 2016 +0100 @@ -140,7 +140,7 @@ x:1, y:1, z:1, - freefall, + unused, impulse_3, impulse_6, impulse_8,
--- a/source/drivers/MicroBitAccelerometer.cpp Wed Jul 13 12:18:21 2016 +0100 +++ b/source/drivers/MicroBitAccelerometer.cpp Wed Jul 13 12:18:22 2016 +0100 @@ -197,7 +197,6 @@ 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; @@ -325,7 +324,6 @@ { bool shakeDetected = false; - // Test for shake events. // We detect a shake by measuring zero crossings in each axis. In other words, if we see a strong acceleration to the left followed by // a strong acceleration to the right, then we can infer a shake. Similarly, we can do this for each axis (left/right, up/down, in/out). @@ -368,6 +366,9 @@ if (shake.shaken) return MICROBIT_ACCELEROMETER_EVT_SHAKE; + if (instantaneousAccelerationSquared() < MICROBIT_ACCELEROMETER_FREEFALL_THRESHOLD) + return MICROBIT_ACCELEROMETER_EVT_FREEFALL; + // Determine our posture. if (getX() < (-1000 + MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) return MICROBIT_ACCELEROMETER_EVT_TILT_LEFT; @@ -422,18 +423,11 @@ 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 = shake.freefall = 0; + shake.impulse_3 = shake.impulse_6 = shake.impulse_8 = 0; // Determine what it looks like we're doing based on the latest sample...