comparison Discovery/Src/base.c @ 611:916998f90e39

Suspend MotionDetection events while diver is operationg the OSTC: In the previous version in some situations the customer selection of the diver was immediatly overwritten by the detection function value (e.g. in sector mode). To prevent this behaviour a timeout for the detection has been added. Also in case the diver is operating a sub menu the handling of motion detection events will now be blocked.
author Ideenmodellierer
date Thu, 14 Jan 2021 21:25:15 +0100
parents 132e7e3d13a7
children 556df4a8f418
comparison
equal deleted inserted replaced
610:ae7f8333c900 611:916998f90e39
332 return(ch); 332 return(ch);
333 } 333 }
334 */ 334 */
335 static uint8_t ButtonAction = ACTION_END; 335 static uint8_t ButtonAction = ACTION_END;
336 336
337 static void StoreButtonAction(uint8_t action) 337 void StoreButtonAction(uint8_t action)
338 { 338 {
339 ButtonAction = action; 339 ButtonAction = action;
340 } 340 }
341 341
342 // =============================================================================== 342 // ===============================================================================
347 // =============================================================================== 347 // ===============================================================================
348 int main(void) 348 int main(void)
349 { 349 {
350 uint32_t pLayerInvisible; 350 uint32_t pLayerInvisible;
351 uint16_t totalDiveCounterFound; 351 uint16_t totalDiveCounterFound;
352 uint8_t wasInFocus = 0;
353 352
354 SStateList status; 353 SStateList status;
355 #ifdef ENABLE_MOTION_CONTROL 354
356 detectionState_t pitchstate;
357 #endif
358 set_globalState( StBoot0 ); 355 set_globalState( StBoot0 );
359 LastButtonPressed = 0; 356 LastButtonPressed = 0;
360 357
361 HAL_Init(); 358 HAL_Init();
362 HAL_NVIC_SetPriorityGrouping( NVIC_PRIORITYGROUP_2 ); 359 HAL_NVIC_SetPriorityGrouping( NVIC_PRIORITYGROUP_2 );
508 TimeoutControl(); /* exit menus if needed */ 505 TimeoutControl(); /* exit menus if needed */
509 506
510 #ifdef ENABLE_MOTION_CONTROL 507 #ifdef ENABLE_MOTION_CONTROL
511 if((stateUsed->mode == MODE_DIVE) && (settingsGetPointer()->MotionDetection != MOTION_DETECT_OFF)) /* handle motion events in divemode only */ 508 if((stateUsed->mode == MODE_DIVE) && (settingsGetPointer()->MotionDetection != MOTION_DETECT_OFF)) /* handle motion events in divemode only */
512 { 509 {
513 evaluateMotionDelta(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading); 510 if(get_globalState() != StD)
514 checkViewport(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading);
515
516 if(viewInFocus())
517 { 511 {
518 wasInFocus = 1; 512 suspendMotionDetection(1); /* do not change custom views while divers is operating the computer */
519 set_Backlight_Boost(settingsGetPointer()->viewPortMode & 0x03); 513 }
520 switch(settingsGetPointer()->MotionDetection) 514 HandleMotionDetection();
521 {
522 case MOTION_DETECT_MOVE: pitchstate = detectPitch(stateRealGetPointer()->lifeData.compass_pitch);
523 break;
524 case MOTION_DETECT_SECTOR: pitchstate = detectSectorButtonEvent(stateRealGetPointer()->lifeData.compass_pitch);
525 break;
526 case MOTION_DETECT_SCROLL: pitchstate = detectScrollButtonEvent(stateRealGetPointer()->lifeData.compass_pitch);
527 break;
528 default:
529 pitchstate = DETECT_NOTHING;
530 break;
531 }
532 if(DETECT_NEG_PITCH == pitchstate)
533 {
534 StoreButtonAction((uint8_t)ACTION_PITCH_NEG);
535 }
536 if(DETECT_POS_PITCH == pitchstate)
537 {
538 StoreButtonAction((uint8_t)ACTION_PITCH_POS);
539 }
540 }
541 else
542 {
543 if(wasInFocus)
544 {
545 wasInFocus = 0;
546 if(settingsGetPointer()->design == 7)
547 {
548 t7_set_customview_to_primary();
549 }
550 else
551 {
552 t3_set_customview_to_primary();
553 }
554 }
555
556 set_Backlight_Boost(0);
557 }
558 } 515 }
559 #endif 516 #endif
560 517
561 #ifdef SIM_WRITES_LOGBOOK 518 #ifdef SIM_WRITES_LOGBOOK
562 if(stateUsed == stateSimGetPointer()) 519 if(stateUsed == stateSimGetPointer())
749 706
750 static void TriggerButtonAction() 707 static void TriggerButtonAction()
751 { 708 {
752 uint8_t action = ButtonAction; 709 uint8_t action = ButtonAction;
753 SStateList status; 710 SStateList status;
711 SSettings* pSettings;
712 pSettings = settingsGetPointer();
713
754 714
755 if(ButtonAction != ACTION_END) 715 if(ButtonAction != ACTION_END)
756 { 716 {
757 get_globalStateList(&status); 717 get_globalStateList(&status);
758 718
776 } else if (action == ACTION_BUTTON_BACK) { 736 } else if (action == ACTION_BUTTON_BACK) {
777 if (get_globalState() == StS) 737 if (get_globalState() == StS)
778 { 738 {
779 openInfo(StILOGLIST); 739 openInfo(StILOGLIST);
780 } 740 }
781 else if ((status.page == PageDive) && (settingsGetPointer()->design < 7)) 741 else if ((status.page == PageDive) && (pSettings->design < 7))
782 { 742 {
783 if(settingsGetPointer()->design == 3) 743 if(pSettings->design == 3)
784 { 744 {
785 if(get_globalState() != StD) /* located in submenu? => return */ 745 if(get_globalState() != StD) /* located in submenu? => return */
786 { 746 {
787 set_globalState(StD); 747 set_globalState(StD);
788 } 748 }
789 else /* return to t7 view */ 749 else /* return to t7 view */
790 { 750 {
791 settingsGetPointer()->design = 7; 751 pSettings->design = 7;
792 if(settingsGetPointer()->MotionDetection == MOTION_DETECT_SECTOR) 752 if(pSettings->MotionDetection == MOTION_DETECT_SECTOR)
793 { 753 {
794 DefinePitchSectors(settingsGetPointer()->viewPitch,CUSTOMER_DEFINED_VIEWS); 754 DefinePitchSectors(pSettings->viewPitch,CUSTOMER_DEFINED_VIEWS);
795 MapCVToSector(); 755 MapCVToSector();
796 } 756 }
797 } 757 }
798 } 758 }
799 else 759 else
800 { 760 {
801 settingsGetPointer()->design = 7; // auto switch to 9 if necessary 761 pSettings->design = 7; // auto switch to 9 if necessary
802 } 762 }
803 } else if ((status.page == PageDive) && (status.line != 0)) 763 } else if ((status.page == PageDive) && (status.line != 0))
804 { 764 {
805 if (settingsGetPointer()->extraDisplay == EXTRADISPLAY_BIGFONT) 765 if (pSettings->extraDisplay == EXTRADISPLAY_BIGFONT)
806 { 766 {
807 settingsGetPointer()->design = 3; 767 pSettings->design = 3;
808 if(settingsGetPointer()->MotionDetection == MOTION_DETECT_SECTOR) 768 if(pSettings->MotionDetection == MOTION_DETECT_SECTOR)
809 { 769 {
810 DefinePitchSectors(settingsGetPointer()->viewPitch,CUSTOMER_DEFINED_VIEWS); 770 DefinePitchSectors(pSettings->viewPitch,CUSTOMER_DEFINED_VIEWS);
811 MapCVToSector(); 771 MapCVToSector();
812 } 772 }
813 } 773 }
814 else if (settingsGetPointer()->extraDisplay == EXTRADISPLAY_DECOGAME) 774 else if (pSettings->extraDisplay == EXTRADISPLAY_DECOGAME)
815 settingsGetPointer()->design = 4; 775 pSettings->design = 4;
816 set_globalState(StD); 776 set_globalState(StD);
817 } 777 }
818 else 778 else
819 { 779 {
820 tHome_change_field_button_pressed(); 780 tHome_change_field_button_pressed();
822 } else if ((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_NEG) || (action == ACTION_PITCH_POS)) 782 } else if ((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_NEG) || (action == ACTION_PITCH_POS))
823 { 783 {
824 784
825 if ((status.page == PageDive) && (status.line == 0)) 785 if ((status.page == PageDive) && (status.line == 0))
826 { 786 {
787 if((action == ACTION_BUTTON_ENTER) && ((pSettings->MotionDetection == MOTION_DETECT_SECTOR) || (pSettings->MotionDetection == MOTION_DETECT_SCROLL)))
788 {
789 suspendMotionDetection(10);
790 }
827 tHome_change_customview_button_pressed(action); 791 tHome_change_customview_button_pressed(action);
828 } 792 }
829 else if (status.page == PageSurface) 793 else if (status.page == PageSurface)
830 tHome_change_customview_button_pressed(action); 794 tHome_change_customview_button_pressed(action);
831 else 795 else