diff Discovery/Src/check_warning.c @ 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 b456be1e152d
children 29d9b5bc7946
line wrap: on
line diff
--- 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;