# HG changeset patch # User Jan Mulder # Date 1558682969 -7200 # Node ID b0045281cb2dec7b5a37b54353323337cd713119 # Parent 1203255481e4a8c71eda914ba75292fa4342eee2 cleanup: factor out SHelper typedef (and more) It is totally useless to carry some data around in the SLifeData global data, that is never used in a significant way. All data in the SHelper typedef can trivially be changed to static data in the new setAvgDepth code. Further, cleanup the setAvgDepth code. Reset to 0 instead of 1, adapt the references to the new local and static data instead of pointers to the external data. Signed-off-by: Jan Mulder diff -r 1203255481e4 -r b0045281cb2d Common/Inc/data_central.h --- a/Common/Inc/data_central.h Fri May 24 09:02:46 2019 +0200 +++ b/Common/Inc/data_central.h Fri May 24 09:29:29 2019 +0200 @@ -152,12 +152,6 @@ } SDeviceState; */ -typedef struct -{ - uint32_t average_depth_meter_Count; - uint32_t average_depth_last_update_dive_time_seconds_without_surface_time; -} SHelper; - /* struct SLifeData * contains data all actual data (pressure, stuturation, etc. as received from second ship * and has actualGas to be send to Small CPU (second chip) @@ -227,10 +221,6 @@ float ppO2Sensor_bar[3]; float sensorVoltage_mV[3]; float HUD_battery_voltage_V; - - /* used by DataEX_copy_to_LifeData() - */ - SHelper internal; } SLifeData; diff -r 1203255481e4 -r b0045281cb2d Discovery/Src/data_exchange_main.c --- a/Discovery/Src/data_exchange_main.c Fri May 24 09:02:46 2019 +0200 +++ b/Discovery/Src/data_exchange_main.c Fri May 24 09:29:29 2019 +0200 @@ -1001,30 +1001,30 @@ 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; + static uint32_t AvgDepthCount = 0; + static uint32_t AvgDepthTimer = 0; uint32_t AvgSecondsSinceLast; uint32_t DiveTime = pStateReal->lifeData.dive_time_seconds_without_surface_time; if(pStateReal->lifeData.boolResetAverageDepth) { *AvgDepthValue = DepthNow; - *AvgDepthCount = 1; - *AvgDepthTimer = DiveTime; + AvgDepthCount = 0; + AvgDepthTimer = DiveTime; pStateReal->lifeData.boolResetAverageDepth = 0; } - else if (DiveTime > *AvgDepthTimer) + else if (DiveTime > AvgDepthTimer) { - AvgSecondsSinceLast = DiveTime - *AvgDepthTimer; + AvgSecondsSinceLast = DiveTime - AvgDepthTimer; for(int i=0;i