Mercurial > public > ostc4
diff 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 |
line wrap: on
line diff
--- a/Discovery/Src/motion.c Thu Jan 14 20:38:28 2021 +0100 +++ b/Discovery/Src/motion.c Thu Jan 14 21:25:15 2021 +0100 @@ -50,6 +50,8 @@ static uint8_t inFocus = 0; static uint8_t sectorMap[SECTOR_MAX_CNT]; +static uint8_t suspendMotionDetectionSec = 0; + void resetMotionDeltaHistory() { motionDeltaHistoryIdx = 0; @@ -719,3 +721,73 @@ { inFocus = 0; } + +void suspendMotionDetection(uint8_t seconds) +{ + suspendMotionDetectionSec = seconds * 10; /* detection function is called every 100ms */ +} + +void HandleMotionDetection(void) +{ + detectionState_t pitchstate = DETECT_NOTHING; + uint8_t wasInFocus = 0; + + evaluateMotionDelta(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading); + checkViewport(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading); + + if(viewInFocus()) + { + wasInFocus = 1; + set_Backlight_Boost(settingsGetPointer()->viewPortMode & 0x03); + + if(suspendMotionDetectionSec == 0) /* suspend detection while diver is manually operating the OSTC */ + { + switch(settingsGetPointer()->MotionDetection) + { + case MOTION_DETECT_MOVE: pitchstate = detectPitch(stateRealGetPointer()->lifeData.compass_pitch); + break; + case MOTION_DETECT_SECTOR: pitchstate = detectSectorButtonEvent(stateRealGetPointer()->lifeData.compass_pitch); + break; + case MOTION_DETECT_SCROLL: pitchstate = detectScrollButtonEvent(stateRealGetPointer()->lifeData.compass_pitch); + break; + default: + pitchstate = DETECT_NOTHING; + break; + } + } + + if(DETECT_NEG_PITCH == pitchstate) + { + StoreButtonAction((uint8_t)ACTION_PITCH_NEG); + } + if(DETECT_POS_PITCH == pitchstate) + { + StoreButtonAction((uint8_t)ACTION_PITCH_POS); + } + } + else + { + if(wasInFocus) + { + wasInFocus = 0; + if(suspendMotionDetectionSec == 0) + { + if(settingsGetPointer()->design == 7) + { + t7_set_customview_to_primary(); + } + else + { + t3_set_customview_to_primary(); + } + } + } + set_Backlight_Boost(0); + } + if(suspendMotionDetectionSec != 0) + { + suspendMotionDetectionSec--; + } +} + +