comparison 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
comparison
equal deleted inserted replaced
201:4073b8091224 202:d328abe2e44e
769 if (c == AVERAGE_COUNT) c = 0; 769 if (c == AVERAGE_COUNT) c = 0;
770 770
771 return (depth[0] + depth[1] + depth[2] + depth[3])/4.0f; 771 return (depth[0] + depth[1] + depth[2] + depth[3])/4.0f;
772 } 772 }
773 773
774 #define TEMP_AVERAGE_COUNT 3
775 static float getTemperature(SDataExchangeSlaveToMaster *d)
776 {
777 static uint8_t c = 0;
778 static float temp[TEMP_AVERAGE_COUNT] = {0};
779
780 temp[c] = d->data[d->boolPressureData].temperature;
781
782 c++;
783 if (c == TEMP_AVERAGE_COUNT) c = 0;
784
785 return (temp[0] + temp[1] + temp[2])/3.0f;
786 }
787
774 void DataEX_copy_to_LifeData(_Bool *modeChangeFlag) 788 void DataEX_copy_to_LifeData(_Bool *modeChangeFlag)
775 { 789 {
776 SDiveState *pStateReal = stateRealGetPointerWrite(); 790 SDiveState *pStateReal = stateRealGetPointerWrite();
777 static uint16_t getDeviceDataAfterStartOfMainCPU = 20; 791 static uint16_t getDeviceDataAfterStartOfMainCPU = 20;
778 792
935 else 949 else
936 { 950 {
937 pStateReal->lifeData.depth_meter = meter; 951 pStateReal->lifeData.depth_meter = meter;
938 } 952 }
939 953
940 pStateReal->lifeData.temperature_celsius = dataIn.data[dataIn.boolPressureData].temperature; 954 pStateReal->lifeData.temperature_celsius = getTemperature(&dataIn);
941 pStateReal->lifeData.ascent_rate_meter_per_min = dataIn.data[dataIn.boolPressureData].ascent_rate_meter_per_min; 955 pStateReal->lifeData.ascent_rate_meter_per_min = dataIn.data[dataIn.boolPressureData].ascent_rate_meter_per_min;
942 if(pStateReal->mode != MODE_DIVE) 956 if(pStateReal->mode != MODE_DIVE)
943 pStateReal->lifeData.max_depth_meter = 0; 957 pStateReal->lifeData.max_depth_meter = 0;
944 else 958 else
945 { 959 {