diff Discovery/Src/t3.c @ 387:0dbb74be972f

Merged in Ideenmodellierer/ostc4/MotionDetection (pull request #34) MotionDetection
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Sun, 24 Nov 2019 15:46:58 +0000
parents 39c147e47c1c
children 65c7b009136f
line wrap: on
line diff
--- a/Discovery/Src/t3.c	Sun Nov 24 16:08:29 2019 +0100
+++ b/Discovery/Src/t3.c	Sun Nov 24 15:46:58 2019 +0000
@@ -58,6 +58,7 @@
 
 /* Private types -------------------------------------------------------------*/
 #define TEXTSIZE 16
+#define NUMBER_OF_VIEWS 7	/* number of views defined in the array below */
 
 const uint8_t t3_customviewsStandard[] =
 {
@@ -259,6 +260,7 @@
                 depthChangeRate = 200;
         }
         start.y = tXl1->WindowY0 - 1;
+        startZeroLine.y = start.y;
         for(int i = 0; i<5;i++)
         {
             start.y += 40;
@@ -484,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);
 }
 
@@ -1059,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)
@@ -1073,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;
 }
 
 
@@ -1251,3 +1290,36 @@
     GFX_draw_circle(tXscreen, center, 107, CLUT_Font030);
     GFX_draw_circle(tXscreen, center, 108, CLUT_Font030);
 }
+
+uint8_t t3_GetEnabled_customviews()
+{
+	int8_t i;
+    uint8_t enabledViewCnt = 0;
+    uint32_t cv_config = settingsGetPointer()->cv_configuration;
+
+    i=0;
+   	do
+    {
+        if(cv_changelist[i] == CVIEW_sensors) /* at the moment specific big font view may not be selected. Only sensor setting is taken from t7 configuration */
+        {
+          	 if(!CHECK_BIT_THOME(cv_config, cv_changelist[i]))
+          	 {
+           		 enabledViewCnt = NUMBER_OF_VIEWS - 1;		/* sensor shall not be displayed */
+           	 }
+          	 else
+          	 {
+           		 enabledViewCnt = NUMBER_OF_VIEWS; 			/* enable all possible views */
+           	 }
+             break;
+        }
+        i++;
+    } while(cv_changelist[i] != CVIEW_END);
+    if ((stateUsed->diveSettings.ppo2sensors_deactivated) || (stateUsed->diveSettings.ccrOption == 0))
+    {
+    	enabledViewCnt = NUMBER_OF_VIEWS - 1;		/* sensor shall not be displayed */
+    }
+
+    return enabledViewCnt;
+}
+
+