changeset 210:b2a9e9b02df0 cv-persistent

New feature: make selected customviews persistent Add the set of selected customviews during dive time to the persistent settings. Nothing has changed to the menu, so a user still has to access the on/off page from the simulator or during an actual dive, but once changed here, the settings are preserved for later dives. It feels a bit as waste of menu space to add a second page for something that is already available. And further, I have to admit the adding a page is rather complex to get the navigation right, so that is a 2nd argument not to add a page. Further, getting this one setting saved to the persist preferences is a bit of a hack. Misused an existing global bool value (WriteSettings) to force a actual write despite not being in surface mode. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Tue, 26 Mar 2019 13:00:15 +0100
parents 2de856965c55
children 85bd5fea5e08
files Common/Inc/settings.h Discovery/Inc/tHome.h Discovery/Src/settings.c Discovery/Src/t7.c Discovery/Src/tHome.c Discovery/Src/tMenuEditSystem.c Discovery/Src/tMenuSystem.c
diffstat 7 files changed, 15 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 13:00:15 2019 +0100
@@ -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 13:00:15 2019 +0100
@@ -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 13:00:15 2019 +0100
@@ -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 13:00:15 2019 +0100
@@ -1517,7 +1517,7 @@
             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;
--- a/Discovery/Src/tHome.c	Sun Mar 24 22:09:37 2019 +0000
+++ b/Discovery/Src/tHome.c	Tue Mar 26 13:00:15 2019 +0100
@@ -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 13:00:15 2019 +0100
@@ -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 13:00:15 2019 +0100
@@ -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",