diff Discovery/Src/data_exchange_main.c @ 577:9bb9a52d6ae5

Handle o2 voltage values < 0.5mV as invalid: Values < 0.5mv will now be handled as ppo2 = 0Bar to avaid problems (e.g. by negativ values) in the decompression calculation. In the custom display sensors with low voltage are show using '-'
author Ideenmodellierer
date Sun, 29 Nov 2020 22:58:11 +0100
parents 84a4e1200726
children 830de438e0b0
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c	Sun Nov 29 22:55:31 2020 +0100
+++ b/Discovery/Src/data_exchange_main.c	Sun Nov 29 22:58:11 2020 +0100
@@ -102,6 +102,8 @@
 #define UNKNOWN_DATE_MONTH		1
 #define UNKNOWN_DATE_YEAR		16
 
+#define IGNORE_O2_VOLTAGE_LEVEL_MV	(0.5f)
+
 /* Private function prototypes -----------------------------------------------*/
 static uint8_t DataEX_check_header_and_footer_ok(void);
 static uint8_t DataEX_check_header_and_footer_shifted(void);
@@ -774,7 +776,7 @@
 {
 	SDiveState *pStateReal = stateRealGetPointerWrite();
 	static uint16_t getDeviceDataAfterStartOfMainCPU = 20;
-	
+	uint8_t idx;
 	
 	// wireless - �ltere daten aufr�umen
 #if 0
@@ -880,12 +882,20 @@
 	{
 		if(pStateReal->data_old__lost_connection_to_slave == 0)
 		{
-			pStateReal->lifeData.sensorVoltage_mV[0] = dataIn.data[0].extADC_voltage[0];
-			pStateReal->lifeData.sensorVoltage_mV[1] = dataIn.data[0].extADC_voltage[1];
-			pStateReal->lifeData.sensorVoltage_mV[2] = dataIn.data[0].extADC_voltage[2];
-			pStateReal->lifeData.ppO2Sensor_bar[0] = pStateReal->lifeData.sensorVoltage_mV[0] * pSettings->ppo2sensors_calibCoeff[0];
-			pStateReal->lifeData.ppO2Sensor_bar[1] = pStateReal->lifeData.sensorVoltage_mV[1] * pSettings->ppo2sensors_calibCoeff[1];
-			pStateReal->lifeData.ppO2Sensor_bar[2] = pStateReal->lifeData.sensorVoltage_mV[2] * pSettings->ppo2sensors_calibCoeff[2];
+			for(idx = 0; idx < 3; idx++)
+			{
+				pStateReal->lifeData.sensorVoltage_mV[idx] = dataIn.data[0].extADC_voltage[idx];
+				if(pStateReal->lifeData.sensorVoltage_mV[idx] < IGNORE_O2_VOLTAGE_LEVEL_MV)
+				{
+					pStateReal->lifeData.sensorVoltage_mV[idx] = 0.0;
+					pStateReal->lifeData.ppO2Sensor_bar[idx] = 0;
+				}
+				else
+				{
+					pStateReal->lifeData.ppO2Sensor_bar[idx] = pStateReal->lifeData.sensorVoltage_mV[idx] * pSettings->ppo2sensors_calibCoeff[idx];
+				}
+
+			}
 		}
 	}