changeset 301:a09b1855d656 cleanup-4

cleanup, RTE: factor out scheduleCheck_pressure_reached_dive_mode_level The detection of the start of dive mode is conceptually simple (when the pressure sensor reaches a certain threshold, we are diving). This said, there are multiple implementations over the entire code base to answer the question: are we diving? This commit factors out scheduleCheck_pressure_reached_dive_mode_level used only in the RTE, in favor of is_ambient_pressure_close_to_surface, which is used in both RTE and CPU1 firmware. I had a little hope that is would fix the 1 second difference between the initial stopwatch and the divetime, but it does not. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Mon, 20 May 2019 10:05:27 +0200
parents 5ca177d2df5d
children eba8d1eb5bef
files Small_CPU/Src/scheduler.c
diffstat 1 files changed, 2 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/Small_CPU/Src/scheduler.c	Fri May 17 21:19:04 2019 +0200
+++ b/Small_CPU/Src/scheduler.c	Mon May 20 10:05:27 2019 +0200
@@ -85,7 +85,6 @@
 static void schedule_update_timer_helper(int8_t thisSeconds);
 uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow);
 
-_Bool scheduleCheck_pressure_reached_dive_mode_level(void);
 void scheduleSetDate(SDeviceLine *line);
 
 /* Exported functions --------------------------------------------------------*/
@@ -771,7 +770,7 @@
 				copyPressureData();
 				Scheduler.counterPressure100msec++;
 				
-				if(scheduleCheck_pressure_reached_dive_mode_level())
+				if (!is_ambient_pressure_close_to_surface(&global.lifeData))
 					global.mode = MODE_DIVE;
 		}
 		
@@ -1029,7 +1028,7 @@
 			}
 		}
 
-		if(scheduleCheck_pressure_reached_dive_mode_level())
+		if (!is_ambient_pressure_close_to_surface(&global.lifeData))
 			global.mode = MODE_BOOT;
 
 		scheduleUpdateLifeData(2000);
@@ -1046,27 +1045,6 @@
 
 /* Private functions ---------------------------------------------------------*/
 
-
-/**
-  ******************************************************************************
-	* @brief   scheduleCheck_pressure_reached_dive_mode_level
-  * @author  heinrichs weikamp gmbh
-  * @version V0.0.1 from inline code
-  * @date    09-Sept-2015
-  ******************************************************************************
-  */
-_Bool scheduleCheck_pressure_reached_dive_mode_level(void)
-{
-		if(get_pressure_mbar() > 1160)
-			return 1;
-		else
-		if((global.mode == MODE_SURFACE) && (get_pressure_mbar() > (get_surface_mbar() + 100)) && (get_surface_mbar() > 880))
-			return 1;
-		else
-			return 0;
-}
-		
-
 /**
   ******************************************************************************
 	* @brief   scheduleUpdateLifeData / calculates tissues