# HG changeset patch
# User Jan Mulder <jlmulder@xs4all.nl>
# Date 1558858162 -7200
# Node ID 95928ef3986f379effc72a6120d938299b86504b
# Parent  b0045281cb2dec7b5a37b54353323337cd713119
Make dive mode detection more advanced

In commit a09b1855d656, a RTE function was factored out, that was
used to detect dive mode vs. surface mode.

In the hunt for the time difference bug between stopwatch and dive time
some progress was made, but its still not totally right. Add some old
logic back, that seems reasonable.

A pool test after this commit shows some improvement, but still there
is some random difference between stopwatch and dive time. Things like
perfectly in sync for 20 min. surface shortly, and descend again in
the same dive. Now, the was a 1 or 2 second difference.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>

diff -r b0045281cb2d -r 95928ef3986f Discovery/Src/data_central.c
--- a/Discovery/Src/data_central.c	Fri May 24 09:29:29 2019 +0200
+++ b/Discovery/Src/data_central.c	Sun May 26 10:09:22 2019 +0200
@@ -763,7 +763,9 @@
 // This code is also in RTE. Keep it in sync when editing
 _Bool is_ambient_pressure_close_to_surface(SLifeData *lifeData)
 {
-	if(lifeData->pressure_ambient_bar < (lifeData->pressure_surface_bar + 0.1f))
+	if (lifeData->pressure_ambient_bar > 1.16)
+		return false;
+	else if(lifeData->pressure_ambient_bar < (lifeData->pressure_surface_bar + 0.1f))
 		return true;
 	else
 		return false;
diff -r b0045281cb2d -r 95928ef3986f Small_CPU/Src/scheduler.c
--- a/Small_CPU/Src/scheduler.c	Fri May 24 09:29:29 2019 +0200
+++ b/Small_CPU/Src/scheduler.c	Sun May 26 10:09:22 2019 +0200
@@ -1560,9 +1560,11 @@
 }
 
 /* same as in data_central.c */
-_Bool is_ambient_pressure_close_to_surface(SLifeData *lifeDataCall)
+_Bool is_ambient_pressure_close_to_surface(SLifeData *lifeData)
 {
-	if(lifeDataCall->pressure_ambient_bar < (lifeDataCall->pressure_surface_bar + 0.1f)) // hw 161121 now 1 mter, before 0.04f
+	if (lifeData->pressure_ambient_bar > 1.16)
+		return false;
+	else if(lifeData->pressure_ambient_bar < (lifeData->pressure_surface_bar + 0.1f)) // hw 161121 now 1 mter, before 0.04f
 		return true;
 	else
 		return false;