comparison Discovery/Src/motion.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 fd0b60dee6f3
children 96af74455420
comparison
equal deleted inserted replaced
610:ae7f8333c900 611:916998f90e39
47 static uint8_t motionDeltaHistoryIdx; /* Current index of history data */ 47 static uint8_t motionDeltaHistoryIdx; /* Current index of history data */
48 48
49 static uint8_t focusCnt = 0; 49 static uint8_t focusCnt = 0;
50 static uint8_t inFocus = 0; 50 static uint8_t inFocus = 0;
51 static uint8_t sectorMap[SECTOR_MAX_CNT]; 51 static uint8_t sectorMap[SECTOR_MAX_CNT];
52
53 static uint8_t suspendMotionDetectionSec = 0;
52 54
53 void resetMotionDeltaHistory() 55 void resetMotionDeltaHistory()
54 { 56 {
55 motionDeltaHistoryIdx = 0; 57 motionDeltaHistoryIdx = 0;
56 memset(motionDeltaHistory, 0, sizeof(motionDeltaHistory)); 58 memset(motionDeltaHistory, 0, sizeof(motionDeltaHistory));
717 } 719 }
718 void resetFocusState(void) 720 void resetFocusState(void)
719 { 721 {
720 inFocus = 0; 722 inFocus = 0;
721 } 723 }
724
725 void suspendMotionDetection(uint8_t seconds)
726 {
727 suspendMotionDetectionSec = seconds * 10; /* detection function is called every 100ms */
728 }
729
730 void HandleMotionDetection(void)
731 {
732 detectionState_t pitchstate = DETECT_NOTHING;
733 uint8_t wasInFocus = 0;
734
735 evaluateMotionDelta(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading);
736 checkViewport(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading);
737
738 if(viewInFocus())
739 {
740 wasInFocus = 1;
741 set_Backlight_Boost(settingsGetPointer()->viewPortMode & 0x03);
742
743 if(suspendMotionDetectionSec == 0) /* suspend detection while diver is manually operating the OSTC */
744 {
745 switch(settingsGetPointer()->MotionDetection)
746 {
747 case MOTION_DETECT_MOVE: pitchstate = detectPitch(stateRealGetPointer()->lifeData.compass_pitch);
748 break;
749 case MOTION_DETECT_SECTOR: pitchstate = detectSectorButtonEvent(stateRealGetPointer()->lifeData.compass_pitch);
750 break;
751 case MOTION_DETECT_SCROLL: pitchstate = detectScrollButtonEvent(stateRealGetPointer()->lifeData.compass_pitch);
752 break;
753 default:
754 pitchstate = DETECT_NOTHING;
755 break;
756 }
757 }
758
759 if(DETECT_NEG_PITCH == pitchstate)
760 {
761 StoreButtonAction((uint8_t)ACTION_PITCH_NEG);
762 }
763 if(DETECT_POS_PITCH == pitchstate)
764 {
765 StoreButtonAction((uint8_t)ACTION_PITCH_POS);
766 }
767 }
768 else
769 {
770 if(wasInFocus)
771 {
772 wasInFocus = 0;
773 if(suspendMotionDetectionSec == 0)
774 {
775 if(settingsGetPointer()->design == 7)
776 {
777 t7_set_customview_to_primary();
778 }
779 else
780 {
781 t3_set_customview_to_primary();
782 }
783 }
784 }
785 set_Backlight_Boost(0);
786 }
787 if(suspendMotionDetectionSec != 0)
788 {
789 suspendMotionDetectionSec--;
790 }
791 }
792
793