changeset 384:427ae9f8e28e MotionDetection

Consider number of available t3 views in sector handling: Before chande the number of sectors were taken from t7 view only causing t3 view to be shown inconsistent in case t7 view count were not 6. => added function to count views.
author ideenmodellierer
date Thu, 17 Oct 2019 23:09:17 +0200
parents 49a02dea8ae3
children 0cd862e501f6
files Discovery/Inc/t3.h Discovery/Src/base.c Discovery/Src/motion.c Discovery/Src/t3.c Discovery/Src/tHome.c Discovery/Src/tMenuEditSystem.c
diffstat 6 files changed, 63 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/t3.h	Thu Oct 17 21:15:42 2019 +0200
+++ b/Discovery/Inc/t3.h	Thu Oct 17 23:09:17 2019 +0200
@@ -36,5 +36,6 @@
 void t3_init(void);
 void t3_refresh(void);
 void t3_change_customview(void);
+uint8_t t3_GetEnabled_customviews();
 
 #endif /* T3_H */
--- a/Discovery/Src/base.c	Thu Oct 17 21:15:42 2019 +0200
+++ b/Discovery/Src/base.c	Thu Oct 17 23:09:17 2019 +0200
@@ -895,7 +895,13 @@
 					settingsGetPointer()->design = 7; // auto switch to 9 if necessary
 				} else if ((status.page == PageDive) && (status.line != 0)) {
 					if (settingsGetPointer()->extraDisplay == EXTRADISPLAY_BIGFONT)
+					{
 						settingsGetPointer()->design = 3;
+						if(settingsGetPointer()->MotionDetection == MOTION_DETECT_SECTOR)
+						{
+							DefinePitchSectors(stateRealGetPointer()->lifeData.compass_pitch,CUSTOMER_DEFINED_VIEWS);
+						}
+					}
 					else if (settingsGetPointer()->extraDisplay
 							== EXTRADISPLAY_DECOGAME)
 						settingsGetPointer()->design = 4;
--- a/Discovery/Src/motion.c	Thu Oct 17 21:15:42 2019 +0200
+++ b/Discovery/Src/motion.c	Thu Oct 17 23:09:17 2019 +0200
@@ -12,6 +12,7 @@
 #include "motion.h"
 #include "data_central.h"
 #include "t7.h"
+#include "t3.h"
 #include "settings.h"
 
 #define	STABLE_STATE_COUNT			2	/* number of count to declare a state as stable (at the moment based on 100ms) */
@@ -62,7 +63,14 @@
 {
 	if(numOfSectors == CUSTOMER_DEFINED_VIEWS)
 	{
-		sectorDetection.count =  t7_GetEnabled_customviews();
+		if(settingsGetPointer()->design == 3)		/* Big font view ? */
+		{
+			sectorDetection.count =  t3_GetEnabled_customviews();
+		}
+		else
+		{
+			sectorDetection.count =  t7_GetEnabled_customviews();
+		}
 		if(sectorDetection.count > 7)
 		{
 			sectorDetection.count = 7;	/* more views are hard to manually control */
--- a/Discovery/Src/t3.c	Thu Oct 17 21:15:42 2019 +0200
+++ b/Discovery/Src/t3.c	Thu Oct 17 23:09:17 2019 +0200
@@ -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[] =
 {
@@ -1251,3 +1252,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;
+}
+
+
--- a/Discovery/Src/tHome.c	Thu Oct 17 21:15:42 2019 +0200
+++ b/Discovery/Src/tHome.c	Thu Oct 17 23:09:17 2019 +0200
@@ -148,8 +148,13 @@
             return;
 
         if(settingsGetPointer()->design == 3)
+        {
             settingsGetPointer()->design = 7;
-
+        	if(settingsGetPointer()->MotionDetection == MOTION_DETECT_SECTOR)
+        	{
+        		DefinePitchSectors(stateRealGetPointer()->lifeData.compass_pitch,CUSTOMER_DEFINED_VIEWS);
+        	}
+        }
         switch(get_globalState())
         {
         case StD:
@@ -239,8 +244,14 @@
         if(settingsGetPointer()->design == 4)
             return;
 
-        if(settingsGetPointer()->design == 3)
+        if(settingsGetPointer()->design == 3)	/* switch back to t7 (standard) view */
+        {
             settingsGetPointer()->design = 7;
+        	if(settingsGetPointer()->MotionDetection == MOTION_DETECT_SECTOR)
+        	{
+        		DefinePitchSectors(stateRealGetPointer()->lifeData.compass_pitch,CUSTOMER_DEFINED_VIEWS);
+        	}
+        }
 
         switch(get_globalState())
         {
--- a/Discovery/Src/tMenuEditSystem.c	Thu Oct 17 21:15:42 2019 +0200
+++ b/Discovery/Src/tMenuEditSystem.c	Thu Oct 17 23:09:17 2019 +0200
@@ -46,9 +46,6 @@
 /*#define HAVE_DEBUG_VIEW */
 static uint8_t infoPage = 0;
 
-
-static uint8_t infoPage = 0;
-
 /* Private function prototypes -----------------------------------------------*/
 void openEdit_DateTime(void);
 void openEdit_Language(void);