comparison Discovery/Src/base.c @ 368:50ea68c7a153 MotionDetection

Added menu item for motion detection. There are several possibility to use motion detection for user action input. To select of the a new menu entry has been added to the Sys2 =>Custom View Menu (Variables in german)
author ideenmodellierer
date Tue, 13 Aug 2019 21:10:46 +0200
parents e309f78f89a5
children fca370f847f8
comparison
equal deleted inserted replaced
367:e309f78f89a5 368:50ea68c7a153
349 RTC_TimeTypeDef Stime; 349 RTC_TimeTypeDef Stime;
350 uint8_t measurementindex = 0; 350 uint8_t measurementindex = 0;
351 uint8_t lastsecond = 0xFF; 351 uint8_t lastsecond = 0xFF;
352 #endif 352 #endif
353 353
354 detectionState_t shakestate; 354 detectionState_t pitchstate;
355 set_globalState( StBoot0 ); 355 set_globalState( StBoot0 );
356 LastButtonPressed = 0; 356 LastButtonPressed = 0;
357 357
358 HAL_Init(); 358 HAL_Init();
359 HAL_NVIC_SetPriorityGrouping( NVIC_PRIORITYGROUP_2 ); 359 HAL_NVIC_SetPriorityGrouping( NVIC_PRIORITYGROUP_2 );
455 settingsGetPointer()->debugModeOnStart = 0; 455 settingsGetPointer()->debugModeOnStart = 0;
456 ext_flash_write_settings(); 456 ext_flash_write_settings();
457 setDebugMode(); 457 setDebugMode();
458 openInfo( StIDEBUG ); 458 openInfo( StIDEBUG );
459 } 459 }
460 InitMotionDetection();
460 461
461 TIM_init(); /* start cylic 100ms task */ 462 TIM_init(); /* start cylic 100ms task */
462 463
463 /* @brief main LOOP 464 /* @brief main LOOP
464 * 465 *
485 if(DoDisplayRefresh) 486 if(DoDisplayRefresh)
486 { 487 {
487 DoDisplayRefresh = 0; 488 DoDisplayRefresh = 0;
488 RefreshDisplay(); 489 RefreshDisplay();
489 490
490 shakestate = detectShake(stateRealGetPointer()->lifeData.compass_pitch); 491 switch(settingsGetPointer()->MotionDetection)
491 if(DETECT_NEG_SHAKE == shakestate) 492 {
493 case MOTION_DETECT_MOVE: pitchstate = detectPitch(stateRealGetPointer()->lifeData.compass_pitch);
494 break;
495 case MOTION_DETECT_SECTOR: pitchstate = detectSectorButtonEvent(stateRealGetPointer()->lifeData.compass_pitch);
496 break;
497 default:
498 pitchstate = DETECT_NOTHING;
499 break;
500 }
501
502 if(DETECT_NEG_PITCH == pitchstate)
492 { 503 {
493 StoreButtonAction((uint8_t)ACTION_SHAKE_NEG); 504 StoreButtonAction((uint8_t)ACTION_PITCH_NEG);
494 } 505 }
495 if(DETECT_POS_SHAKE == shakestate) 506 if(DETECT_POS_PITCH == pitchstate)
496 { 507 {
497 StoreButtonAction((uint8_t)ACTION_SHAKE_POS); 508 StoreButtonAction((uint8_t)ACTION_PITCH_POS);
498 } 509 }
499 510
500 // Enable this to make the simulator write a logbook entry 511 // Enable this to make the simulator write a logbook entry
501 // #define SIM_WRITES_LOGBOOK 1 512 // #define SIM_WRITES_LOGBOOK 1
502 513
883 settingsGetPointer()->design = 4; 894 settingsGetPointer()->design = 4;
884 895
885 set_globalState(StD); 896 set_globalState(StD);
886 } else 897 } else
887 tHome_change_field_button_pressed(); 898 tHome_change_field_button_pressed();
888 } else if ((action == ACTION_BUTTON_ENTER) || (action == ACTION_SHAKE_NEG) || (action == ACTION_SHAKE_POS)) 899 } else if ((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_NEG) || (action == ACTION_PITCH_POS))
889 { 900 {
890 901
891 if ((status.page == PageDive) && (status.line == 0)) 902 if ((status.page == PageDive) && (status.line == 0))
903 {
892 tHome_change_customview_button_pressed(action); 904 tHome_change_customview_button_pressed(action);
905 if((settingsGetPointer()->MotionDetection == MOTION_DETECT_SECTOR) && (action == ACTION_BUTTON_ENTER)) /* Button pressed while sector detection is active => calibrate to current pitch value */
906 {
907 DefinePitchSectors(stateRealGetPointer()->lifeData.compass_pitch);
908 }
909 }
893 else if (status.page == PageSurface) 910 else if (status.page == PageSurface)
894 tHome_change_customview_button_pressed(action); 911 tHome_change_customview_button_pressed(action);
895 else 912 else
896 tHomeDiveMenuControl(action); 913 tHomeDiveMenuControl(action);
897 } 914 }