diff Discovery/Src/t3.c @ 386:39c147e47c1c MotionDetection

Added key direction awarness to t3, t5 and t6 views: In case of big font views the handling of motion events were not considered, As results all events caused a menu change in th same direction.
author ideenmodellierer
date Mon, 21 Oct 2019 21:16:53 +0200
parents 427ae9f8e28e
children 65c7b009136f
line wrap: on
line diff
--- a/Discovery/Src/t3.c	Mon Oct 21 18:37:43 2019 +0200
+++ b/Discovery/Src/t3.c	Mon Oct 21 21:16:53 2019 +0200
@@ -260,6 +260,7 @@
                 depthChangeRate = 200;
         }
         start.y = tXl1->WindowY0 - 1;
+        startZeroLine.y = start.y;
         for(int i = 0; i<5;i++)
         {
             start.y += 40;
@@ -485,9 +486,10 @@
 
 void t3_refresh_customview(float depth)
 {
+#if 0
     if((t3_selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0))
         t3_change_customview();
-
+#endif
     t3_basics_refresh_customview(depth, t3_selection_customview, &t3screen, &t3c1, &t3c2, stateUsedWrite->diveSettings.diveMode);
 }
 
@@ -1060,13 +1062,13 @@
 }
 
 
-void t3_change_customview(void)
+void t3_change_customview(uint8_t action)
 {
-    t3_basics_change_customview(&t3_selection_customview, t3_customviews);
+    t3_basics_change_customview(&t3_selection_customview, t3_customviews, action);
 }
 
 
-void t3_basics_change_customview(uint8_t *tX_selection_customview, const uint8_t *tX_customviews)
+void t3_basics_change_customview(uint8_t *tX_selection_customview, const uint8_t *tX_customviews, uint8_t action)
 {
     const SDecoinfo * pDecoinfo;
     if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE)
@@ -1074,24 +1076,60 @@
     else
         pDecoinfo = &stateUsed->decolistVPM;
 
-    const uint8_t *pViews;
+    uint8_t *pViews;
     pViews = tX_customviews;
 
-    while((*pViews != CVIEW_T3_END) && (*pViews != *tX_selection_customview))
-        {pViews++;}
+    uint8_t *pStartView,*pCurView, *pLastView;
+    uint8_t iterate = 0;	/* set to 1 if a view has to be skipped */
 
-    if(*pViews < CVIEW_T3_END)
-        pViews++;
+    pStartView = pViews;
+    /* set pointer to currently selected view and count number of entries */
+    while((*pViews != CVIEW_T3_END))
+    {
+    	if (*pViews == *tX_selection_customview)
+    	{
+    		pCurView = pViews;
+    	}
+    	pViews++;
+    }
+    pLastView = pViews;
+    pViews = pCurView;
+
+    do
+    {
+    	iterate = 0;
+		if((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_POS))
+		{
+			if(*pViews != CVIEW_T3_END)
+				pViews++;
 
-    if((*pViews == CVIEW_T3_TTS) && !pDecoinfo->output_time_to_surface_seconds)
-        pViews++;
+			if(*pViews == CVIEW_T3_END)
+			{
+				pViews = pStartView;
+			}
+		}
+		else
+		{
+			if(pViews == pStartView)
+			{
+				pViews = pLastView - 1;
+			}
+			else
+			{
+				pViews--;
+			}
+		}
+		if((*pViews == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0))
+		{
+			iterate = 1;
+		}
+	    if((*pViews == CVIEW_T3_TTS) && !pDecoinfo->output_time_to_surface_seconds)
+	    {
+	    	iterate = 1;
+	    }
+    }while (iterate == 1);
 
-    if(*pViews == CVIEW_T3_END)
-    {
-        *tX_selection_customview = tX_customviews[0];
-    }
-    else
-        *tX_selection_customview = *pViews;
+    *tX_selection_customview = *pViews;
 }