changeset 830:b7d93ff6b3b2 Evo_2_23

Added selection if an active gas shall be used for deco calculation or not: In previous version selecting a gas as deco gas automatically activated the gas for deco calculation. Some divers prever to have the deco time displayed which matches to the gas currently in use. These divers kept the gas deactivated unless they switch to it. Features like gas usability visualization or easy gas change using quick selection were not usable for these divers. With introduction of the new option the gas switching / visualization features may be used without having the gas been considered for calculation in the background. The option may be operated in the gas selection menu.
author Ideenmodellierer
date Thu, 16 Nov 2023 20:32:09 +0100
parents d5e68cc08f9a
children da632300e7d4
files Common/Inc/settings.h Discovery/Src/buehlmann.c Discovery/Src/settings.c Discovery/Src/simulation.c Discovery/Src/tMenuEditGasOC.c Discovery/Src/tMenuEditPlanner.c Discovery/Src/vpm.c
diffstat 7 files changed, 91 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/Common/Inc/settings.h	Thu Nov 16 20:25:01 2023 +0100
+++ b/Common/Inc/settings.h	Thu Nov 16 20:32:09 2023 +0100
@@ -119,7 +119,8 @@
 uint8_t deco:1;
 uint8_t travel:1;
 uint8_t off:1;
-uint8_t spare:3;
+uint8_t decocalc:1;
+uint8_t spare:2;
 } gasubit8_t;
 
 typedef union{
--- a/Discovery/Src/buehlmann.c	Thu Nov 16 20:25:01 2023 +0100
+++ b/Discovery/Src/buehlmann.c	Thu Nov 16 20:32:09 2023 +0100
@@ -258,7 +258,8 @@
 		gStop.depth = next_depth;
     for(i = gGas_id + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
     {
-        if(pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+        if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+        		|| (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
             break;
         float pressureChange =  ((float)pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero) / 10;
         if(gStop.depth <= pressureChange + 0.00001f)
@@ -458,7 +459,8 @@
         pressureTop_tmp = pressureTop;
         for(i = gGas_id + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
         {
-            if(pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            		|| (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
                 break;
             pressureChange = gSurface_pressure_bar + ((float)pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero) / 10;
             if(pressureBottom <= pressureChange)
@@ -473,7 +475,8 @@
         }
         for(i = gGas_id + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
         {
-            if(pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            	|| (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
                 break;
             pressureChange = gSurface_pressure_bar + ((float)pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero)/ 10;
             if((pressureChange < pressureBottom) && (pressureChange > pressureTop))
--- a/Discovery/Src/settings.c	Thu Nov 16 20:25:01 2023 +0100
+++ b/Discovery/Src/settings.c	Thu Nov 16 20:32:09 2023 +0100
@@ -89,7 +89,7 @@
  * There might even be entries with fixed values that have no range
  */
 const SSettings SettingsStandard = {
-    .header = 0xFFFF0028,
+    .header = 0xFFFF0029,
     .warning_blink_dsec = 8 * 2,
     .lastDiveLogId = 0,
     .logFlashNextSampleStartAddress = SAMPLESTART,
@@ -581,7 +581,19 @@
     	pSettings->cv_config_BigScreen = pSettings->cv_config_BigScreen >> (LEGACY_T3_START_ID_PRE_TIMER - 3);
     	pSettings->cv_config_BigScreen &= ~0x00000007;		/* just to be sure: clear lower three bits */
     	pSettings->cv_config_BigScreen |= tmp;
-
+    	// no break;
+    case 0xFFFF0028:						/* In previous version deco gases were automatically used for deco calculation */
+        for(tmp=1; tmp<=2*NUM_GASES; tmp++) /* This is now handled by an additional parameter. Set it to true to maintain same behavior as before */
+        {
+            if(Settings.gas[tmp].note.ub.deco)
+            {
+            	Settings.gas[tmp].note.ub.decocalc = 1;
+            }
+            else
+            {
+            	Settings.gas[tmp].note.ub.decocalc = 0;
+            }
+        }
     	// no break;
     default:
         pSettings->header = pStandard->header;
--- a/Discovery/Src/simulation.c	Thu Nov 16 20:25:01 2023 +0100
+++ b/Discovery/Src/simulation.c	Thu Nov 16 20:32:09 2023 +0100
@@ -466,7 +466,8 @@
         // ascend (deco) gases
         for(int i=1; i<=5;i++)
         {
-            if(pDiveState->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            if((pDiveState->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            		|| (pDiveState->diveSettings.gas[pDiveState->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
                 break;
             gasChangeListDepthGas20x2[ptrGasChangeList++] = pDiveState->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero;
             gasChangeListDepthGas20x2[ptrGasChangeList++] = pDiveState->diveSettings.decogaslist[i].GasIdInSettings;
--- a/Discovery/Src/tMenuEditGasOC.c	Thu Nov 16 20:25:01 2023 +0100
+++ b/Discovery/Src/tMenuEditGasOC.c	Thu Nov 16 20:32:09 2023 +0100
@@ -66,6 +66,7 @@
 uint8_t OnAction_GasType		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_ChangeDepth	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_SetToMOD		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+uint8_t OnAction_CalcDeco		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_BottleSize		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 
 uint8_t OnAction_First			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
@@ -204,11 +205,8 @@
     	return;
     }
 #endif
-    for(int i=0;i<(1+ (2*NUM_GASES));i++)
-        editGasPage.pGasLine[i].note.ub.first = 0;
 
     editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
-    editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1;
     setActualGas_DM(&stateUsedWrite->lifeData,editGasPage.gasID,setpoint);
 }
 
@@ -385,7 +383,7 @@
 /* surface mode */
 void openEdit_Gas(uint8_t line, uint8_t ccr)
 {
-    uint8_t gasID, oxygen, helium, depthDeco, active, first, depthMOD, deco, travel, inactive, off;//, bottleSizeLiter;
+    uint8_t gasID, oxygen, helium, depthDeco, active, first, depthMOD, deco, travel, inactive, off, decocalc;//, bottleSizeLiter;
 
     char text[32];
     char textMOD[32];
@@ -424,6 +422,7 @@
     deco = editGasPage.pGasLine[gasID].note.ub.deco;
     travel = editGasPage.pGasLine[gasID].note.ub.travel;
     off = editGasPage.pGasLine[gasID].note.ub.off;
+    decocalc = editGasPage.pGasLine[gasID].note.ub.decocalc;
     //bottleSizeLiter = editGasPage.pGasLine[gasID].bottle_size_liter;
 
     if(active)
@@ -480,11 +479,19 @@
         write_field_button(StMOG_GasType,	20, 710, ME_Y_LINE2, &FontT48, text);
 
 
-        if(deco)
+        if((deco) || (travel && ccr))
         {
             text[0] = TXT_ChangeDepth;
             text[1] = ' ';
-            text[2] = TXT_Deco;
+
+			if(deco)
+			{
+				text[2] = TXT_Deco;
+			}
+			else
+			{
+				text[2] = TXT_Travel;
+			}
             text[3] = 0;
             write_label_var(  20 ,800, ME_Y_LINE3, &FontT48, text);
 
@@ -501,6 +508,16 @@
             text[txtptr++] = TXT2BYTE_SetToMOD;
             text[txtptr++] = 0;
             write_field_button(StMOG_SetToMOD,		20, 710, ME_Y_LINE4, &FontT48,text);
+
+            if(deco)
+            {
+				txtptr = 0;
+				text[txtptr++] = TXT_2BYTE;
+				text[txtptr++] = TXT2BYTE_CalculateDeco;
+				text[txtptr++] = 0;
+
+				write_field_on_off(StMOG_CalcDeco, 20, 710, ME_Y_LINE5, &FontT48, text, decocalc);
+            }
         }
         else
         {
@@ -547,11 +564,15 @@
         setEvent(StMOG_Mix, 					(uint32_t)OnAction_Mix);
         setEvent(StMOG_GasType,				(uint32_t)OnAction_GasType);
 
-        if(deco)
+        if((deco) || (travel && ccr))
         {
             setEvent(StMOG_ChangeDepth,		(uint32_t)OnAction_ChangeDepth);
             setEvent(StMOG_SetToMOD,		(uint32_t)OnAction_SetToMOD);
         }
+        if(deco)
+        {
+        	setEvent(StMOG_CalcDeco,		(uint32_t)OnAction_CalcDeco);
+        }
 /*
         setEvent(StMOG_Bottle, 				(uint32_t)OnAction_BottleSize);
 */
@@ -1091,12 +1112,33 @@
 {
     uint8_t newChangeDepth = editGasPage.mod;
 
-    editGasPage.pGasLine[editGasPage.gasID].depth_meter = newChangeDepth;
+    if(editGasPage.pGasLine[editGasPage.gasID].note.ub.travel)
+    {
+    	editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel= newChangeDepth;
+    }
+    else
+    {
+    	editGasPage.pGasLine[editGasPage.gasID].depth_meter = newChangeDepth;
+    }
     tMenuEdit_newInput(StMOG_ChangeDepth, unit_depth_integer(newChangeDepth), 0, 0, 0);
 
     return UPDATE_DIVESETTINGS;
 }
 
+uint8_t OnAction_CalcDeco	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+{
+    if(editGasPage.pGasLine[editGasPage.gasID].note.ub.decocalc)
+    {
+    	editGasPage.pGasLine[editGasPage.gasID].note.ub.decocalc = 0;
+    }
+    else
+    {
+    	editGasPage.pGasLine[editGasPage.gasID].note.ub.decocalc = 1;
+    }
+    tMenuEdit_set_on_off(editId, editGasPage.pGasLine[editGasPage.gasID].note.ub.decocalc);
+
+    return UPDATE_DIVESETTINGS;
+}
 
 uint8_t OnAction_ChangeDepth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
@@ -1117,7 +1159,15 @@
         }
         if(newDepth > 255)
             newDepth = 255;
-        editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth;
+
+        if(editGasPage.pGasLine[editGasPage.gasID].note.ub.travel)
+        {
+        	editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = newDepth;
+        }
+        else
+        {
+        	editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth;
+        }
         tMenuEdit_newInput(editId, unit_depth_integer(newDepth), 0, 0, 0);
         return UPDATE_DIVESETTINGS;
     }
--- a/Discovery/Src/tMenuEditPlanner.c	Thu Nov 16 20:25:01 2023 +0100
+++ b/Discovery/Src/tMenuEditPlanner.c	Thu Nov 16 20:32:09 2023 +0100
@@ -449,7 +449,8 @@
 
     for(int i = 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
     {
-        if(stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+        if((stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+        	|| (stateSimGetPointer()->diveSettings.gas[stateSimGetPointer()->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
                 break;
         depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero;
         if(depthPrev <= depthChange)
@@ -464,7 +465,8 @@
 
     for(int i = GasIdPrev + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
     {
-            if(stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            if((stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            	|| (stateSimGetPointer()->diveSettings.gas[stateSimGetPointer()->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
                     break;
             depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero;
             if((depthChange < depthPrev) && (depthChange >= depthNext))
--- a/Discovery/Src/vpm.c	Thu Nov 16 20:25:01 2023 +0100
+++ b/Discovery/Src/vpm.c	Thu Nov 16 20:32:09 2023 +0100
@@ -460,10 +460,12 @@
 
     for (i = 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
     {
-        if(pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero  >= depth_change[0] + 1)
+        if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero  >= depth_change[0] + 1)
+        		&& (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc))
             continue;
 
-        if(pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero <= 0)
+        if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero <= 0)
+        	|| (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
             break;
 
         j++;