changeset 212:c878a08dcf86

Merged in janlmulder/ostc4/cv-persistent (pull request #10) Custom views persistent and better support for mCCR
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Tue, 26 Mar 2019 22:23:26 +0000
parents 2de856965c55 (current diff) 85bd5fea5e08 (diff)
children d539ed9aa5b8 7012a521fa95
files
diffstat 7 files changed, 22 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Common/Inc/settings.h	Sun Mar 24 22:09:37 2019 +0000
+++ b/Common/Inc/settings.h	Tue Mar 26 22:23:26 2019 +0000
@@ -212,11 +212,11 @@
 	// new in 0xFFFF0017
 	uint8_t FactoryButtonBase;
 	uint8_t FactoryButtonBalance[3];
-
 	/* new in 0xFFFF0018 */
 	uint8_t FlipDisplay;
+	/* new in 0xFFFF0019 */
+	uint32_t cv_configuration;
 
-//to be continued
 } SSettings;
 
 typedef struct
--- a/Discovery/Inc/tHome.h	Sun Mar 24 22:09:37 2019 +0000
+++ b/Discovery/Inc/tHome.h	Tue Mar 26 22:23:26 2019 +0000
@@ -84,7 +84,6 @@
 
 // for custom view switch on/off 161122 hw
 extern const uint8_t cv_changelist[6];
-extern uint32_t cv_configuration;
 #define CHECK_BIT_THOME(var,pos) (((var)>>(pos)) & 1)
 
 typedef struct
--- a/Discovery/Src/settings.c	Sun Mar 24 22:09:37 2019 +0000
+++ b/Discovery/Src/settings.c	Tue Mar 26 22:23:26 2019 +0000
@@ -82,7 +82,7 @@
  * There might even be entries with fixed values that have no range
  */
 const SSettings SettingsStandard = {
-    .header = 0xFFFF0018,
+    .header = 0xFFFF0019,
     .warning_blink_dsec = 8 * 2,
     .lastDiveLogId = 0,
     .logFlashNextSampleStartAddress = 0,
@@ -306,6 +306,7 @@
     .FactoryButtonBalance[1] = 3,
     .FactoryButtonBalance[2] = 3,
 	.FlipDisplay = 0,
+	.cv_configuration = 0xFFFFFFFF,
 };
 
 /* Private function prototypes -----------------------------------------------*/
@@ -446,8 +447,11 @@
     case 0xFFFF0017:
     	pSettings->FlipDisplay = 0;
     	// no break
+    case 0xFFFF0018:
+    	pSettings->cv_configuration = 0xFFFFFFFF;
+    	// no break
     default:
-        pSettings->header 																= pStandard->header;
+        pSettings->header = pStandard->header;
         break; // no break before!!
     }
 }
--- a/Discovery/Src/t7.c	Sun Mar 24 22:09:37 2019 +0000
+++ b/Discovery/Src/t7.c	Tue Mar 26 22:23:26 2019 +0000
@@ -1517,12 +1517,19 @@
             cv_disabled = 0;
             for(int i=0;i<6;i++)
             {
-                if((*pViews == cv_changelist[i]) && !CHECK_BIT_THOME(cv_configuration, cv_changelist[i]))
+                if((*pViews == cv_changelist[i]) && !CHECK_BIT_THOME(settingsGetPointer()->cv_configuration, cv_changelist[i]))
                 {
                     cv_disabled = 1;
                     break;
                 }
             }
+
+            if ((*pViews == CVIEW_sensors || *pViews == CVIEW_sensors_mV) &&
+            	stateUsed->diveSettings.ppo2sensors_deactivated)
+            {
+            	cv_disabled = 1;
+            }
+
             if(cv_disabled)
             {
                 if(*pViews < CVIEW_END)
--- a/Discovery/Src/tHome.c	Sun Mar 24 22:09:37 2019 +0000
+++ b/Discovery/Src/tHome.c	Tue Mar 26 22:23:26 2019 +0000
@@ -56,7 +56,6 @@
 static uint16_t tHome_tick_count_cview;
 static uint16_t tHome_tick_count_field;
 
-uint32_t cv_configuration = 0xFFFFFFFF;
 const uint8_t cv_changelist[6] = {CVIEW_Compass, CVIEW_SummaryOfLeftCorner, CVIEW_Tissues, CVIEW_Profile, CVIEW_EADTime, CVIEW_Gaslist};
 
 /* Private function prototypes -----------------------------------------------*/
--- a/Discovery/Src/tMenuEditSystem.c	Sun Mar 24 22:09:37 2019 +0000
+++ b/Discovery/Src/tMenuEditSystem.c	Tue Mar 26 22:23:26 2019 +0000
@@ -149,7 +149,11 @@
 
 void openEdit_CustomviewDivemode(uint8_t line)
 {
-    cv_configuration ^= 1 << (cv_changelist[line-1]);
+	SSettings *pSettings = settingsGetPointer();
+	extern _Bool WriteSettings;
+
+    pSettings->cv_configuration ^= 1 << (cv_changelist[line-1]);
+    WriteSettings = 1;
     exitMenuEdit_to_Menu_with_Menu_Update();
 }
 
--- a/Discovery/Src/tMenuSystem.c	Sun Mar 24 22:09:37 2019 +0000
+++ b/Discovery/Src/tMenuSystem.c	Tue Mar 26 22:23:26 2019 +0000
@@ -59,7 +59,7 @@
         for(int i=0; i<6;i++)
         {
             id = cv_changelist[i];
-            text[textPointer++] = '\006' - CHECK_BIT_THOME(cv_configuration,id);
+            text[textPointer++] = '\006' - CHECK_BIT_THOME(data->cv_configuration,id);
             text[textPointer++] = ' ';
             textPointer += snprintf(&text[textPointer], 60,
                 "%c%c\n\r",