diff Discovery/Src/data_exchange_main.c @ 308:1203255481e4 cleanup-4

cleanup: introduce function setAvgDepth The simulator and the realtime code shared a literally identical piece of code to compute a running depth average. This is simply poor coding style, so factor this out and create a function to do this work. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Fri, 24 May 2019 09:02:46 +0200
parents b6436edfb2c0
children b0045281cb2d
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c	Wed May 22 22:22:15 2019 +0200
+++ b/Discovery/Src/data_exchange_main.c	Fri May 24 09:02:46 2019 +0200
@@ -994,15 +994,18 @@
 		}
 	}
 
-	/* average depth 
-	 */
+	setAvgDepth(pStateReal);
+}
+
+void setAvgDepth(SDiveState *pStateReal) {
+
 	float *AvgDepthValue = &pStateReal->lifeData.average_depth_meter;
 	float	DepthNow = pStateReal->lifeData.depth_meter; 
 	uint32_t *AvgDepthCount = &pStateReal->lifeData.internal.average_depth_meter_Count;
 	uint32_t *AvgDepthTimer = &pStateReal->lifeData.internal.average_depth_last_update_dive_time_seconds_without_surface_time;
 	uint32_t AvgSecondsSinceLast;
 	uint32_t DiveTime = pStateReal->lifeData.dive_time_seconds_without_surface_time;
-	
+
 	if(pStateReal->lifeData.boolResetAverageDepth)
 	{
 		*AvgDepthValue = DepthNow;