changeset 304:43b44f8d4fb0 cleanup-4

bugfix, simulator: fix the 1 sec difference between stopwatch and divetime This is a rather subtle bugfix. counterSecondsShallowDepth is used to decide to increase dive_time_seconds_without_surface_time. But just after using it, logic is present to reset counterSecondsShallowDepth. So, basically, we are looking to an old state. Simply increase dive_time_seconds_without_surface_time *after* we have reset counterSecondsShallowDepth, so that we are looking to a current state instead of an old one. Notice that this is simulator only. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Mon, 20 May 2019 13:06:02 +0200
parents 90e65971f15d
children 305f251cc981
files Discovery/Src/simulation.c
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Src/simulation.c	Mon May 20 12:57:31 2019 +0200
+++ b/Discovery/Src/simulation.c	Mon May 20 13:06:02 2019 +0200
@@ -159,11 +159,6 @@
     pDiveState->lifeData.dive_time_seconds += 1;
     pDiveState->lifeData.pressure_ambient_bar = sim_get_ambient_pressure(pDiveState);
 
-    if(!is_ambient_pressure_close_to_surface(&pDiveState->lifeData) && !(stateSimGetPointer()->lifeData.counterSecondsShallowDepth) )
-    {
-        pDiveState->lifeData.dive_time_seconds_without_surface_time += 1;
-    }
-
     if(is_ambient_pressure_close_to_surface(&pDiveState->lifeData)) // new hw 170214
     {
         if(!(stateSimGetPointer()->lifeData.counterSecondsShallowDepth))
@@ -185,6 +180,11 @@
         pDiveState->lifeData.counterSecondsShallowDepth = 0;
     }
 
+    if(!is_ambient_pressure_close_to_surface(&pDiveState->lifeData) && !(stateSimGetPointer()->lifeData.counterSecondsShallowDepth) )
+    {
+    	pDiveState->lifeData.dive_time_seconds_without_surface_time += 1;
+    }
+
     pDiveState->lifeData.depth_meter = (pDiveState->lifeData.pressure_ambient_bar - pDiveState->lifeData.pressure_surface_bar) * 10.0f;
     if(pDiveState->lifeData.max_depth_meter < pDiveState->lifeData.depth_meter)
             pDiveState->lifeData.max_depth_meter = pDiveState->lifeData.depth_meter;