changeset 756:6de83d8205a0

Added visualization of CO2 during dive: In the previous version CO2 values were available in sufrace mode only. Now the display of Co2 value has been added to the lower left corner view. In addition a Co2 alarm has been added. Early Co2 warning vaues will be displayed in yellow while critical values are shown in red.
author Ideenmodellierer
date Tue, 07 Mar 2023 20:02:05 +0100
parents 92bf7bf9fb8a
children 39ff186b6f98
files Common/Inc/data_exchange.h Discovery/Inc/text_multilanguage.h Discovery/Src/check_warning.c Discovery/Src/t7.c Discovery/Src/text_multilanguage.c
diffstat 5 files changed, 54 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Common/Inc/data_exchange.h	Tue Mar 07 19:59:02 2023 +0100
+++ b/Common/Inc/data_exchange.h	Tue Mar 07 20:02:05 2023 +0100
@@ -54,6 +54,9 @@
 
 #define EXTIF_SENSOR_INFO_SIZE		(32u)		/* size of data array reserved for extended sensor data from external interface */
 
+#define CO2_WARNING_LEVEL_PPM		(2000u)	    /* Early warning to indicate unexpected high co2 concentration (yellow) */
+#define CO2_ALARM_LEVEL_PPM			(5000u)		/* starting by this level CO2 has a negative impact on health (long exposure) */
+
 enum MODE
 {
 	MODE_SURFACE	= 0,
--- a/Discovery/Inc/text_multilanguage.h	Tue Mar 07 19:59:02 2023 +0100
+++ b/Discovery/Inc/text_multilanguage.h	Tue Mar 07 20:02:05 2023 +0100
@@ -221,6 +221,7 @@
 		TXT2BYTE_WarnSensorLinkLost,
 		TXT2BYTE_WarnFallback,
 		TXT2BYTE_WarnCnsHigh,
+		TXT2BYTE_WarnCO2High,
 		/* */
 		TXT2BYTE_O2monitor,
 		TXT2BYTE_O2voltage,
--- a/Discovery/Src/check_warning.c	Tue Mar 07 19:59:02 2023 +0100
+++ b/Discovery/Src/check_warning.c	Tue Mar 07 20:02:05 2023 +0100
@@ -41,6 +41,7 @@
 
 #define DEBOUNCE_FALLBACK_TIME_MS	(5000u)		/* set warning after 5 seconds of pending error condition */
 
+
 /* Private variables with access ----------------------------------------------*/
 static uint8_t betterGasId = 0;
 static uint8_t betterSetpointId = 0;
@@ -61,6 +62,9 @@
 #ifdef ENABLE_BOTTLE_SENSOR
 static int8_t check_pressureSensor(SDiveState * pDiveState);
 #endif
+#ifdef ENABLE_CO2_SUPPORT
+static int8_t check_co2(SDiveState * pDiveState);
+#endif
 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2);
 
 /* Exported functions --------------------------------------------------------*/
@@ -88,6 +92,9 @@
 #ifdef ENABLE_BOTTLE_SENSOR
 	pDiveState->warnings.numWarnings += check_pressureSensor(pDiveState);
 #endif
+#ifdef ENABLE_CO2_SUPPORT
+	pDiveState->warnings.numWarnings += check_co2(pDiveState);
+#endif
 }
 
 
@@ -433,6 +440,28 @@
 }
 #endif
 
+#ifdef ENABLE_CO2_SUPPORT
+static int8_t check_co2(SDiveState * pDiveState)
+{
+	if(pDiveState->mode != MODE_DIVE)
+	{
+		pDiveState->warnings.co2High = 0;
+	}
+	else
+	{
+		if(pDiveState->lifeData.CO2_data.CO2_ppm > CO2_ALARM_LEVEL_PPM)
+		{
+			pDiveState->warnings.co2High = 1;
+		}
+		else
+		{
+			pDiveState->warnings.co2High = 0;
+		}
+	}
+	return pDiveState->warnings.co2High;
+}
+#endif
+
 uint8_t debounce_warning_fallback(uint16_t debounceStepms)
 {
 	uint8_t retVal = 0;
--- a/Discovery/Src/t7.c	Tue Mar 07 19:59:02 2023 +0100
+++ b/Discovery/Src/t7.c	Tue Mar 07 20:02:05 2023 +0100
@@ -1412,6 +1412,7 @@
     //count += stateUsed->warnings.lowBattery;
     count += stateUsed->warnings.sensorLinkLost;
     count += stateUsed->warnings.fallback;
+    count += stateUsed->warnings.co2High;
 #ifdef ENABLE_BOTTLE_SENSOR
     if(stateUsed->warnings.newPressure)
     {
@@ -1563,6 +1564,18 @@
         lineFree--;
     }
 #endif
+#ifdef ENABLE_CO2_SUPPORT
+    if(lineFree && stateUsed->warnings.co2High)
+    {
+    	text[textpointer++] = '\001';
+        text[textpointer++] = TXT_2BYTE;
+        text[textpointer++] = TXT2BYTE_WarnCO2High;
+        text[textpointer++] = '\n';
+        text[textpointer++] = '\r';
+        text[textpointer] = 0;
+        lineFree--;
+    }
+#endif
 /*
     if(lineFree && stateUsed->warnings.lowBattery)
     {
--- a/Discovery/Src/text_multilanguage.c	Tue Mar 07 19:59:02 2023 +0100
+++ b/Discovery/Src/text_multilanguage.c	Tue Mar 07 20:02:05 2023 +0100
@@ -972,6 +972,13 @@
 static uint8_t text_IT_WarnCnsHigh[] = "CNS alto";
 static uint8_t text_ES_WarnCnsHigh[] = "CNS alto";
 
+// Warning
+static uint8_t text_EN_WarnCO2High[] = "CO2 high";
+static uint8_t text_DE_WarnCO2High[] = "CO2 hoch";
+static uint8_t text_FR_WarnCO2High[] = "CO2 haut";
+static uint8_t text_IT_WarnCO2High[] = "CO2 alto";
+static uint8_t text_ES_WarnCO2High[] = "CO2 alto";
+
 // Tissue Graph
 static uint8_t text_EN_Nitrogen[] = "Nitrogen";
 static uint8_t text_DE_Nitrogen[] = "Stickstoff";
@@ -1921,6 +1928,7 @@
     {(uint8_t)TXT2BYTE_WarnSensorLinkLost,{text_EN_WarnSensorLinkLost, text_DE_WarnSensorLinkLost, text_FR_WarnSensorLinkLost, text_IT_WarnSensorLinkLost, text_ES_WarnSensorLinkLost}},
     {(uint8_t)TXT2BYTE_WarnFallback,	{text_EN_WarnFallback, text_DE_WarnFallback, text_FR_WarnFallback, text_IT_WarnFallback, text_ES_WarnFallback}},
     {(uint8_t)TXT2BYTE_WarnCnsHigh,		{text_EN_WarnCnsHigh, text_DE_WarnCnsHigh, text_FR_WarnCnsHigh, text_IT_WarnCnsHigh, text_ES_WarnCnsHigh}},
+    {(uint8_t)TXT2BYTE_WarnCO2High,		{text_EN_WarnCO2High, text_DE_WarnCO2High, text_FR_WarnCO2High, text_IT_WarnCO2High, text_ES_WarnCO2High}},
     {(uint8_t)TXT2BYTE_O2monitor,		{text_EN_O2monitor, text_DE_O2monitor, text_FR_O2monitor, text_IT_O2monitor, text_ES_O2monitor}},
     {(uint8_t)TXT2BYTE_O2voltage,		{text_EN_O2voltage, text_DE_O2voltage, text_FR_O2voltage, text_IT_O2voltage, text_ES_O2voltage}},
     {(uint8_t)TXT2BYTE_Tissues,			{text_EN_Tissues, text_DE_Tissues, text_FR_Tissues, text_IT_Tissues, text_ES_Tissues}},