comparison Discovery/Src/base.c @ 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 74a8296a2318
children b111fc4250e9
comparison
equal deleted inserted replaced
359:4258ea9b67fa 360:fc5e9fdcb156
229 #include "decom.h" 229 #include "decom.h"
230 #include "timer.h" 230 #include "timer.h"
231 #include "logbook_miniLive.h" 231 #include "logbook_miniLive.h"
232 #include "test_vpm.h" 232 #include "test_vpm.h"
233 #include "tDebug.h" 233 #include "tDebug.h"
234 #include "motion.h"
234 235
235 #ifdef DEMOMODE 236 #ifdef DEMOMODE
236 #include "demo.h" 237 #include "demo.h"
237 static void TIM_DEMO_init(void); 238 static void TIM_DEMO_init(void);
238 #endif 239 #endif
337 /* #define DEBUG_RUNTIME TRUE */ 338 /* #define DEBUG_RUNTIME TRUE */
338 #ifdef DEBUG_RUNTIME 339 #ifdef DEBUG_RUNTIME
339 #define MEASURECNT 60 /* number of measuremets to be stored */ 340 #define MEASURECNT 60 /* number of measuremets to be stored */
340 static uint32_t loopcnt[MEASURECNT]; 341 static uint32_t loopcnt[MEASURECNT];
341 #endif 342 #endif
343
344 static uint8_t ButtonAction = ACTION_END;
345
346 static void StoreButtonAction(uint8_t action)
347 {
348 ButtonAction = action;
349 }
350
342 // =============================================================================== 351 // ===============================================================================
343 // main 352 // main
344 /// @brief This function makes initializations and has the nonIRQ endless loop 353 /// @brief This function makes initializations and has the nonIRQ endless loop
345 /// for bluetooth and deco calculations 354 /// for bluetooth and deco calculations
346 /// 355 ///
506 if(DoDisplayRefresh) 515 if(DoDisplayRefresh)
507 { 516 {
508 DoDisplayRefresh = 0; 517 DoDisplayRefresh = 0;
509 RefreshDisplay(); 518 RefreshDisplay();
510 519
520 if(DETECT_NEG_SHAKE == detectShake(stateRealGetPointer()->lifeData.compass_pitch))
521 {
522 StoreButtonAction((uint8_t)ACTION_BUTTON_ENTER);
523 }
524
511 // Enable this to make the simulator write a logbook entry 525 // Enable this to make the simulator write a logbook entry
512 // #define SIM_WRITES_LOGBOOK 1 526 // #define SIM_WRITES_LOGBOOK 1
513 527
514 #ifdef SIM_WRITES_LOGBOOK 528 #ifdef SIM_WRITES_LOGBOOK
515 if(stateUsed == stateSimGetPointer()) 529 if(stateUsed == stateSimGetPointer())
539 } 553 }
540 #endif 554 #endif
541 555
542 } 556 }
543 } 557 }
558
559
560
544 561
545 // =============================================================================== 562 // ===============================================================================
546 // timer IRQ 563 // timer IRQ
547 /// @brief this is called periodically 564 /// @brief this is called periodically
548 /// 565 ///
847 if(get_globalState() == StStop) 864 if(get_globalState() == StStop)
848 tHome_sleepmode_fun(); 865 tHome_sleepmode_fun();
849 break; 866 break;
850 } 867 }
851 } 868 }
852 static uint8_t ButtonAction = ACTION_END; 869
853
854 static void StoreButtonAction(uint8_t action)
855 {
856 ButtonAction = action;
857 }
858 870
859 static void TriggerButtonAction() 871 static void TriggerButtonAction()
860 { 872 {
861 uint8_t action = ButtonAction; 873 uint8_t action = ButtonAction;
862 SStateList status; 874 SStateList status;