Mercurial > public > ostc4
diff Discovery/Src/motion.c @ 642:c737cf5d9067
Do not show focus indicator in case motion detection is suspended:
Motion detection will be suspended in case the diver is operating the OSTC using the buttons. In previous versions the focus indicator was shown even the motion detection was not active => may cause confusion. The indicator is now only shown in case the detection is active
Added hystresis for switching between sector views:
In previous versions small jitter at the angle signal could cause fast switching of the custom view. An offset has now been added to avoid this scenario
author | Ideenmodellierer |
---|---|
date | Wed, 24 Mar 2021 21:28:41 +0100 |
parents | 189f945ae4ba |
children | ff2b393e290f |
line wrap: on
line diff
--- a/Discovery/Src/motion.c Thu Mar 11 21:45:22 2021 +0100 +++ b/Discovery/Src/motion.c Wed Mar 24 21:28:41 2021 +0100 @@ -277,19 +277,26 @@ /* Map the current pitch value to a sector and create button event in case the sector is left */ detectionState_t detectSectorButtonEvent(float focusOffset) { + static uint8_t lastTargetSector = 0xFF; + static float lastfocusOffset = 0.0; + uint8_t newTargetSector; newTargetSector = GetSectorForFocus(focusOffset); - if(settingsGetPointer()->design == 3) /* Big font view ? */ + /* take a small hysteresis into account to avoid fast display changes (flicker) */ + if((newTargetSector != lastTargetSector) && (fabsf(focusOffset - lastfocusOffset) > (sectorDetection.size / 3))) { - t3_select_customview(GetCVForSector(newTargetSector)); + lastfocusOffset = focusOffset; + if(settingsGetPointer()->design == 3) /* Big font view ? */ + { + t3_select_customview(GetCVForSector(newTargetSector)); + } + else + { + t7_select_customview(GetCVForSector(newTargetSector)); + } } - else - { - t7_select_customview(GetCVForSector(newTargetSector)); - } - return DETECT_NOTHING; } @@ -734,6 +741,17 @@ inFocus = 0; } +uint8_t viewDetectionSuspended(void) +{ + uint8_t retVal = 0; + + if(suspendMotionDetectionSec) + { + retVal = 1; + } + return retVal; +} + void suspendMotionDetection(uint8_t seconds) { suspendMotionDetectionSec = seconds * 10; /* detection function is called every 100ms */