updates

Dependencies:   BLE_API mbed-dev-bin nRF51822

Fork of microbit-dal-eddystone by Martin Woolley

Files at this revision

API Documentation at this revision

Comitter:
LancasterUniversity
Date:
Wed Jul 13 12:18:20 2016 +0100
Parent:
39:112df23f039f
Child:
41:da05ec75cd5d
Commit message:
Synchronized with git rev d2319f6d
Author: Joe Finney
microbit: Added support for freefall event

Replaced this functionality after testing showed funcitonality had been
accidentally removed.

Changed in this revision

inc/drivers/MicroBitAccelerometer.h Show annotated file Show diff for this revision Revisions of this file
source/drivers/MicroBitAccelerometer.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/inc/drivers/MicroBitAccelerometer.h	Wed Jul 13 12:18:18 2016 +0100
+++ b/inc/drivers/MicroBitAccelerometer.h	Wed Jul 13 12:18:20 2016 +0100
@@ -140,7 +140,7 @@
                 x:1,
                 y:1,
                 z:1,
-                unused,
+                freefall,
                 impulse_3,
                 impulse_6,
                 impulse_8,
--- 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...