changeset 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 ed5422ac4ffb
children 5149cd644fbc
files Discovery/Inc/motion.h Discovery/Src/base.c Discovery/Src/motion.c Discovery/Src/t3.c Discovery/Src/t7.c
diffstat 5 files changed, 33 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/motion.h	Thu Mar 11 21:45:22 2021 +0100
+++ b/Discovery/Inc/motion.h	Wed Mar 24 21:28:41 2021 +0100
@@ -92,6 +92,7 @@
 void calibrateViewport(float roll, float pitch, float yaw);
 float checkViewport(float roll, float pitch, float yaw, uint8_t enableAxis);
 uint8_t viewInFocus(void);
+uint8_t viewDetectionSuspended(void);
 void resetFocusState(void);
 
 #endif /* INC_MOTION_H_ */
--- a/Discovery/Src/base.c	Thu Mar 11 21:45:22 2021 +0100
+++ b/Discovery/Src/base.c	Wed Mar 24 21:28:41 2021 +0100
@@ -522,7 +522,7 @@
         	{
         		if(get_globalState() != StD)
         		{
-        			suspendMotionDetection(1);		/* do not change custom views while divers is operating the computer */
+        			suspendMotionDetection(10);		/* do not change custom views while divers is operating the computer */
         		}
         		HandleMotionDetection();
         	}
@@ -790,7 +790,7 @@
 
 						if ((status.page == PageDive) && (status.line == 0))
 						{
-							if((action == ACTION_BUTTON_ENTER) && ((pSettings->MotionDetection == MOTION_DETECT_SECTOR) || (pSettings->MotionDetection == MOTION_DETECT_SCROLL)))
+							if(action == ACTION_BUTTON_ENTER)
 							{
 								suspendMotionDetection(10);
 							}
@@ -799,7 +799,9 @@
 						else if (status.page == PageSurface)
 							tHome_change_customview_button_pressed(action);
 						else
+						{
 							tHomeDiveMenuControl(action);
+						}
 					}
 			break;
 
--- 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 */
--- a/Discovery/Src/t3.c	Thu Mar 11 21:45:22 2021 +0100
+++ b/Discovery/Src/t3.c	Wed Mar 24 21:28:41 2021 +0100
@@ -415,7 +415,7 @@
     start.x = 0;
     stop.x = 799;
     stop.y = start.y = BigFontSeperationTopBottom;
-    if(viewInFocus())
+    if((viewInFocus()) && (!viewDetectionSuspended()))
     {
     	GFX_draw_line(tXscreen, start, stop, CLUT_Font023);
     }
@@ -429,7 +429,7 @@
     stop.y = 479;
 
     stop.x = start.x = BigFontSeperationLeftRight;
-    if(viewInFocus())
+    if((viewInFocus() && (!viewDetectionSuspended())))
     {
     	GFX_draw_line(tXscreen, start, stop, CLUT_Font023);
     }
--- a/Discovery/Src/t7.c	Thu Mar 11 21:45:22 2021 +0100
+++ b/Discovery/Src/t7.c	Wed Mar 24 21:28:41 2021 +0100
@@ -2935,7 +2935,7 @@
     WidthHeight.x = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_LINE_LEFT;
     LeftLow.y = 60;
     WidthHeight.y = 440 - LeftLow.y;
-    if(viewInFocus())
+    if((viewInFocus() && (!viewDetectionSuspended())))
     {
     	GFX_draw_box(&t7screen, LeftLow, WidthHeight, 1, CLUT_Font023);
     }