changeset 360:fc5e9fdcb156 MotionDetection

Added trigger of middle button action in case of a detected shake
author ideenmodellierer
date Fri, 24 May 2019 22:01:46 +0200
parents 4258ea9b67fa
children b111fc4250e9
files Discovery/Src/base.c
diffstat 1 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Src/base.c	Fri May 24 22:00:38 2019 +0200
+++ b/Discovery/Src/base.c	Fri May 24 22:01:46 2019 +0200
@@ -231,6 +231,7 @@
 #include "logbook_miniLive.h"
 #include "test_vpm.h"
 #include "tDebug.h"
+#include "motion.h"
 
 #ifdef DEMOMODE
 #include "demo.h"
@@ -339,6 +340,14 @@
 #define MEASURECNT 60	/* number of measuremets to be stored */
 static uint32_t loopcnt[MEASURECNT];
 #endif
+
+static uint8_t ButtonAction = ACTION_END;
+
+static void StoreButtonAction(uint8_t action)
+{
+	ButtonAction = action;
+}
+
 //  ===============================================================================
 //	main
 /// @brief	This function makes initializations and has the nonIRQ endless loop
@@ -508,6 +517,11 @@
 	        DoDisplayRefresh = 0;
         	RefreshDisplay();
 
+            if(DETECT_NEG_SHAKE == detectShake(stateRealGetPointer()->lifeData.compass_pitch))
+           	{
+            	StoreButtonAction((uint8_t)ACTION_BUTTON_ENTER);
+           	}
+
 // Enable this to make the simulator write a logbook entry
 // #define SIM_WRITES_LOGBOOK 1
 
@@ -542,6 +556,9 @@
     }
 }
 
+
+
+
 //  ===============================================================================
 //	timer IRQ
 /// @brief	this is called periodically
@@ -849,12 +866,7 @@
 		break;
 	}
 }
-static uint8_t ButtonAction = ACTION_END;
 
-static void StoreButtonAction(uint8_t action)
-{
-	ButtonAction = action;
-}
 
 static void TriggerButtonAction()
 {