# HG changeset patch
# User Ideenmodellierer
# Date 1676839922 -3600
# Node ID b392524753fba2cbcbb5b74cd16bc4655e5e4783
# Parent  dd5db6e2c9a4b2a98e29dbb6945a5c783cccd744
Update Sentinel protocol:
The Sentinel protocol is now supported by autodetection.
Added Autodetection indicator:
In the previous version no indicator showed that an auto detection is running. A new pseudo sensor type has been introduced which now causes the auto detection string to be displayed while the detection is running in the background.

diff -r dd5db6e2c9a4 -r b392524753fb Common/Inc/data_central.h
--- a/Common/Inc/data_central.h	Sun Feb 19 21:51:19 2023 +0100
+++ b/Common/Inc/data_central.h	Sun Feb 19 21:52:02 2023 +0100
@@ -424,13 +424,23 @@
 typedef enum
 {
 	 SENSOR_NONE,
+	 SENSOR_SEARCH,
 	 SENSOR_OPTIC,
 	 SENSOR_ANALOG,
 	 SENSOR_DIGO2,
+	 SENSOR_SENTINEL,
+	 SENSOR_TYPE_O2_END,
 	 SENSOR_CO2,
 	 SENSOR_END
 } externalInterfaceSensorType;
 
+#define DVO2_FATAL_INTENSITY_LOW	(0x00000001)
+#define DVO2_FATAL_AMBIENT_HIGH		(0x00000002)
+#define DVO2_FATAL_REFINT_LOW		(0x00000004)
+#define DVO2_FATAL_REFAMB_HIGH		(0x00000008)
+#define DVO2_FATAL_TEMPERATURE		(0x00000010)
+
+#define DVO2_FATAL_ERROR	(DVO2_FATAL_INTENSITY_LOW | DVO2_FATAL_AMBIENT_HIGH | DVO2_FATAL_REFINT_LOW | DVO2_FATAL_REFAMB_HIGH | DVO2_FATAL_TEMPERATURE)
 
 uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow);
 
diff -r dd5db6e2c9a4 -r b392524753fb Discovery/Inc/text_multilanguage.h
--- a/Discovery/Inc/text_multilanguage.h	Sun Feb 19 21:51:19 2023 +0100
+++ b/Discovery/Inc/text_multilanguage.h	Sun Feb 19 21:52:02 2023 +0100
@@ -284,6 +284,7 @@
 		TXT2BYTE_SetToMOD,
 		/* */
 		TXT2BYTE_HUDbattery,
+		TXT2BYTE_SensorDetect,
 		TXT2BYTE_O2Calib,
 		TXT2BYTE_O2Interface,
 		TXT2BYTE_O2IFOptic,
diff -r dd5db6e2c9a4 -r b392524753fb Discovery/Src/base.c
--- a/Discovery/Src/base.c	Sun Feb 19 21:51:19 2023 +0100
+++ b/Discovery/Src/base.c	Sun Feb 19 21:52:02 2023 +0100
@@ -730,9 +730,6 @@
 {
 	static uint32_t lastInput = 0;
 	uint8_t action = ButtonAction;
-	SStateList status;
-	SSettings* pSettings;
-	pSettings = settingsGetPointer();
 
 	if(action != ACTION_END)
 	{
diff -r dd5db6e2c9a4 -r b392524753fb Discovery/Src/tMenuEditHardware.c
--- a/Discovery/Src/tMenuEditHardware.c	Sun Feb 19 21:51:19 2023 +0100
+++ b/Discovery/Src/tMenuEditHardware.c	Sun Feb 19 21:52:02 2023 +0100
@@ -327,6 +327,8 @@
 											pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_DIGITAL;
 										}
 									break;
+					case SENSOR_SENTINEL:	pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_SENTINEL;
+									break;
 					default:
 									break;
 				}
@@ -336,20 +338,8 @@
 
 	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 */
 	{
-#if 0
-			if(get_globalState() == StMHARD3_O2_Source)
-			{
-				y_line = 5;
-			}
-#endif
 			haveSensorInfo = 1;
 		    openEdit_O2Sensors();
-#if 0
-		    if(y_line == 5)
-		    {
-		    	tMenuEdit_select(StMHARD3_O2_Source);
-		    }
-#endif
 	}
 	else
 	{
@@ -379,6 +369,8 @@
 
 			switch(pSettings->ext_sensor_map[index])
 			{
+				case SENSOR_SEARCH: strSensorId[4] = TXT2BYTE_SensorDetect;
+								break;
 				case SENSOR_OPTIC:	strSensorId[4] = TXT2BYTE_O2IFOptic;
 								break;
 				case SENSOR_ANALOG:	strSensorId[4] = TXT2BYTE_O2IFAnalog;
@@ -388,6 +380,9 @@
 				case SENSOR_CO2: strSensorId[3] = 'C';
 								 strSensorId[4] = 'O';
 								break;
+				case SENSOR_SENTINEL: strSensorId[3] = 'S';
+				 	 	 	 	 	  strSensorId[4] = 'e';
+				 	 	 	 	break;
 				default:
 					break;
 			}
@@ -396,7 +391,7 @@
 				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_DIGO2))
+			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]);
 			}
@@ -409,22 +404,8 @@
 			{
 				write_label_var(  480, 800, y_line, &FontT48, strSensorValue);
 			}
-
-#if 0
-			if(((pSettings->ext_sensor_map[index] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[index] > SENSOR_DIGO2)))
-			{
-				write_label_var(  96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, text);
-			}
-			if(pSettings->ext_sensor_map[index] == SENSOR_CO2)
-			{
-				write_label_var(  96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, "CO2");
-			}
-#endif
 		}
 
-
-
-
 		if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
 		{
 			strSensorId[0] = TXT_2BYTE;
@@ -437,7 +418,7 @@
 		}
 		else
 		{
-			if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG))
+			if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)|| (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL))
 			{
 				strSensorId[0] = TXT_2BYTE;
 				strSensorId[1] = TXT2BYTE_O2Calib;
@@ -448,47 +429,12 @@
 			}
 		}
 
-		write_label_var(  30, 340, ME_Y_LINE6, &FontT48, "Autodetect");
+		strSensorId[0] = TXT_2BYTE;
+		strSensorId[1] = TXT2BYTE_SensorDetect;
+		strSensorId[2] = 0;
 
-#if 0
-		if(DataEX_external_ADC_Present())
-		{
-			strSensorId[0] = TXT_2BYTE;
-			strSensorId[1] = TXT2BYTE_O2Interface;
-			strSensorId[2] = 0;
-			write_label_var(  30, 340, ME_Y_LINE5, &FontT48, strSensorId);
-			strSensorId[0] = TXT_2BYTE;
-			switch(pSettings->ppo2sensors_source)
-			{
-				default:
-				case O2_SENSOR_SOURCE_OPTIC: 	strSensorId[1] = TXT2BYTE_O2IFOptic;
-				strSensorId[2] = 0;
-					break;
-				case O2_SENSOR_SOURCE_ANALOG: 	strSensorId[1] = TXT2BYTE_O2IFAnalog;
-				strSensorId[2] = 0;
-					break;
-				case O2_SENSOR_SOURCE_DIGITAL: 	strSensorId[1] = TXT2BYTE_O2IFDigital;
-				strSensorId[2] = 0;
-					break;
-				case O2_SENSOR_SOURCE_ANADIG: 	//write_label_var(  30, 340, ME_Y_LINE6, &FontT48, "Autodetect");
-				strSensorId[1] = TXT2BYTE_O2IFAnalog;
-				strSensorId[2] = ' ';
-				strSensorId[3] = '+';
-				strSensorId[4] = ' ';
-				strSensorId[5] = TXT_2BYTE;
-				strSensorId[6] = TXT2BYTE_O2IFDigital;
-				strSensorId[7] = 0;
-					break;
-	#ifdef ENABLE_SENTINEL_MODE
-				case O2_SENSOR_SOURCE_SENTINEL: snprintf(text, 10,"Sentinel");
-					break;
-	#endif
-			}
-			write_label_var(  480, 800, ME_Y_LINE5, &FontT48, strSensorId);
+		write_label_var(  30, 340, ME_Y_LINE6, &FontT48, strSensorId);
 
-
-		}
-#endif
 		if(haveSensorInfo == 1)
 		{
 			strSensorId[0] = TXT_Sensor;
@@ -498,15 +444,15 @@
 			write_label_var(  30, 340, ME_Y_LINE5, &FontT48, strSensorId);
 		}
 
-		if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] <= SENSOR_DIGO2))
+		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_DIGO2))
+		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_DIGO2))
+		if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_TYPE_O2_END))
 		{
 			tMenuEdit_refresh_field(StMHARD3_O2_Sensor3);
 		}
@@ -527,6 +473,7 @@
 {
 	SSettings *pSettings = settingsGetPointer();
     uint8_t sensorActive[3];
+    uint8_t text[3];
 
     set_globalState(StMHARD3_Sensors);
 	resetMenuEdit(CLUT_MenuPageHardware);
@@ -535,7 +482,7 @@
     sensorActive[1] = 1;
     sensorActive[2] = 1;
 
-	if(((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] > SENSOR_DIGO2)))
+	if(((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] >= SENSOR_TYPE_O2_END)))
 	{
 		pSettings->ppo2sensors_deactivated |= 1;
 	}
@@ -543,7 +490,7 @@
 	{
 		write_field_on_off(StMHARD3_O2_Sensor1,	 30, 95, ME_Y_LINE1,  &FontT48, "", sensorActive[0]);
 	}
-	if(((pSettings->ext_sensor_map[1] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[1] > SENSOR_DIGO2)))
+	if(((pSettings->ext_sensor_map[1] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[1] >= SENSOR_TYPE_O2_END)))
 	{
 		pSettings->ppo2sensors_deactivated |= 2;
 	}
@@ -551,7 +498,7 @@
 	{
 		 write_field_on_off(StMHARD3_O2_Sensor2,	 30, 95, ME_Y_LINE2,  &FontT48, "", sensorActive[1]);
 	}
-	if(((pSettings->ext_sensor_map[2] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[2] > SENSOR_DIGO2)))
+	if(((pSettings->ext_sensor_map[2] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[2] >= SENSOR_TYPE_O2_END)))
 	{
 		pSettings->ppo2sensors_deactivated |= 4;
 	}
@@ -588,17 +535,23 @@
    		write_field_button(StMHARD3_Sensor_Info,	 30, 800, ME_Y_LINE5,  &FontT48, "");
    	}
 
-   	write_field_button(StMHARD3_Sensor_Detect,	 30, 800, ME_Y_LINE6,  &FontT48, "Autodetect");
+   	text[0] = TXT_2BYTE;
+   	text[1] = TXT2BYTE_SensorDetect;
+   	text[2] = 0;
 
-    if((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] > SENSOR_DIGO2))
+	write_label_var(  30, 340, ME_Y_LINE6, &FontT48, text);
+
+   	write_field_button(StMHARD3_Sensor_Detect,	 30, 800, ME_Y_LINE6,  &FontT48, text);
+
+    if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_TYPE_O2_END))
 	{
 			setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1);
 	}
-    if((pSettings->ext_sensor_map[1] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[1] > SENSOR_DIGO2))
+    if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_TYPE_O2_END))
 	{
 			setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2);
 	}
-    if((pSettings->ext_sensor_map[2] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[2] > SENSOR_DIGO2))
+    if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_TYPE_O2_END))
 	{
 			setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3);
 	}
@@ -736,47 +689,7 @@
 
 	return retVal;
 }
-#if 0
-uint8_t OnAction_O2_Source	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
-{
-    uint8_t source = settingsGetPointer()->ppo2sensors_source;
-    SSettings* pSettings = settingsGetPointer();
 
-    source++;
-    if(source == O2_SENSOR_SOURCE_MAX)
-    {
-    	source = O2_SENSOR_SOURCE_OPTIC;
-    }
-
-    switch(source)
-    {
-    	case O2_SENSOR_SOURCE_OPTIC:
-    	case O2_SENSOR_SOURCE_ANALOG:
-    	case O2_SENSOR_SOURCE_ANADIG:
-    											pSettings->ext_sensor_map[0] = SENSOR_ANALOG;
-    											pSettings->ext_sensor_map[1] = SENSOR_ANALOG;
-    											pSettings->ext_sensor_map[2] = SENSOR_ANALOG;
-
-    		break;
-    	case O2_SENSOR_SOURCE_DIGITAL:			pSettings->ext_sensor_map[0] = SENSOR_DIGO2;
-    											pSettings->ext_sensor_map[1] = SENSOR_NONE;
-    											pSettings->ext_sensor_map[2] = SENSOR_NONE;
-    		break;
-    	default:
-    		break;
-    }
-    pSettings->ext_sensor_map[3] = SENSOR_NONE;
-    pSettings->ext_sensor_map[4] = SENSOR_NONE;
-
-    pSettings->ppo2sensors_source = source;
-
-    DataEX_setExtInterface_Cmd(EXT_INTERFACE_COPY_SENSORMAP);
-
-    openEdit_O2Sensors();					/* rebuild menu structure (Hide HUD <=> Show Calibrate) */
-  //  tMenuEdit_select(StMHARD3_O2_Source);
-    return UPDATE_DIVESETTINGS;
-}
-#endif
 uint8_t OnAction_Sensor_Info(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
 	return EXIT_TO_INFO_SENSOR;
diff -r dd5db6e2c9a4 -r b392524753fb Discovery/Src/text_multilanguage.c
--- a/Discovery/Src/text_multilanguage.c	Sun Feb 19 21:51:19 2023 +0100
+++ b/Discovery/Src/text_multilanguage.c	Sun Feb 19 21:52:02 2023 +0100
@@ -1267,6 +1267,12 @@
 static uint8_t text_IT_HUDBattery[] = "Batteria HUD";
 static uint8_t text_ES_HUDBattery[] = "Carga del HUD";
 
+static uint8_t text_EN_SensorDetect[] = "Auto detection";
+static uint8_t text_DE_SensorDetect[] = "Sensor suchen";
+static uint8_t text_FR_SensorDetect[] = "";
+static uint8_t text_IT_SensorDetect[] = "";
+static uint8_t text_ES_SensorDetect[] = "";
+
 static uint8_t text_EN_O2Calib[] = "Calibrate";
 static uint8_t text_DE_O2Calib[] = "Kalibrierung";
 static uint8_t text_FR_O2Calib[] = "";
@@ -1968,6 +1974,7 @@
     {(uint8_t)TXT2BYTE_CornerStandard,  {text_EN_CornerStandard, text_DE_CornerStandard, text_FR_CornerStandard, text_IT_CornerStandard, text_ES_CornerStandard}},
     {(uint8_t)TXT2BYTE_SetToMOD,		{text_EN_SetToMOD, text_DE_SetToMOD, text_FR_SetToMOD, text_IT_SetToMOD, text_ES_SetToMOD}},
     {(uint8_t)TXT2BYTE_HUDbattery,		{text_EN_HUDBattery, text_DE_HUDBattery, text_FR_HUDBattery, text_IT_HUDBattery, text_ES_HUDBattery}},
+	{(uint8_t)TXT2BYTE_SensorDetect,	{text_EN_SensorDetect, text_DE_SensorDetect, text_FR_SensorDetect, text_IT_SensorDetect, text_ES_SensorDetect}},
 	{(uint8_t)TXT2BYTE_O2Calib,			{text_EN_O2Calib, text_DE_O2Calib, text_FR_O2Calib, text_IT_O2Calib, text_ES_O2Calib}},
 	{(uint8_t)TXT2BYTE_O2Interface,		{text_EN_O2Interface, text_DE_O2Interface, text_FR_O2Interface, text_IT_O2Interface, text_ES_O2Interface}},
 	{(uint8_t)TXT2BYTE_O2IFOptic,		{text_EN_O2IFOptic, text_DE_O2IFOptic, text_FR_O2IFOptic, text_IT_O2IFOptic, text_ES_O2IFOptic}},