changeset 288:ba229a012ac7 div-fixes-6

cleanup: no useless checks for simulator state and some more in the style of commit 74a8296a2318. And in addition more cleanup like removing commented and unused code, and making things static. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Mon, 29 Apr 2019 19:43:05 +0200
parents ba9d99a2e310
children 8466c994f3e6
files Discovery/Src/data_exchange_main.c Discovery/Src/tMenuEditDeco.c Discovery/Src/tMenuEditDecoParameter.c Discovery/Src/tMenuEditGasOC.c Discovery/Src/tMenuEditSetpoint.c Discovery/Src/tMenuEditXtra.c
diffstat 6 files changed, 138 insertions(+), 622 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c	Mon May 06 15:45:19 2019 +0200
+++ b/Discovery/Src/data_exchange_main.c	Mon Apr 29 19:43:05 2019 +0200
@@ -422,27 +422,16 @@
 
 void DataEX_copy_to_deco(void)
 {
-  SDiveState * pStateUsed;
 	if(decoLock == DECO_CALC_running)
         return;
-	if(stateUsed == stateRealGetPointer())
-		pStateUsed = stateRealGetPointerWrite();
-	else{
-		pStateUsed = stateSimGetPointerWrite();
-	}
 
 		if(decoLock == DECO_CALC_init_as_is_start_of_dive)
 		{
-	    vpm_init(&pStateUsed->vpm,  pStateUsed->diveSettings.vpm_conservatism, 0, 0);
+	    vpm_init(&stateUsedWrite->vpm,  stateUsedWrite->diveSettings.vpm_conservatism, 0, 0);
 	    buehlmann_init();
 	    timer_init();
-	    resetEvents(pStateUsed);
-      pStateUsed->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0;
-			/*
-			 * ToDo by Peter
-			 * copy VPM stuff etc. pp.
-			 * was   void initDiveState(SDiveSettings * pDiveSettings, SVpm * pVpm);
-			 */
+	    resetEvents(stateUsedWrite);
+	    stateUsedWrite->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0;
 		}
 
 		if(decoLock == DECO_CALC_FINSHED_Buehlmann)
@@ -454,48 +443,48 @@
 
     //Deco_calculation finished
     case DECO_CALC_FINSHED_vpm:
-        memcpy(&pStateUsed->decolistVPM,&stateDeco.decolistVPM,sizeof(SDecoinfo));
-				pStateUsed->decolistVPM.tickstamp = HAL_GetTick();
-        pStateUsed->vpm.deco_zone_reached = stateDeco.vpm.deco_zone_reached;
+        memcpy(&stateUsedWrite->decolistVPM,&stateDeco.decolistVPM,sizeof(SDecoinfo));
+        stateUsedWrite->decolistVPM.tickstamp = HAL_GetTick();
+        stateUsedWrite->vpm.deco_zone_reached = stateDeco.vpm.deco_zone_reached;
         for(int i = 0; i< 16; i++)
         {
-            pStateUsed->vpm.adjusted_critical_radius_he[i] = stateDeco.vpm.adjusted_critical_radius_he[i];
-            pStateUsed->vpm.adjusted_critical_radius_n2[i] = stateDeco.vpm.adjusted_critical_radius_n2[i];
-            pStateUsed->vpm.adjusted_crushing_pressure_he[i] = stateDeco.vpm.adjusted_crushing_pressure_he[i];
-            pStateUsed->vpm.adjusted_crushing_pressure_n2[i] = stateDeco.vpm.adjusted_crushing_pressure_n2[i];
-            pStateUsed->vpm.initial_allowable_gradient_he[i] = stateDeco.vpm.initial_allowable_gradient_he[i];
-            pStateUsed->vpm.initial_allowable_gradient_n2[i] = stateDeco.vpm.initial_allowable_gradient_n2[i];
-            pStateUsed->vpm.max_actual_gradient[i] = stateDeco.vpm.max_actual_gradient[i];
+        	stateUsedWrite->vpm.adjusted_critical_radius_he[i] = stateDeco.vpm.adjusted_critical_radius_he[i];
+        	stateUsedWrite->vpm.adjusted_critical_radius_n2[i] = stateDeco.vpm.adjusted_critical_radius_n2[i];
+        	stateUsedWrite->vpm.adjusted_crushing_pressure_he[i] = stateDeco.vpm.adjusted_crushing_pressure_he[i];
+        	stateUsedWrite->vpm.adjusted_crushing_pressure_n2[i] = stateDeco.vpm.adjusted_crushing_pressure_n2[i];
+        	stateUsedWrite->vpm.initial_allowable_gradient_he[i] = stateDeco.vpm.initial_allowable_gradient_he[i];
+        	stateUsedWrite->vpm.initial_allowable_gradient_n2[i] = stateDeco.vpm.initial_allowable_gradient_n2[i];
+        	stateUsedWrite->vpm.max_actual_gradient[i] = stateDeco.vpm.max_actual_gradient[i];
         }
         break;
     case DECO_CALC_FINSHED_Buehlmann:
-        memcpy(&pStateUsed->decolistBuehlmann,&stateDeco.decolistBuehlmann,sizeof(SDecoinfo));
-				pStateUsed->decolistBuehlmann.tickstamp = HAL_GetTick();
+        memcpy(&stateUsedWrite->decolistBuehlmann,&stateDeco.decolistBuehlmann,sizeof(SDecoinfo));
+        stateUsedWrite->decolistBuehlmann.tickstamp = HAL_GetTick();
         //Copy Data to be stored if regular Buehlmann, not FutureBuehlmann
-        pStateUsed->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = stateDeco.diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero;
+        stateUsedWrite->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = stateDeco.diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero;
         break;
     case DECO_CALC_FINSHED_FutureBuehlmann:
-        memcpy(&pStateUsed->decolistFutureBuehlmann,&stateDeco.decolistFutureBuehlmann,sizeof(SDecoinfo));
-				pStateUsed->decolistFutureBuehlmann.tickstamp = HAL_GetTick();
+        memcpy(&stateUsedWrite->decolistFutureBuehlmann,&stateDeco.decolistFutureBuehlmann,sizeof(SDecoinfo));
+        stateUsedWrite->decolistFutureBuehlmann.tickstamp = HAL_GetTick();
         break;
     case DECO_CALC_FINSHED_Futurevpm:
-        memcpy(&pStateUsed->decolistFutureVPM,&stateDeco.decolistFutureVPM,sizeof(SDecoinfo));
-				pStateUsed->decolistFutureVPM.tickstamp = HAL_GetTick();
+        memcpy(&stateUsedWrite->decolistFutureVPM,&stateDeco.decolistFutureVPM,sizeof(SDecoinfo));
+        stateUsedWrite->decolistFutureVPM.tickstamp = HAL_GetTick();
         break;
     }
 
     //Copy Inputdata from stateReal to stateDeco
-    memcpy(&stateDeco.lifeData,&pStateUsed->lifeData,sizeof(SLifeData));
-    memcpy(&stateDeco.diveSettings,&pStateUsed->diveSettings,sizeof(SDiveSettings));
+    memcpy(&stateDeco.lifeData,&stateUsedWrite->lifeData,sizeof(SLifeData));
+    memcpy(&stateDeco.diveSettings,&stateUsedWrite->diveSettings,sizeof(SDiveSettings));
 
-    stateDeco.vpm.deco_zone_reached = pStateUsed->vpm.deco_zone_reached;
+    stateDeco.vpm.deco_zone_reached = stateUsedWrite->vpm.deco_zone_reached;
     // memcpy(&stateDeco.vpm,&pStateUsed->vpm,sizeof(SVpm));
     for(int i = 0; i< 16; i++)
     {
-        stateDeco.vpm.max_crushing_pressure_he[i] = pStateUsed->vpm.max_crushing_pressure_he[i];
-        stateDeco.vpm.max_crushing_pressure_n2[i] = pStateUsed->vpm.max_crushing_pressure_n2[i];
-        stateDeco.vpm.adjusted_critical_radius_he[i] = pStateUsed->vpm.adjusted_critical_radius_he[i];
-        stateDeco.vpm.adjusted_critical_radius_n2[i] = pStateUsed->vpm.adjusted_critical_radius_n2[i];
+        stateDeco.vpm.max_crushing_pressure_he[i] = stateUsedWrite->vpm.max_crushing_pressure_he[i];
+        stateDeco.vpm.max_crushing_pressure_n2[i] = stateUsedWrite->vpm.max_crushing_pressure_n2[i];
+        stateDeco.vpm.adjusted_critical_radius_he[i] = stateUsedWrite->vpm.adjusted_critical_radius_he[i];
+        stateDeco.vpm.adjusted_critical_radius_n2[i] = stateUsedWrite->vpm.adjusted_critical_radius_n2[i];
     }
 		decoLock = DECO_CALC_ready;
 }
--- a/Discovery/Src/tMenuEditDeco.c	Mon May 06 15:45:19 2019 +0200
+++ b/Discovery/Src/tMenuEditDeco.c	Mon Apr 29 19:43:05 2019 +0200
@@ -34,27 +34,27 @@
 #include "unit.h"
 
 /* Private variables ---------------------------------------------------------*/
-uint8_t lineSelected = 0;
+static uint8_t lineSelected = 0;
 
 /* Private function prototypes -----------------------------------------------*/
 
-void openEdit_DiveMode(void);
-void openEdit_CCRModeSensorOrFixedSP(void);
-void openEdit_ppO2max(void);
-void openEdit_SafetyStop(void);
-void openEdit_FutureTTS(void);
-void openEdit_Salinity(void);
+static void openEdit_DiveMode(void);
+static void openEdit_CCRModeSensorOrFixedSP(void);
+static void openEdit_ppO2max(void);
+static void openEdit_SafetyStop(void);
+static void openEdit_FutureTTS(void);
+static void openEdit_Salinity(void);
 
 /* Announced function prototypes -----------------------------------------------*/
 
-uint8_t OnAction_OC			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_CC			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_Apnea		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_Gauge		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_FutureTTS	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_ppO2Max	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_SafetyStop (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_Salinity	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+static uint8_t OnAction_OC			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+static uint8_t OnAction_CC			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+static uint8_t OnAction_Apnea		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+static uint8_t OnAction_Gauge		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+static uint8_t OnAction_FutureTTS	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+static uint8_t OnAction_ppO2Max	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+static uint8_t OnAction_SafetyStop (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+static uint8_t OnAction_Salinity	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 /* Exported functions --------------------------------------------------------*/
 
 void openEdit_Deco(uint8_t line)
@@ -96,7 +96,7 @@
 /* Private functions ---------------------------------------------------------*/
 
 
-void openEdit_DiveMode(void)
+static void openEdit_DiveMode(void)
 {
 #define APNEAANDGAUGE
 
@@ -153,7 +153,7 @@
     write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
 }
 
-uint8_t OnAction_OC						(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+static uint8_t OnAction_OC						(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     SSettings *pSettings = settingsGetPointer();
     if(pSettings->dive_mode == DIVEMODE_OC)
@@ -168,7 +168,7 @@
 }
 
 
-uint8_t OnAction_CC						(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+static uint8_t OnAction_CC						(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     SSettings *pSettings = settingsGetPointer();
     if(pSettings->dive_mode == DIVEMODE_CCR)
@@ -183,7 +183,7 @@
 }
 
 
-uint8_t OnAction_Apnea				(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+static uint8_t OnAction_Apnea				(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     SSettings *pSettings = settingsGetPointer();
     if(pSettings->dive_mode == DIVEMODE_Apnea)
@@ -198,7 +198,7 @@
 }
 
 
-uint8_t OnAction_Gauge				(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+static uint8_t OnAction_Gauge				(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     SSettings *pSettings = settingsGetPointer();
     if(pSettings->dive_mode == DIVEMODE_Gauge)
@@ -213,7 +213,7 @@
 }
 
 
-void openEdit_CCRModeSensorOrFixedSP(void)
+static void openEdit_CCRModeSensorOrFixedSP(void)
 {
     SSettings *pSettings = settingsGetPointer();
 
@@ -226,7 +226,7 @@
 }
 
 
-void openEdit_SafetyStop(void)
+static void openEdit_SafetyStop(void)
 {
     uint32_t safetystopDuration, safetystopDepth;
     char text[64];
@@ -284,7 +284,7 @@
 }
 
 
-uint8_t OnAction_SafetyStop		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+static uint8_t OnAction_SafetyStop		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     uint8_t digitContentNew;
     uint32_t newSafetystopDuration, newSafetystopDepth;
@@ -372,7 +372,7 @@
 }
 
 
-void openEdit_Salinity(void)
+static void openEdit_Salinity(void)
 {
     char text[32];
     uint16_t y_line;
@@ -396,7 +396,7 @@
 }
 
 
-uint8_t OnAction_Salinity(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+static uint8_t OnAction_Salinity(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     SSettings *pSettings;
     uint8_t digitContentNew;
@@ -439,7 +439,7 @@
 }
 
 
-void openEdit_ppO2max(void)
+static void openEdit_ppO2max(void)
 {
     uint8_t maxL_std, maxL_deco;
     uint16_t y_line;
@@ -480,7 +480,7 @@
 }
 
 
-uint8_t OnAction_ppO2Max(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+static uint8_t OnAction_ppO2Max(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     SSettings *pSettings;
     uint8_t digitContentNew;
@@ -525,7 +525,7 @@
 }
 
 
-void openEdit_FutureTTS(void)
+static void openEdit_FutureTTS(void)
 {
     uint8_t futureTTS;
     uint16_t y_line;
@@ -555,7 +555,7 @@
 }
 
 
-uint8_t OnAction_FutureTTS(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+static uint8_t OnAction_FutureTTS(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     SSettings *pSettings;
     int8_t digitContentNew;
@@ -592,29 +592,5 @@
             digitContentNew = '0' + 15;
         return digitContentNew;
     }
-/*
-    if(action == ACTION_BUTTON_NEXT)
-    {
-        digitContentNew = digitContent + 1;
-        if((digitNumber == 0) && (digitContentNew > '1'))
-            digitContentNew = '0';
-        else
-        if(digitContentNew > '9')
-            digitContentNew = '0';
-        return digitContentNew;
-    }
-    if(action == ACTION_BUTTON_BACK)
-    {
-        digitContentNew = digitContent - 1;
-        if((digitNumber == 0) && (digitContentNew < '0'))
-            digitContentNew = '1';
-        else
-        if(digitContentNew < '0')
-            digitContentNew = '9';
-        return digitContentNew;
-    }
-*/
     return EXIT_TO_MENU;
 }
-
-
--- a/Discovery/Src/tMenuEditDecoParameter.c	Mon May 06 15:45:19 2019 +0200
+++ b/Discovery/Src/tMenuEditDecoParameter.c	Mon Apr 29 19:43:05 2019 +0200
@@ -36,12 +36,12 @@
 #define MEDP_TAB (380)
 
 /* Private function prototypes -----------------------------------------------*/
-void openEdit_DecoAlgorithm(void);
-void openEdit_DecoGF(void);
-void openEdit_DecoAltGF(void);
-void openEdit_DecoVPM(void);
-void openEdit_DecoLastStop(void);
-void openEdit_DM_SwitchAlgorithm(uint8_t line);
+static void openEdit_DecoAlgorithm(void);
+static void openEdit_DecoGF(void);
+static void openEdit_DecoAltGF(void);
+static void openEdit_DecoVPM(void);
+static void openEdit_DecoLastStop(void);
+static void openEdit_DM_SwitchAlgorithm(uint8_t line);
 
 //void openEdit_DecoGasUsage(void);
 
@@ -50,11 +50,6 @@
 uint8_t OnAction_VPM			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_AltGF			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_LastStop		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-
-uint8_t OnAction_GasAMV			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_DefaultAMV		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_GasReserve		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-
 uint8_t OnAction_DM_ActiveGF	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_DM_ActiveVPM	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_DM_AltActiveGF	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
@@ -95,42 +90,31 @@
 
 /* Private functions ---------------------------------------------------------*/
 
-void openEdit_DM_SwitchAlgorithm(uint8_t line)
+static void openEdit_DM_SwitchAlgorithm(uint8_t line)
 {
-    SDiveState * pState;
-
-    if(actual_menu_content == MENU_DIVE_REAL)
-    {
-        pState = stateRealGetPointerWrite();
-    }
-    else
-    {
-        pState = stateSimGetPointerWrite();
-    }
-
     switch(line)
     {
     case 1:
     default:
-        pState->diveSettings.deco_type.ub.standard = VPM_MODE;
+        stateUsedWrite->diveSettings.deco_type.ub.standard = VPM_MODE;
         break;
     case 2:
 
-        pState->diveSettings.gf_high = settingsGetPointer()->GF_high;
-        pState->diveSettings.gf_low = settingsGetPointer()->GF_low;
-        pState->diveSettings.deco_type.ub.standard = GF_MODE;
+    	stateUsedWrite->diveSettings.gf_high = settingsGetPointer()->GF_high;
+    	stateUsedWrite->diveSettings.gf_low = settingsGetPointer()->GF_low;
+    	stateUsedWrite->diveSettings.deco_type.ub.standard = GF_MODE;
         break;
     case 3:
-        pState->diveSettings.gf_high = settingsGetPointer()->aGF_high;
-        pState->diveSettings.gf_low = settingsGetPointer()->aGF_low;
-        pState->diveSettings.deco_type.ub.standard = GF_MODE;
+    	stateUsedWrite->diveSettings.gf_high = settingsGetPointer()->aGF_high;
+    	stateUsedWrite->diveSettings.gf_low = settingsGetPointer()->aGF_low;
+    	stateUsedWrite->diveSettings.deco_type.ub.standard = GF_MODE;
         break;
     }
     exitMenuEdit_to_Home_with_Menu_Update();
 }
 
 
-void openEdit_DecoAlgorithm(void)
+static void openEdit_DecoAlgorithm(void)
 {
     SSettings *pSettings = settingsGetPointer();
 
@@ -143,7 +127,7 @@
 }
 
 
-void openEdit_DecoVPM(void)
+static void openEdit_DecoVPM(void)
 {
     uint8_t vpm;
     char text[32];
@@ -167,7 +151,7 @@
 }
 
 
-void openEdit_DecoGF(void)
+static void openEdit_DecoGF(void)
 {
     uint8_t gfLow,gfHigh;
     char text[32];
@@ -192,7 +176,7 @@
 }
 
 
-void openEdit_DecoAltGF(void)
+static void openEdit_DecoAltGF(void)
 {
     uint8_t aGfLow,aGfHigh;
     char text[32];
@@ -216,7 +200,7 @@
 }
 
 
-void openEdit_DecoLastStop(void)
+static void openEdit_DecoLastStop(void)
 {
     uint8_t lastStop;
     char text[32];
@@ -247,62 +231,6 @@
     startEdit();
 }
 
-/*
-void openEdit_DecoGF_DM(void)
-    {
-      const SDiveSettings * pDiveSettings;
-        uint8_t activeGF, activeVPM, aActiveGF;
-        SSettings *pSettings = settingsGetPointer();
-
-        if(actual_menu_content == MENU_DIVE_REAL)
-        {
-            const SDiveState * pState = stateRealGetPointer();
-            pDiveSettings = &pState->diveSettings;
-        }
-        else
-        {
-            const SDiveState * pState = stateSimGetPointer();
-            pDiveSettings = &pState->diveSettings;
-        }
-        if(pDiveSettings->deco_type.ub.standard == VPM_MODE)
-        {
-            aActiveGF = 0;
-            activeGF = 0;
-            activeVPM = 1;
-        }
-        else
-        if((pDiveSettings->gf_high == pSettings->GF_high) && (pDiveSettings->gf_low == pSettings->GF_low))
-        {
-            aActiveGF = 0;
-            activeGF = 1;
-            activeVPM = 0;
-        }
-        else
-        {
-            aActiveGF = 1;
-            activeGF = 0;
-            activeVPM = 0;
-        }
-
-        write_label_fix(  30, 340,  90, &FontT42, TXT_ZHL16GF);
-        write_label_fix(  30, 340, 140, &FontT42, TXT_low_high);
-        write_label_fix( 400, 600,  90, &FontT42, TXT_VPM);
-        write_label_fix( 400, 600, 140, &FontT42, TXT_Conservatism);
-        write_label_fix( 660, 799,  90, &FontT42, TXT_aGF);
-
-        write_field_on_off(StMDECOP7_ActiveGF,		 30, 170, 405, &FontT48, "Active", activeGF);
-
-        write_field_on_off(StMDECOP8_ActiveVPM,	400, 600, 405, &FontT48, "Active", activeVPM);
-
-        write_field_on_off(StMDECOP9_ActiveAltGF,	660, 799, 405, &FontT48, "Active", aActiveGF);
-
-
-        setEvent(StMDECOP7_ActiveGF, 		(uint32_t)OnAction_DM_ActiveGF);
-        setEvent(StMDECOP8_ActiveVPM,		(uint32_t)OnAction_DM_ActiveVPM);
-        setEvent(StMDECOP9_ActiveAltGF, 		(uint32_t)OnAction_DM_AltActiveGF);
-}
-*/
-
 uint8_t OnAction_VPM(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     SSettings *pSettings;
@@ -518,53 +446,9 @@
     return EXIT_TO_MENU;
 }
 
-
-uint8_t OnAction_ActiveGF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
-{
-    SSettings *pSettings;
-    pSettings = settingsGetPointer();
-
-    if(pSettings->deco_type.ub.standard == GF_MODE)
-        return 255;
-
-    pSettings->deco_type.ub.standard = GF_MODE;
-    tMenuEdit_set_on_off(editId, 1);
-    tMenuEdit_set_on_off(StMDECOP8_ActiveVPM, 0);
-
-    return UPDATE_DIVESETTINGS;
-}
-
-
-uint8_t OnAction_ActiveVPM(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
-{
-    SSettings *pSettings;
-    pSettings = settingsGetPointer();
-
-    if(pSettings->deco_type.ub.standard == VPM_MODE)
-        return 255;
-
-    pSettings->deco_type.ub.standard = VPM_MODE;
-    tMenuEdit_set_on_off(editId, 1);
-    tMenuEdit_set_on_off(StMDECOP7_ActiveGF, 0);
-
-    return UPDATE_DIVESETTINGS;
-}
-
-
 uint8_t OnAction_DM_ActiveVPM(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
-    SDiveSettings * pDiveSettings;
-    if(actual_menu_content == MENU_DIVE_REAL)
-    {
-        SDiveState * pState = stateRealGetPointerWrite();
-        pDiveSettings = &pState->diveSettings;
-    }
-    else
-    {
-        SDiveState * pState = stateSimGetPointerWrite();
-        pDiveSettings = &pState->diveSettings;
-    }
-    pDiveSettings->deco_type.ub.standard = VPM_MODE;
+    stateUsedWrite->diveSettings.deco_type.ub.standard = VPM_MODE;
     return EXIT_TO_HOME;
 }
 
@@ -572,164 +456,20 @@
 uint8_t OnAction_DM_ActiveGF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     SSettings *pSettings = settingsGetPointer();
-    SDiveSettings * pDiveSettings;
-    if(actual_menu_content == MENU_DIVE_REAL)
-    {
-        SDiveState * pState = stateRealGetPointerWrite();
-        pDiveSettings = &pState->diveSettings;
-    }
-    else
-    {
-        SDiveState * pState = stateSimGetPointerWrite();
-        pDiveSettings = &pState->diveSettings;
-    }
-    pDiveSettings->gf_high = pSettings->GF_high;
-    pDiveSettings->gf_low = pSettings->GF_low;
-    pDiveSettings->deco_type.ub.standard = GF_MODE;
+
+    stateUsedWrite->diveSettings.gf_high = pSettings->GF_high;
+    stateUsedWrite->diveSettings.gf_low = pSettings->GF_low;
+    stateUsedWrite->diveSettings.deco_type.ub.standard = GF_MODE;
     return EXIT_TO_HOME;
 }
 
 
 uint8_t OnAction_DM_AltActiveGF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
-    SSettings *pSettings = settingsGetPointer();
-    SDiveSettings * pDiveSettings;
-    if(actual_menu_content == MENU_DIVE_REAL)
-    {
-        SDiveState * pState = stateRealGetPointerWrite();
-        pDiveSettings = &pState->diveSettings;
-    }
-    else
-    {
-        SDiveState * pState = stateSimGetPointerWrite();
-        pDiveSettings = &pState->diveSettings;
-    }
-    pDiveSettings->gf_high = pSettings->aGF_high;
-    pDiveSettings->gf_low = pSettings->aGF_low;
-    pDiveSettings->deco_type.ub.standard = GF_MODE;
+	SSettings *pSettings = settingsGetPointer();
+
+    stateUsedWrite->diveSettings.gf_high = pSettings->aGF_high;
+    stateUsedWrite->diveSettings.gf_low = pSettings->aGF_low;
+    stateUsedWrite->diveSettings.deco_type.ub.standard = GF_MODE;
     return EXIT_TO_HOME;
 }
-
-
-/*
-void openEdit_DecoGasUsage(void)
-{
-    uint8_t amv, reserve;
-    char text[32];
-    SSettings *pSettings;
-
-    pSettings = settingsGetPointer();
-
-    amv = pSettings->AtemMinutenVolumenLiter;
-    reserve = pSettings->ReserveFractionDenominator;
-
-    text[0] = '\a';
-    text[1] = TXT_AtemGasVorrat;
-    text[2] = 0;
-
-    write_topline(text);
-
-    write_label_fix(  30, 340,  90, &FontT42, TXT_LiterproMinute);
-    write_label_fix(  30, 340, 250, &FontT42, TXT_Default);
-    write_label_fix( 430, 740,  90, &FontT42, TXT_Reserve);
-
-    strcpy(text, "1/0");
-    text[2] += reserve;
-    write_field_udigit(StMDECOP5_AMV,				 30, 320, 150, &FontT105, "###", (uint32_t)amv, 0, 0, 0);
-    write_field_button(StMDECOP5_DefaultAMV,	 30, 170, 290,  &FontT48, "25");
-    write_field_button(StMDECOP5_RESERVE,		430, 640, 150, &FontT105, text);
-
-    setEvent(StMDECOP5_AMV, 				(uint32_t)OnAction_GasAMV);
-    setEvent(StMDECOP5_DefaultAMV, (uint32_t)OnAction_DefaultAMV);
-    setEvent(StMDECOP5_RESERVE, 		(uint32_t)OnAction_GasReserve);
-}
-
-
-uint8_t OnAction_GasAMV				(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
-{
-    uint8_t digitContentNew;
-    uint32_t newAMV;
-    SSettings *pSettings;
-
-    if(action == ACTION_BUTTON_ENTER)
-    {
-        return digitContent;
-    }
-    if(action == ACTION_BUTTON_ENTER_FINAL)
-    {
-        evaluateNewString(editId, &newAMV, 0, 0, 0);
-
-        if(newAMV < 5)
-            newAMV = 5;
-        if(newAMV > 190)
-            newAMV = 190;
-
-        pSettings = settingsGetPointer();
-        pSettings->AtemMinutenVolumenLiter = newAMV;
-
-        tMenuEdit_newInput(editId, newAMV, 0, 0, 0);
-
-        return 255;
-    }
-    if(action == ACTION_BUTTON_NEXT)
-    {
-        if((digitNumber == 0) && (digitContentNew >= '1'))
-            digitContentNew = '0';
-        else
-            digitContentNew = digitContent + 1;
-        if(digitContentNew > '9')
-            digitContentNew = '0';
-        return digitContentNew;
-    }
-    if(action == ACTION_BUTTON_BACK)
-    {
-        if((digitNumber == 0) && (digitContentNew == '0'))
-            digitContentNew = '1';
-        else
-            digitContentNew = digitContent - 1;
-        if(digitContentNew < '0')
-            digitContentNew = '9';
-        return digitContentNew;
-    }
-
-    return UNSPECIFIC_RETURN;
-}
-
-
-uint8_t OnAction_DefaultAMV		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
-{
-    uint32_t newAMV;
-    SSettings *pSettings;
-
-    newAMV = 25;
-
-    pSettings = settingsGetPointer();
-    pSettings->AtemMinutenVolumenLiter = newAMV;
-    tMenuEdit_newInput(StMDECOP5_AMV, newAMV, 0, 0, 0);
-
-    return UNSPECIFIC_RETURN;
-}
-
-
-uint8_t OnAction_GasReserve		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
-{
-    uint32_t reserve;
-    SSettings *pSettings;
-    char text[32];
-
-    pSettings = settingsGetPointer();
-    reserve = pSettings->ReserveFractionDenominator;
-    if(reserve <= 3)
-        reserve = 4;
-    else
-        reserve = 3;
-
-    pSettings->ReserveFractionDenominator = reserve;
-
-    strcpy(text, "1/0");
-    text[2] += reserve;
-    tMenuEdit_newButtonText(editId, text);
-
-    return UNSPECIFIC_RETURN;
-}
-*/
--- a/Discovery/Src/tMenuEditGasOC.c	Mon May 06 15:45:19 2019 +0200
+++ b/Discovery/Src/tMenuEditGasOC.c	Mon Apr 29 19:43:05 2019 +0200
@@ -148,24 +148,14 @@
 
 void openEdit_DiveGasSelect_Subroutine(uint8_t line, uint8_t ccr)
 {
-    SDiveState * pState;
     uint8_t setpoint;
 
-    if(actual_menu_content == MENU_DIVE_REAL)
-    {
-        pState = stateRealGetPointerWrite();
-        editGasPage.pGasLine = pState->diveSettings.gas;
-    }
-    else
-    {
-        pState = stateSimGetPointerWrite();
-        editGasPage.pGasLine = pState->diveSettings.gas;
-    }
+    editGasPage.pGasLine = stateUsed->diveSettings.gas;
 
     if(ccr)
     {
         editGasPage.gasID = line + NUM_OFFSET_DILUENT;
-        setpoint = pState->lifeData.actualGas.setPoint_cbar;
+        setpoint = stateUsed->lifeData.actualGas.setPoint_cbar;
     }
     else
     {
@@ -178,7 +168,7 @@
 
     editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
     editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1;
-    setActualGas_DM(&pState->lifeData,editGasPage.gasID,setpoint);
+    setActualGas_DM(&stateUsedWrite->lifeData,editGasPage.gasID,setpoint);
 }
 
 /* extra gas and gas on/off option */
@@ -186,21 +176,12 @@
 {
     char text[32];
     uint8_t oxygen, helium, gasOffset, textpointer, lineCount, ptrGas;
-    SDiveState * pState;
+    //SDiveState * pState;
 
-    if(actual_menu_content == MENU_DIVE_REAL)
-    {
-        pState = stateRealGetPointerWrite();
-        editGasPage.pGasLine = pState->diveSettings.gas;
-    }
-    else
-    {
-        pState = stateSimGetPointerWrite();
-        editGasPage.pGasLine = pState->diveSettings.gas;
-    }
+    editGasPage.pGasLine = stateUsed->diveSettings.gas;
     if(ccr)
     {
-        editGasPage.setpoint = pState->lifeData.actualGas.setPoint_cbar;
+        editGasPage.setpoint = stateUsed->lifeData.actualGas.setPoint_cbar;
     }
     editGasPage.ccr = ccr;
 
@@ -322,17 +303,12 @@
         if((newOxygen + newHelium) > 100)
             newOxygen = 100 - newHelium;
 
-        SDiveState * pDiveState = 0;
+        //SDiveState * pDiveState = 0;
 
         for(int i=1;i<=(2*NUM_GASES);i++)
             editGasPage.pGasLine[i].note.ub.first = 0;
 
-        if(actual_menu_content == MENU_DIVE_REAL)
-            pDiveState = stateRealGetPointerWrite();
-        else
-            pDiveState = stateSimGetPointerWrite();
-
-        setActualGas_ExtraGas(&pDiveState->lifeData, newOxygen, newHelium, 0);
+        setActualGas_ExtraGas(&stateUsedWrite->lifeData, newOxygen, newHelium, 0);
         tMEGas_check_switch_to_bailout();
         return EXIT_TO_HOME;
     }
@@ -357,16 +333,9 @@
 
 void tMEGas_check_switch_to_bailout(void)
 {
-    SDiveState *pState;
-
-    if(actual_menu_content == MENU_DIVE_REAL)
-        pState = stateRealGetPointerWrite();
-    else
-        pState = stateSimGetPointerWrite();
-
-    if(pState->diveSettings.diveMode == DIVEMODE_CCR)
+    if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR)
     {
-        pState->diveSettings.diveMode = DIVEMODE_OC;
+    	stateUsedWrite->diveSettings.diveMode = DIVEMODE_OC;
         block_diluent_page();
     }
 }
--- a/Discovery/Src/tMenuEditSetpoint.c	Mon May 06 15:45:19 2019 +0200
+++ b/Discovery/Src/tMenuEditSetpoint.c	Mon Apr 29 19:43:05 2019 +0200
@@ -43,20 +43,15 @@
 
 
 /* Private variables ---------------------------------------------------------*/
-SEditSetpointPage editSetpointPage;
+static SEditSetpointPage editSetpointPage;
 
 /* Private function prototypes -----------------------------------------------*/
 
-
 /* Announced function prototypes -----------------------------------------------*/
-uint8_t OnAction_SP_Setpoint    (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_SP_Depth       (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-//uint8_t OnAction_SP_First     (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-//uint8_t OnAction_SP_Active    (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-//uint8_t OnAction_SP_DM_Select (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_SP_DM_Sensor1	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_SP_DM_Sensor2	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-uint8_t OnAction_SP_DM_Sensor3	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+static uint8_t OnAction_SP_Setpoint    (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+static uint8_t OnAction_SP_DM_Sensor1	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+static uint8_t OnAction_SP_DM_Sensor2	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+static uint8_t OnAction_SP_DM_Sensor3	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 
 /* Exported functions --------------------------------------------------------*/
 
@@ -68,52 +63,46 @@
     if(actual_menu_content != MENU_SURFACE)
     {
         uint8_t setpointCbar, actualGasID;
-        SDiveState *pState;
         setpointCbar = 100;
 
-        if(actual_menu_content == MENU_DIVE_REAL)
-            pState = stateRealGetPointerWrite();
-        else
-            pState = stateSimGetPointerWrite();
-
         // actualGasID
-        if(pState->diveSettings.diveMode != DIVEMODE_CCR)
+        if(stateUsedWrite->diveSettings.diveMode != DIVEMODE_CCR)
         {
-            actualGasID = pState->lifeData.lastDiluent_GasIdInSettings;
+            actualGasID = stateUsedWrite->lifeData.lastDiluent_GasIdInSettings;
             if((actualGasID <= NUM_OFFSET_DILUENT) || (actualGasID > NUM_GASES + NUM_OFFSET_DILUENT))
                 actualGasID = NUM_OFFSET_DILUENT + 1;
         }
         else
-            actualGasID = pState->lifeData.actualGas.GasIdInSettings;
+            actualGasID = stateUsedWrite->lifeData.actualGas.GasIdInSettings;
 
         // setpointCbar, CCR_Mode and sensor menu
         if(line < 6)
         {
-            setpointCbar = pState->diveSettings.setpoint[line].setpoint_cbar;
-            pState->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint;
+            setpointCbar = stateUsedWrite->diveSettings.setpoint[line].setpoint_cbar;
+            stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint;
 
             // BetterSetpoint warning only once
             if(actualBetterSetpointId() == line)
             {
                 uint8_t depth;
-                depth = pState->diveSettings.setpoint[line].depth_meter;
+                depth = stateUsedWrite->diveSettings.setpoint[line].depth_meter;
                 // BetterSetpoint warning only once -> clear active
                 for(int i=0; i<=NUM_GASES; i++)
                 {
-                    pState->diveSettings.setpoint[i].note.ub.first = 0;
-                    if(pState->diveSettings.setpoint[i].depth_meter <= depth)
-                        pState->diveSettings.setpoint[i].note.ub.active = 0;
+                	stateUsedWrite->diveSettings.setpoint[i].note.ub.first = 0;
+                    if(stateUsedWrite->diveSettings.setpoint[i].depth_meter <= depth)
+                    	stateUsedWrite->diveSettings.setpoint[i].note.ub.active = 0;
                 }
-                pState->diveSettings.setpoint[line].note.ub.first = 1;
+                stateUsedWrite->diveSettings.setpoint[line].note.ub.first = 1;
             }
         }
         else
         {
-            if(pState->diveSettings.CCR_Mode != CCRMODE_Sensors)
+            if(stateUsedWrite->diveSettings.CCR_Mode != CCRMODE_Sensors)
             {
                 /* setpoint_cbar will be written by updateSetpointStateUsed() in main.c loop */
                 setpointCbar = 255;
-                pState->diveSettings.CCR_Mode = CCRMODE_Sensors;
+                stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_Sensors;
             }
             else
             {
@@ -121,11 +110,11 @@
             }
         }
 
-        setActualGas_DM(&pState->lifeData,actualGasID,setpointCbar);
+        setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar);
 
-        if(pState->diveSettings.diveMode != DIVEMODE_CCR)
+        if(stateUsedWrite->diveSettings.diveMode != DIVEMODE_CCR)
         {
-            pState->diveSettings.diveMode = DIVEMODE_CCR;
+        	stateUsedWrite->diveSettings.diveMode = DIVEMODE_CCR;
             unblock_diluent_page();
         }
 
@@ -155,11 +144,11 @@
             sensorActive[0] = 1;
             sensorActive[1] = 1;
             sensorActive[2] = 1;
-            if(pState->diveSettings.ppo2sensors_deactivated & 1)
+            if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1)
                 sensorActive[0] = 0;
-            if(pState->diveSettings.ppo2sensors_deactivated & 2)
+            if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 2)
                 sensorActive[1] = 0;
-            if(pState->diveSettings.ppo2sensors_deactivated & 4)
+            if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 4)
                 sensorActive[2] = 0;
 
             write_field_on_off(StMSP_Sensor1,	 30, 95, ME_Y_LINE1,  &FontT48, "", sensorActive[0]);
@@ -241,7 +230,7 @@
     }
 }
 
-uint8_t OnAction_SP_Setpoint(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+static uint8_t OnAction_SP_Setpoint(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     int8_t digitContentNew;
     uint32_t new_integer_part, new_fractional_part, new_cbar, newDepth;
@@ -297,216 +286,73 @@
     return EXIT_TO_MENU;
 }
 
-uint8_t OnAction_SP_Depth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
-{
-    uint8_t digitContentNew;
-    uint32_t newDepth;
-
-    if(action == ACTION_BUTTON_ENTER)
-    {
-        return digitContent;
-    }
-    if(action == ACTION_BUTTON_ENTER_FINAL)
-    {
-        evaluateNewString(editId, &newDepth, 0, 0, 0);
-        if(newDepth > 255)
-            newDepth = 255;
-
-        editSetpointPage.pSetpointLine[editSetpointPage.spID].depth_meter = newDepth;
-
-        tMenuEdit_newInput(editId, newDepth, 0, 0, 0);
-        return UPDATE_DIVESETTINGS;
-    }
-    if(action == ACTION_BUTTON_NEXT)
-    {
-        digitContentNew = digitContent + 1;
-        if(digitContentNew > '9')
-            digitContentNew = '0';
-        return digitContentNew;
-    }
-    if(action == ACTION_BUTTON_BACK)
-    {
-        digitContentNew = digitContent - 1;
-        if(digitContentNew < '0')
-            digitContentNew = '9';
-        return digitContentNew;
-    }
-
-    return UNSPECIFIC_RETURN;
-}
-
 void openEdit_DiveSelectBetterSetpoint(void)
 {
     uint8_t spId;
-    SDiveState *pState;
     uint8_t depth;
 
     spId = actualBetterSetpointId();
 
-    if(actual_menu_content == MENU_DIVE_REAL)
-        pState = stateRealGetPointerWrite();
-    else
-        pState = stateSimGetPointerWrite();
-
-    depth = pState->diveSettings.setpoint[spId].depth_meter;
+    depth = stateUsedWrite->diveSettings.setpoint[spId].depth_meter;
 
     // BetterSetpoint warning only once -> clear active
     for(int i=0; i<=NUM_GASES; i++)
     {
-        pState->diveSettings.setpoint[i].note.ub.first = 0;
-        if(pState->diveSettings.setpoint[i].depth_meter <= depth)
-            pState->diveSettings.setpoint[i].note.ub.active = 0;
+    	stateUsedWrite->diveSettings.setpoint[i].note.ub.first = 0;
+        if(stateUsedWrite->diveSettings.setpoint[i].depth_meter <= depth)
+        	stateUsedWrite->diveSettings.setpoint[i].note.ub.active = 0;
     }
 
     // new setpoint
-    pState->diveSettings.setpoint[spId].note.ub.first = 1;
+    stateUsedWrite->diveSettings.setpoint[spId].note.ub.first = 1;
 
     // change in lifeData
-    setActualGas_DM(&pState->lifeData, pState->lifeData.actualGas.GasIdInSettings, pState->diveSettings.setpoint[spId].setpoint_cbar);
+    setActualGas_DM(&stateUsedWrite->lifeData, stateUsedWrite->lifeData.actualGas.GasIdInSettings, stateUsedWrite->diveSettings.setpoint[spId].setpoint_cbar);
 }
 
-uint8_t OnAction_SP_DM_Sensor1	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+static uint8_t OnAction_SP_DM_Sensor1	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
-    SDiveState * pDiveState = 0;
-
-    if(actual_menu_content == MENU_DIVE_REAL)
-        pDiveState = stateRealGetPointerWrite();
-    else
-        pDiveState = stateSimGetPointerWrite();
-
-    if(pDiveState->diveSettings.ppo2sensors_deactivated & 1)
+    if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1)
     {
-        pDiveState->diveSettings.ppo2sensors_deactivated &= 4+2;
+    	stateUsedWrite->diveSettings.ppo2sensors_deactivated &= 4+2;
         tMenuEdit_set_on_off(editId, 1);
     }
     else
     {
-        pDiveState->diveSettings.ppo2sensors_deactivated |= 1;
+    	stateUsedWrite->diveSettings.ppo2sensors_deactivated |= 1;
         tMenuEdit_set_on_off(editId, 0);
     }
 
     return UNSPECIFIC_RETURN;
 }
 
-uint8_t OnAction_SP_DM_Sensor2	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+static uint8_t OnAction_SP_DM_Sensor2	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
-    SDiveState * pDiveState = 0;
-
-    if(actual_menu_content == MENU_DIVE_REAL)
-        pDiveState = stateRealGetPointerWrite();
-    else
-        pDiveState = stateSimGetPointerWrite();
-
-    if(pDiveState->diveSettings.ppo2sensors_deactivated & 2)
+    if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 2)
     {
-        pDiveState->diveSettings.ppo2sensors_deactivated &= 4+1;
+    	stateUsedWrite->diveSettings.ppo2sensors_deactivated &= 4+1;
         tMenuEdit_set_on_off(editId, 1);
     }
     else
     {
-        pDiveState->diveSettings.ppo2sensors_deactivated |= 2;
+    	stateUsedWrite->diveSettings.ppo2sensors_deactivated |= 2;
         tMenuEdit_set_on_off(editId, 0);
     }
 
     return UNSPECIFIC_RETURN;
 }
 
-uint8_t OnAction_SP_DM_Sensor3	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+static uint8_t OnAction_SP_DM_Sensor3	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
-    SDiveState * pDiveState = 0;
-
-    if(actual_menu_content == MENU_DIVE_REAL)
-        pDiveState = stateRealGetPointerWrite();
-    else
-        pDiveState = stateSimGetPointerWrite();
-
-    if(pDiveState->diveSettings.ppo2sensors_deactivated & 4)
+    if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 4)
     {
-        pDiveState->diveSettings.ppo2sensors_deactivated &= 2+1;
+    	stateUsedWrite->diveSettings.ppo2sensors_deactivated &= 2+1;
         tMenuEdit_set_on_off(editId, 1);
     }
     else
     {
-        pDiveState->diveSettings.ppo2sensors_deactivated |= 4;
+    	stateUsedWrite->diveSettings.ppo2sensors_deactivated |= 4;
         tMenuEdit_set_on_off(editId, 0);
     }
     return UNSPECIFIC_RETURN;
 }
-
-/* Private functions ---------------------------------------------------------*/
-
-/*
-uint8_t OnAction_SP_Active(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
-{
-    uint8_t active, first;
-
-    first = editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.first;
-
-    if(first)
-        return UNSPECIFIC_RETURN;
-
-    active = editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active;
-
-    if(active)
-    {
-        active = 0;
-        editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active = 0;
-    }
-    else
-    {
-        active = 1;
-        editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active = 1;
-    }
-    tMenuEdit_set_on_off(editId, active);
-
-    return UPDATE_DIVESETTINGS;
-}
-
-uint8_t OnAction_SP_First(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
-{
-    uint8_t active, first, i;
-    SDiveState * pStateReal = stateRealGetPointerWrite();
-
-    first = editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.first;
-
-    if(first)
-        return UNSPECIFIC_RETURN;
-
-    for(i=0;i<NUM_GASES;i++)
-        editSetpointPage.pSetpointLine[i].note.ub.first = 0;
-
-    editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.first = 1;
-
-    active = editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active;
-    if(active == 0)
-    {
-        editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active = 1;
-    }
-
-    tMenuEdit_set_on_off(editId, 1);
-
-    return UPDATE_DIVESETTINGS;
-}
-
-uint8_t OnAction_SP_DM_Select(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
-{
-    SDiveState * pDiveState = 0;
-
-    if(editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active == 0)
-        editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active = 1;
-
-    for(int i=0;i<NUM_GASES;i++)
-        editSetpointPage.pSetpointLine[i].note.ub.first = 0;
-
-    editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.first = 1;
-
-    if(actual_menu_content == MENU_DIVE_REAL)
-        pDiveState = stateRealGetPointerWrite();
-    else
-        pDiveState = stateSimGetPointerWrite();
-
-    setActualGas_DM(&pDiveState->lifeData, pDiveState->lifeData.actualGas.GasIdInSettings, editSetpointPage.pSetpointLine[editSetpointPage.spID].setpoint_cbar);
-
-    return EXIT_TO_HOME;
-}
-*/
--- a/Discovery/Src/tMenuEditXtra.c	Mon May 06 15:45:19 2019 +0200
+++ b/Discovery/Src/tMenuEditXtra.c	Mon Apr 29 19:43:05 2019 +0200
@@ -77,11 +77,7 @@
 
 void openEdit_SetManualMarker(void)
 {
-    if(stateUsed == stateRealGetPointer())
-        stateRealGetPointerWrite()->events.manualMarker = 1;
-    else
-        stateSimGetPointerWrite()->events.manualMarker = 1;
-
+    stateUsedWrite->events.manualMarker = 1;
     exitMenuEdit_to_Home();
 }