changeset 405:73db1565220b Improment_NVM

Bugfix Display of Sensor values: At divestart sensor values were shown even sensors were deactivated (fix SP). During iterating though customer views they were no longe be displayed. In the code were several if conditions for this cased => created new function and replaced local if conditions with new function to have a constistence behavior
author ideenmodellierer
date Sun, 12 Jan 2020 17:47:02 +0100
parents e729b8e7654d
children 439874690f85
files Discovery/Src/t7.c
diffstat 1 files changed, 33 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Src/t7.c	Sun Jan 12 17:45:36 2020 +0100
+++ b/Discovery/Src/t7.c	Sun Jan 12 17:47:02 2020 +0100
@@ -48,6 +48,7 @@
 void t7_refresh_sleep_design_fun(void);
 void t7_refresh_divemode_userselected_left_lower_corner(void);
 void t7_refresh_customview(void);
+uint8_t t7_customview_disabled(uint8_t view);
 
 void draw_frame(_Bool PluginBoxHeader, _Bool LinesOnTheSides, uint8_t colorBox, uint8_t colorLinesOnTheSide);
 
@@ -1491,9 +1492,31 @@
     return enabledViewCnt;
 }
 
+uint8_t t7_customview_disabled(uint8_t view)
+{
+	uint8_t i = 0;
+	uint8_t cv_disabled = 0;
+
+   	while(cv_changelist[i] != CVIEW_END)
+    {
+         if((view == cv_changelist[i]) && !CHECK_BIT_THOME(settingsGetPointer()->cv_configuration, cv_changelist[i]))
+         {
+        	 cv_disabled = 1;
+               break;
+         }
+         i++;
+    }
+
+    if (((view == CVIEW_sensors) || (view == CVIEW_sensors_mV)) &&
+       	((stateUsed->diveSettings.ppo2sensors_deactivated) || (stateUsed->diveSettings.ccrOption == 0)))
+    {
+      	cv_disabled = 1;
+    }
+    return cv_disabled;
+}
+
 void t7_change_customview(uint8_t action)
 {
-	int8_t i;
     uint8_t *pViews;
     uint8_t *pStartView,*pCurView, *pLastView;
     _Bool cv_disabled = 0;
@@ -1540,24 +1563,7 @@
 
     do
     {
-        cv_disabled = 0;
-        i=0;
-       	while(cv_changelist[i] != CVIEW_END)
-        {
-             if((*pViews == cv_changelist[i]) && !CHECK_BIT_THOME(settingsGetPointer()->cv_configuration, cv_changelist[i]))
-             {
-            	 cv_disabled = 1;
-                   break;
-             }
-             i++;
-        }
-
-        if (((*pViews == CVIEW_sensors) || (*pViews == CVIEW_sensors_mV)) &&
-           	((stateUsed->diveSettings.ppo2sensors_deactivated) || (stateUsed->diveSettings.ccrOption == 0)))
-        {
-	      	cv_disabled = 1;
-        }
-
+    	cv_disabled = t7_customview_disabled(*pViews);
         if(cv_disabled)		/* view is disabled => jump to next view */
         {
           	if((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_POS))
@@ -1598,6 +1604,7 @@
 
 void t7_refresh_customview(void)
 {
+	static uint8_t last_customview = CVIEW_END;
 
     char text[256];
     uint16_t textpointer = 0;
@@ -1614,13 +1621,13 @@
 	SSettings* pSettings;
 	pSettings = settingsGetPointer();
 
-    if((selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0))
-        t7_change_customview(ACTION_BUTTON_ENTER);
-    if((selection_customview == CVIEW_sensors_mV) &&(stateUsed->diveSettings.ccrOption == 0))
-        t7_change_customview(ACTION_BUTTON_ENTER);
-    if((selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0))
-        t7_change_customview(ACTION_BUTTON_ENTER);
-
+	if(last_customview != selection_customview)		/* check if current selection is disabled and should be skipped */
+	{
+		if(t7_customview_disabled(selection_customview))
+		{
+			t7_change_customview(ACTION_BUTTON_ENTER);
+		}
+	}
     switch(selection_customview)
     {
     case CVIEW_noneOrDebug: