diff Small_CPU/Src/pressure.c @ 696:cc542448fb28

Merge
author heinrichsweikamp
date Fri, 19 Aug 2022 11:30:24 +0200
parents 8c92f7743e14
children 2ace67231c49
line wrap: on
line diff
--- a/Small_CPU/Src/pressure.c	Mon Nov 01 12:39:34 2021 +0100
+++ b/Small_CPU/Src/pressure.c	Fri Aug 19 11:30:24 2022 +0200
@@ -49,8 +49,12 @@
 /* remove comment to use a predefined profile for pressure changes instead of real world data */
 /* #define SIMULATE_PRESSURE */
 
+
 #define PRESSURE_SURFACE_MAX_MBAR			(1060.0f)		/* It is unlikely that pressure at surface is greater than this value => clip to it */
 
+#define PRESSURE_MINIMUM					(0.0f)
+#define TEMPERATURE_MINIMUM					(-100.0f)
+
 #define PRESSURE_SURFACE_QUE					(30u)			/* history buffer [minutes] for past pressure measurements */
 #define PRESSURE_SURFACE_EVA_WINDOW				(15u)			/* Number of entries evaluated during instability test. Used to avoid detection while dive enters water */
 #define PRESSURE_SURFACE_STABLE_LIMIT			(10u)			/* Define pressure as stable if delta (mBar) is below this value */
@@ -664,6 +668,11 @@
 	ambient_temperature = ((float)local_Tx100) / 100;
 	ambient_temperature	+= temperature_offset;
 
+	if(ambient_temperature < TEMPERATURE_MINIMUM)
+	{
+		ambient_temperature = 20.0;
+	}
+
 	calc_pressure = ((float)local_Px10) / 10;
 	calc_pressure += pressure_offset;
 
@@ -673,6 +682,11 @@
 		avgCnt++;		/* by the measurement range of the sensor which is focused on under water pressure measurement */
 	}
 	ambient_pressure_mbar = runningAvg;
+
+	if(ambient_pressure_mbar < PRESSURE_MINIMUM)
+	{
+		ambient_pressure_mbar = 1000.0;
+	}
 }