changeset 783:c31237d20491

Update digital O2 sensor information: In the previous version only one digital O2 sensor was supported and the additional data could be accessed via a separate menu item. Because of the intraduction of the multiplexer there are three datasets available not. Because of the existing menu structure it was not possible to add additional menu items. To solve the problem the sensor information has been moved beghind the sensor On/Off functionality. When selecting a sensor the sensor data will be shown and the de-/activation of a sensor may be done in scope of the sensor information dialog.
author Ideenmodellierer
date Mon, 29 May 2023 20:26:38 +0200
parents 9a1bb9e7cb61
children 95af969fe0ae
files Discovery/Inc/tInfoSensor.h Discovery/Inc/tMenuEdit.h Discovery/Src/tInfoSensor.c Discovery/Src/tMenuEdit.c Discovery/Src/tMenuEditHardware.c
diffstat 5 files changed, 263 insertions(+), 162 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/tInfoSensor.h	Mon May 29 20:22:15 2023 +0200
+++ b/Discovery/Inc/tInfoSensor.h	Mon May 29 20:26:38 2023 +0200
@@ -29,7 +29,7 @@
 #define TINFO_SENSOR_H
 
 /* Exported functions --------------------------------------------------------*/
-void openInfo_Sensor(void);
+void openInfo_Sensor(uint8_t sensorId);
 void refreshInfo_Sensor(GFX_DrawCfgScreen s);
 void sendActionToInfoSensor(uint8_t sendAction);
 
--- a/Discovery/Inc/tMenuEdit.h	Mon May 29 20:22:15 2023 +0200
+++ b/Discovery/Inc/tMenuEdit.h	Mon May 29 20:26:38 2023 +0200
@@ -94,7 +94,7 @@
 
 void setBackMenu(uint32_t inputFunctionCall, uint8_t functionCallParameter, uint8_t gotoMenuEditField);
 void exitMenuEdit_to_BackMenu(void);
-
+void exitMenuEdit(uint8_t writeSettingsIfEnterPressed);
 void startEdit(void);
 void exitEditWithUpdate(void);
 void exitMenuEdit_to_Home(void);
--- a/Discovery/Src/tInfoSensor.c	Mon May 29 20:22:15 2023 +0200
+++ b/Discovery/Src/tInfoSensor.c	Mon May 29 20:26:38 2023 +0200
@@ -39,14 +39,49 @@
 #include <inttypes.h>
 
 extern void openEdit_O2Sensors(void);
+uint8_t OnAction_Sensor	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 
 /* Private variables ---------------------------------------------------------*/
-
+static uint8_t	activeSensorId = 0;
+static uint8_t sensorActive = 0;
 /* Exported functions --------------------------------------------------------*/
-void openInfo_Sensor(void)
+void openInfo_Sensor(uint8_t sensorId)
 {
+	SSettings *pSettings = settingsGetPointer();
+	activeSensorId = sensorId;
     set_globalState(StISENINFO);
-    setBackMenu((uint32_t)openEdit_O2Sensors,0,6);
+    switch (activeSensorId)
+    {
+    	case 3: setBackMenu((uint32_t)openEdit_O2Sensors,0,3);
+    		break;
+    	case 2: setBackMenu((uint32_t)openEdit_O2Sensors,0,2);
+    	    		break;
+    	default:
+    	case 1: setBackMenu((uint32_t)openEdit_O2Sensors,0,1);
+    	    		break;
+    }
+
+    sensorActive = 1;
+    if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId - 1)))
+    {
+    	sensorActive = 0;
+    }
+}
+
+
+uint8_t OnAction_Sensor(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+{
+	if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId - 1)))
+	{
+		settingsGetPointer()->ppo2sensors_deactivated &= ~(1 << (activeSensorId - 1));
+		tMenuEdit_set_on_off(editId, 1);
+	}
+	else
+	{
+		settingsGetPointer()->ppo2sensors_deactivated |= (1 << (activeSensorId - 1));
+		tMenuEdit_set_on_off(editId, 0);
+	}
+    return UPDATE_DIVESETTINGS;
 }
 
 
@@ -73,16 +108,45 @@
 	strcpy(pbuf,&tmpBuf[index+1]);
 }
 
-//  ===============================================================================
-//	refreshInfo_Compass
-/// @brief	there is only compass_DX_f, compass_DY_f, compass_DZ_f output during this mode
-///					the accel is not called during this process
+void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode)
+{
+    char localtext[32];
+
+    if(left2ByteCode)
+    {
+        localtext[0] = TXT_2BYTE;
+        localtext[1] = left2ByteCode;
+        localtext[2] = 0;
+        tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
+    }
+
+    if(middle2ByteCode)
+    {
+        localtext[0] = '\001';
+        localtext[1] = TXT_2BYTE;
+        localtext[2] = middle2ByteCode;
+        localtext[3] = 0;
+        tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
+    }
+
+    if(right2ByteCode)
+    {
+        localtext[0] = '\002';
+        localtext[1] = TXT_2BYTE;
+        localtext[2] = right2ByteCode;
+        localtext[3] = 0;
+        tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
+    }
+}
+
 //  ===============================================================================
 void refreshInfo_Sensor(GFX_DrawCfgScreen s)
 {
+	const SDiveState *pStateReal = stateRealGetPointer();
     SSensorDataDiveO2* pDiveO2Data;
     char text[31];
     uint8_t strIndex = 0;
+    char *textPointer = text;
 
     float pressure = 0.0;
 
@@ -90,11 +154,12 @@
 	text[1] = TXT_Sensor;
 	text[2] = ' ';
 	text[3] = TXT_Information;
-	text[4] = 0;
+	text[4] = ' ';
+	text[5] = '0' + activeSensorId;
+	text[6] = 0;
 	tInfo_write_content_simple(  30, 340, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware);
 
-
-    pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data;
+    pDiveO2Data = (SSensorDataDiveO2*)&stateRealGetPointer()->lifeData.extIf_sensor_data[activeSensorId-1];
 
     strIndex = snprintf(text,32,"ID: ");
     if(pDiveO2Data->sensorId != 0)
@@ -121,19 +186,49 @@
     snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0]));
     tInfo_write_content_simple(  30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
 #endif
+
+    if(sensorActive)
+    {
+    	*textPointer++ = '\005';
+    }
+    else
+    {
+    	*textPointer++ = '\006';
+    }
+    *textPointer++ = ' ';
+    *textPointer++ = TXT_2BYTE;
+    *textPointer++ = TXT2BYTE_Sensor;
+    *textPointer++ = ' ';
+    *textPointer++ = TXT_2BYTE;
+    *textPointer++ = TXT2BYTE_O2IFDigital;
+    *textPointer++ = '0' + activeSensorId;
+
+    snprintf(textPointer, 20,": %01.2f, %01.1f mV",  pStateReal->lifeData.ppO2Sensor_bar[activeSensorId - 1], pStateReal->lifeData.sensorVoltage_mV[activeSensorId - 1]);
+
+    tInfo_write_content_simple(  30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
+
+    tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0);
 }
 
 void sendActionToInfoSensor(uint8_t sendAction)
 {
-
     switch(sendAction)
     {
-
     	case ACTION_BUTTON_BACK:
     		exitMenuEdit_to_BackMenu();
     			break;
 
-    	case ACTION_BUTTON_ENTER:
+    	case ACTION_BUTTON_ENTER:    	if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId - 1)))
+										{
+    										settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId - 1));
+											sensorActive = 1;
+										}
+										else
+										{
+											settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId - 1));
+											sensorActive = 0;
+										}
+    		break;
 		case ACTION_BUTTON_NEXT:
 		case ACTION_TIMEOUT:
 		case ACTION_MODE_CHANGE:
--- a/Discovery/Src/tMenuEdit.c	Mon May 29 20:22:15 2023 +0200
+++ b/Discovery/Src/tMenuEdit.c	Mon May 29 20:26:38 2023 +0200
@@ -129,7 +129,6 @@
 
 void draw_tMEcursorNewDesign(void);
 
-void exitMenuEdit(uint8_t writeSettingsIfEnterPressed);
 uint8_t split_Content_to_Digit_helper(uint8_t inContentAscii, uint8_t *outDigit100, uint8_t *outDigit10, uint8_t *outDigit1);
 
 /* Exported functions --------------------------------------------------------*/
@@ -348,8 +347,19 @@
 
 void exitMenuEdit_to_InfoSensor(void)
 {
+	uint32_t globState = get_globalState();
+
     exitMenuEdit(1);
-    openInfo_Sensor();
+	switch(globState)
+	{
+	 	 case (StMHARD3_O2_Sensor3): openInfo_Sensor(3);
+			break;
+	 	 case (StMHARD3_O2_Sensor2): openInfo_Sensor(2);
+	 	 	 break;
+	 	 default:
+	 	 case (StMHARD3_O2_Sensor1): openInfo_Sensor(1);
+	 	 	 break;
+	}
 }
 
 
--- a/Discovery/Src/tMenuEditHardware.c	Mon May 29 20:22:15 2023 +0200
+++ b/Discovery/Src/tMenuEditHardware.c	Mon May 29 20:26:38 2023 +0200
@@ -28,6 +28,7 @@
 
 /* Includes ------------------------------------------------------------------*/
 #include "tMenuEditHardware.h"
+#include "tMenuEdit.h"
 
 #include "externCPU2bootloader.h"
 #include "gfx_fonts.h"
@@ -78,7 +79,6 @@
 #define O2_CALIB_FRACTION_O2	(0.98F)
 
 static uint8_t	O2_calib_gas = 21;
-static uint8_t haveSensorInfo = 0;
 
 void openEdit_Hardware(uint8_t line)
 {
@@ -426,39 +426,26 @@
 		openEdit_O2Sensors();
 	}
 
-	if((pStateReal->lifeData.extIf_sensor_Id != 0) && (haveSensorInfo == 0)) /* the sensor is detected after the interface has been selected => add button if info become available */
-	{
-			haveSensorInfo = 1;
-		    openEdit_O2Sensors();
-	}
-	else
-	{
-		if(pStateReal->lifeData.extIf_sensor_Id == 0)
-		{
-			haveSensorInfo = 0;
-		}
-
-		strSensorId[0] = '\001';
-		strSensorId[1] = TXT_o2Sensors;
-		strSensorId[2] = 0;
-		write_topline(strSensorId);
+	strSensorId[0] = '\001';
+	strSensorId[1] = TXT_o2Sensors;
+	strSensorId[2] = 0;
+	write_topline(strSensorId);
 
+	strSensorId[0] = TXT_2BYTE;
+	strSensorId[1] = TXT2BYTE_Sensor;
+	strSensorId[2] = ' ';
+	strSensorId[3] = TXT_2BYTE;
+	strSensorId[4] = 'X';
+	strSensorId[5] = '1';
+	strSensorId[6] = 0;
 
-		strSensorId[0] = TXT_2BYTE;
-		strSensorId[1] = TXT2BYTE_Sensor;
-		strSensorId[2] = ' ';
-		strSensorId[3] = TXT_2BYTE;
+	for(index = 0; index < 3; index++)
+	{
 		strSensorId[4] = 'X';
-		strSensorId[5] = '1';
-		strSensorId[6] = 0;
+		strSensorId[5] = '1' + index;
 
-		for(index = 0; index < 3; index++)
+		switch(pSettings->ext_sensor_map[index])
 		{
-			strSensorId[4] = 'X';
-			strSensorId[5] = '1' + index;
-
-			switch(pSettings->ext_sensor_map[index])
-			{
 				case SENSOR_SEARCH: strSensorId[1] = TXT2BYTE_SensorDetect;
 									strSensorId[2] = 0;
 									strSensorId[4] = 0;
@@ -478,84 +465,73 @@
 				default:
 									  strSensorId[5] = 0;
 					break;
-			}
-			if(strSensorId[4] != 'X')
-			{
-				write_label_var(  96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, strSensorId);
-			}
-			strSensorValue[0] = 0;
-			if((pSettings->ext_sensor_map[index] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[index] < SENSOR_TYPE_O2_END))
-			{
-				snprintf(strSensorValue, 20,"%01.2f, %01.1f mV",  pStateReal->lifeData.ppO2Sensor_bar[index], pStateReal->lifeData.sensorVoltage_mV[index]);
-			}
-			else if(pSettings->ext_sensor_map[index] == SENSOR_CO2)
-			{
-				snprintf(strSensorValue, 20,"%ld ppm",  pStateReal->lifeData.CO2_data.CO2_ppm);
-			}
-			y_line = ME_Y_LINE1 + (index * ME_Y_LINE_STEP);
-			if(strSensorValue[0] != 0)
-			{
-				write_label_var(  480, 800, y_line, &FontT48, strSensorValue);
-			}
+		}
+		if(strSensorId[4] != 'X')
+		{
+			write_label_var(  96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, strSensorId);
+		}
+		strSensorValue[0] = 0;
+		if((pSettings->ext_sensor_map[index] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[index] < SENSOR_TYPE_O2_END))
+		{
+			snprintf(strSensorValue, 20,"%01.2f, %01.1f mV",  pStateReal->lifeData.ppO2Sensor_bar[index], pStateReal->lifeData.sensorVoltage_mV[index]);
+		}
+		else if(pSettings->ext_sensor_map[index] == SENSOR_CO2)
+		{
+			snprintf(strSensorValue, 20,"%ld ppm",  pStateReal->lifeData.CO2_data.CO2_ppm);
 		}
-
-		if(pSettings->ext_sensor_map[0] == SENSOR_OPTIC)
+		y_line = ME_Y_LINE1 + (index * ME_Y_LINE_STEP);
+		if(strSensorValue[0] != 0)
 		{
-			strSensorId[0] = TXT_2BYTE;
-			strSensorId[1] = TXT2BYTE_HUDbattery;
-			strSensorId[2] = 0;
-			write_label_var(  30, 340, ME_Y_LINE4, &FontT48, strSensorId);
+			write_label_var(  480, 800, y_line, &FontT48, strSensorValue);
+		}
+	}
 
-			snprintf(strSensorId, 20,"%01.3fV", get_HUD_battery_voltage_V());
-			write_label_var(  480, 800, ME_Y_LINE4, &FontT48, strSensorId);
-		}
-		else
-		{
-			if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
+	if(pSettings->ext_sensor_map[0] == SENSOR_OPTIC)
+	{
+		strSensorId[0] = TXT_2BYTE;
+		strSensorId[1] = TXT2BYTE_HUDbattery;
+		strSensorId[2] = 0;
+		write_label_var(  30, 340, ME_Y_LINE4, &FontT48, strSensorId);
+
+		snprintf(strSensorId, 20,"%01.3fV", get_HUD_battery_voltage_V());
+		write_label_var(  480, 800, ME_Y_LINE4, &FontT48, strSensorId);
+	}
+	else
+	{
+		if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
 #ifdef ENABLE_SENTINEL_MODE
 					|| (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL)
 #endif
 					)
-			{
-				strSensorId[0] = TXT_2BYTE;
-				strSensorId[1] = TXT2BYTE_O2Calib;
-				strSensorId[2] = 0;
-				write_label_var(  30, 340, ME_Y_LINE4, &FontT48, strSensorId);
-				snprintf(strSensorId, 20,"%d%%", O2_calib_gas);
-				write_label_var(  480, 800, ME_Y_LINE4, &FontT48, strSensorId);
-			}
+		{
+			strSensorId[0] = TXT_2BYTE;
+			strSensorId[1] = TXT2BYTE_O2Calib;
+			strSensorId[2] = 0;
+			write_label_var(  30, 340, ME_Y_LINE4, &FontT48, strSensorId);
+			snprintf(strSensorId, 20,"%d%%", O2_calib_gas);
+			write_label_var(  480, 800, ME_Y_LINE4, &FontT48, strSensorId);
 		}
-
-	   	if(DataEX_external_ADC_Present())
-	   	{
-			strSensorId[0] = TXT_2BYTE;
-			strSensorId[1] = TXT2BYTE_SensorDetect;
-			strSensorId[2] = 0;
-
-			write_label_var(  30, 340, ME_Y_LINE6, &FontT48, strSensorId);
-	   	}
+	}
+   	if(DataEX_external_ADC_Present())
+   	{
+		strSensorId[0] = TXT_2BYTE;
+		strSensorId[1] = TXT2BYTE_SensorDetect;
+		strSensorId[2] = 0;
 
-		if(haveSensorInfo == 1)
-		{
-			strSensorId[0] = TXT_Sensor;
-			strSensorId[1] = ' ';
-			strSensorId[2] = TXT_Information;
-			strSensorId[3] = 0;
-			write_label_var(  30, 340, ME_Y_LINE5, &FontT48, strSensorId);
-		}
+		write_label_var(  30, 340, ME_Y_LINE6, &FontT48, strSensorId);
+   	}
 
-		if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_TYPE_O2_END))
-		{
-			tMenuEdit_refresh_field(StMHARD3_O2_Sensor1);
-		}
-		if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_TYPE_O2_END))
-		{
-			tMenuEdit_refresh_field(StMHARD3_O2_Sensor2);
-		}
-		if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_TYPE_O2_END))
-		{
-			tMenuEdit_refresh_field(StMHARD3_O2_Sensor3);
-		}
+	if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_TYPE_O2_END))
+	{
+		tMenuEdit_refresh_field(StMHARD3_O2_Sensor1);
+	}
+	if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_TYPE_O2_END))
+	{
+		tMenuEdit_refresh_field(StMHARD3_O2_Sensor2);
+	}
+	if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_TYPE_O2_END))
+	{
+		tMenuEdit_refresh_field(StMHARD3_O2_Sensor3);
 	}
 
     if(get_globalState() == StMHARD3_O2_Calibrate)
@@ -573,14 +549,23 @@
 {
 	SSettings *pSettings = settingsGetPointer();
     uint8_t sensorActive[3];
+    uint8_t index = 0;
     char text[3];
 
     set_globalState(StMHARD3_Sensors);
 	resetMenuEdit(CLUT_MenuPageHardware);
 
-    sensorActive[0] = 1;
-    sensorActive[1] = 1;
-    sensorActive[2] = 1;
+	for(index = 0; index < 3; index++ )
+	{
+		if(pSettings->ppo2sensors_deactivated & (0x01 << index))
+		{
+			sensorActive[index] = 0;
+		}
+		else
+		{
+			sensorActive[index] = 1;
+		}
+	}
 
 	if(((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] >= SENSOR_TYPE_O2_END)))
 	{
@@ -613,11 +598,6 @@
     if(settingsGetPointer()->ppo2sensors_deactivated & 4)
         sensorActive[2] = 0;
 
-    if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
-    {
-    	haveSensorInfo = 0;		/* as long as we do not move the HUD battery into the information page... */
-    }
-
     if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
 #ifdef ENABLE_SENTINEL_MODE
     		|| (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL)
@@ -630,11 +610,6 @@
         write_field_toggle(StMHARD3_O2_Calibrate,	400, 800, ME_Y_LINE4, &FontT48, "", 21, 98);
     }
 
-   	if(haveSensorInfo != 0)
-   	{
-   		write_field_button(StMHARD3_Sensor_Info,	 30, 800, ME_Y_LINE5,  &FontT48, "");
-   	}
-
    	if(DataEX_external_ADC_Present())
    	{
 		text[0] = TXT_2BYTE;
@@ -668,11 +643,6 @@
     	setEvent(StMHARD3_O2_Calibrate, (uint32_t)OnAction_O2_Calibrate);
     }
 
-  	if(haveSensorInfo != 0)
-   	{
-   		setEvent(StMHARD3_Sensor_Info, (uint32_t)OnAction_Sensor_Info);
-   	}
-
    	if(DataEX_external_ADC_Present())
    	{
    		setEvent(StMHARD3_Sensor_Detect, (uint32_t)OnAction_Sensor_Detect);
@@ -683,16 +653,25 @@
 
 uint8_t OnAction_Sensor1(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
-    if(settingsGetPointer()->ppo2sensors_deactivated & 1)
-    {
-        settingsGetPointer()->ppo2sensors_deactivated &= 4+2;
-        tMenuEdit_set_on_off(editId, 1);
-    }
-    else
-    {
-        settingsGetPointer()->ppo2sensors_deactivated |= 1;
-        tMenuEdit_set_on_off(editId, 0);
-    }
+	const SDiveState *pStateReal = stateRealGetPointer();
+
+	if(pStateReal->lifeData.extIf_sensor_map[0] == SENSOR_DIGO2)
+	{
+		return EXIT_TO_INFO_SENSOR;
+	}
+	else
+	{
+		if(settingsGetPointer()->ppo2sensors_deactivated & 1)
+		{
+			settingsGetPointer()->ppo2sensors_deactivated &= 4+2;
+			tMenuEdit_set_on_off(editId, 1);
+		}
+		else
+		{
+			settingsGetPointer()->ppo2sensors_deactivated |= 1;
+			tMenuEdit_set_on_off(editId, 0);
+		}
+	}
 
     return UPDATE_DIVESETTINGS;
 }
@@ -700,34 +679,51 @@
 
 uint8_t OnAction_Sensor2(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
-    if(settingsGetPointer()->ppo2sensors_deactivated & 2)
-    {
-        settingsGetPointer()->ppo2sensors_deactivated &= 4+1;
-        tMenuEdit_set_on_off(editId, 1);
-    }
-    else
-    {
-        settingsGetPointer()->ppo2sensors_deactivated |= 2;
-        tMenuEdit_set_on_off(editId, 0);
-    }
+	const SDiveState *pStateReal = stateRealGetPointer();
 
+	if(pStateReal->lifeData.extIf_sensor_map[1] == SENSOR_DIGO2)
+	{
+		return EXIT_TO_INFO_SENSOR;
+	}
+	else
+	{
+		if(settingsGetPointer()->ppo2sensors_deactivated & 2)
+		{
+			settingsGetPointer()->ppo2sensors_deactivated &= 4+1;
+			tMenuEdit_set_on_off(editId, 1);
+		}
+		else
+		{
+			settingsGetPointer()->ppo2sensors_deactivated |= 2;
+			tMenuEdit_set_on_off(editId, 0);
+		}
+	}
     return UPDATE_DIVESETTINGS;
 }
 
 
 uint8_t OnAction_Sensor3(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
-    if(settingsGetPointer()->ppo2sensors_deactivated & 4)
-    {
-        settingsGetPointer()->ppo2sensors_deactivated &= 2+1;
-        tMenuEdit_set_on_off(editId, 1);
-    }
-    else
-    {
-        settingsGetPointer()->ppo2sensors_deactivated |= 4;
-        tMenuEdit_set_on_off(editId, 0);
-    }
+	const SDiveState *pStateReal = stateRealGetPointer();
+
+	if(pStateReal->lifeData.extIf_sensor_map[2] == SENSOR_DIGO2)
+	{
+		return EXIT_TO_INFO_SENSOR;
+	}
+	else
+	{
 
+		if(settingsGetPointer()->ppo2sensors_deactivated & 4)
+		{
+			settingsGetPointer()->ppo2sensors_deactivated &= 2+1;
+			tMenuEdit_set_on_off(editId, 1);
+		}
+		else
+		{
+			settingsGetPointer()->ppo2sensors_deactivated |= 4;
+			tMenuEdit_set_on_off(editId, 0);
+		}
+	}
     return UPDATE_DIVESETTINGS;
 }