//去掉一个最大值,去掉一个最小值,求平均值
#define BUF_DEEP 3
#define CHX_NUM 3
static uint32_t ValueFiltrate(uint8_t chx,uint32_t Value)
{
static uint32_t ValueTempBuf[CHX_NUM][BUF_DEEP];
static uint8_t point[CHX_NUM] = {0};
uint32_t Max = 0;
uint32_t Min = 0xffffffff;
uint32_t Sum = 0;
if(chx >= CHX_NUM)
return 0;
ValueTempBuf[chx][point[chx]] = Value;
point[chx] ++;
if(point[chx] == BUF_DEEP)
point[chx] = 0;
for(uint8_t i = 0;i<BUF_DEEP;i++)
{
if(ValueTempBuf[chx][i] >= Max)
Max = ValueTempBuf[chx][i];
if(ValueTempBuf[chx][i] <= Min)
Min = ValueTempBuf[chx][i];
Sum += ValueTempBuf[chx][i];
}
return (Sum - Max - Min)/(BUF_DEEP-2);
}
C语言 滤波 去掉一个最大值,去掉一个最小值,求平均值
最新推荐文章于 2024-02-14 14:11:22 发布