diff Discovery/Src/buehlmann.c @ 226:2ae6440cb8d6

Merged in janlmulder/ostc4/div-fixes-3 (pull request #13) 3 bug fixes and some cleanup.
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Mon, 01 Apr 2019 19:19:04 +0000
parents ceecabfddb57
children ff0d23625cd5
line wrap: on
line diff
--- a/Discovery/Src/buehlmann.c	Mon Apr 01 09:01:09 2019 +0000
+++ b/Discovery/Src/buehlmann.c	Mon Apr 01 19:19:04 2019 +0000
@@ -16,9 +16,6 @@
 #include "decom.h"
 
 
-extern  const float helium_time_constant[16];
-extern  const float nitrogen_time_constant[16];
-
 extern const float buehlmann_N2_a[];
 extern const float buehlmann_N2_b[];
 extern const float buehlmann_He_a[];
@@ -727,18 +724,17 @@
 	float gf_low;
 	float gf_high;
 	float gf_delta;
-	int dv_gf_low_stop_meter;
+	float dv_gf_low_stop_meter;
 	_Bool test_result;
 	float next_gf_value;
 	float next_pressure_absolute;
-	int depth_in_meter;
+	float depth_in_meter;
 	
 	gf_low = pDiveSettings->gf_low;
 	gf_high = pDiveSettings->gf_high;
 
-	//
 	dv_gf_low_stop_meter = (int)((pDiveSettings->internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero - pLifeData->pressure_surface_bar) * 10);
-	//
+
 	if(dv_gf_low_stop_meter < 1)
 	{
 		next_gf_value = gf_high; // fix hw 161024
@@ -748,9 +744,9 @@
 	{
 		next_gf_value = gf_high;
 		gf_delta = gf_high - gf_low;
-		gf_delta /= dv_gf_low_stop_meter; // gf_delta is delta for each meter now!!
+		gf_delta /= (dv_gf_low_stop_meter * 10); // gf_delta is delta for 10 cm !!
 	}
-	//
+
 	depth_in_meter = 0;
 	next_pressure_absolute = pLifeData->pressure_surface_bar;
 
@@ -762,19 +758,18 @@
 	//
 	while(!test_result && depth_in_meter < 200)
 	{
-		depth_in_meter += 1;
+		depth_in_meter += 0.1;
 		next_gf_value = fmaxf(gf_low, next_gf_value - gf_delta);
 		gGF_value = next_gf_value / 100.0f;
-		next_pressure_absolute += 0.1f; // 1 meter down
+		next_pressure_absolute += 0.01f; // 0.1 meter down
 		test_result = buehlmann_tissue_test_tolerance(next_pressure_absolute);
 	}
-	//
+
 	if(test_result)
 	{
-		// old direct paste
 		pDecoInfo->output_ceiling_meter = depth_in_meter;
-		// new sub-meter hw 160331
-		if(depth_in_meter >= 1)
+
+		if(depth_in_meter >= 0)
 		{
 			for(int i = 0; i < 10; i++)
 			{