Mercurial > public > ostc4
diff Discovery/Src/data_exchange_main.c @ 202:d328abe2e44e
Merged heinrichsweikamp/ostc4 into default
author | Thorsten <ideenmodellierer@o2mail.de> |
---|---|
date | Sun, 17 Mar 2019 19:16:59 +0100 |
parents | 8b8074080d7b |
children | c853f5d23bb7 |
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c Sat Mar 16 19:58:52 2019 +0000 +++ b/Discovery/Src/data_exchange_main.c Sun Mar 17 19:16:59 2019 +0100 @@ -771,6 +771,20 @@ return (depth[0] + depth[1] + depth[2] + depth[3])/4.0f; } +#define TEMP_AVERAGE_COUNT 3 +static float getTemperature(SDataExchangeSlaveToMaster *d) +{ + static uint8_t c = 0; + static float temp[TEMP_AVERAGE_COUNT] = {0}; + + temp[c] = d->data[d->boolPressureData].temperature; + + c++; + if (c == TEMP_AVERAGE_COUNT) c = 0; + + return (temp[0] + temp[1] + temp[2])/3.0f; +} + void DataEX_copy_to_LifeData(_Bool *modeChangeFlag) { SDiveState *pStateReal = stateRealGetPointerWrite(); @@ -937,7 +951,7 @@ pStateReal->lifeData.depth_meter = meter; } - pStateReal->lifeData.temperature_celsius = dataIn.data[dataIn.boolPressureData].temperature; + pStateReal->lifeData.temperature_celsius = getTemperature(&dataIn); pStateReal->lifeData.ascent_rate_meter_per_min = dataIn.data[dataIn.boolPressureData].ascent_rate_meter_per_min; if(pStateReal->mode != MODE_DIVE) pStateReal->lifeData.max_depth_meter = 0;