/*
void Weighting(uint32_t *Priary_Data,uint16_t Deal_Long,uint16_t Weight_Long,uint16_t Grade,float *Filter_Data)
定义:加权-滤波-阈值曲线
参数:
//Priary_Data---输入--原始ADC数据
//Deal_Long-----输入--数据个数
//Weight_Long---输入--滤波处理长度最大为9,如果想输出原函数,配置Weight_Long=0
//Grade---------输入--滤波数据处理等级--处理层数,写0时也是一层
//up_thre_data--输入--阈值设置
//Filter_Data---输出--滤波数据
//Compare_Data--输出--参与波形比较
//Thre_Data-----输出--阈值曲线
返回值:无
*/
#include "lock.h"
void Weighting(uint32_t *Priary_Data,uint16_t Deal_Long,uint16_t Weight_Long,uint16_t Grade,float *Filter_Data)
{
uint16_t i=0;
float temp_f=0.0f;
uint32_t data_long=0;
uint16_t Addr_Star=0,Addr_Stop=0;
uint16_t G=0;
uint16_t m=0;
for(i=0;i<Deal_Long;i++)
{
for(G=0;G<Grade;G++) //第G层 G=0~Grade-1
{
if(i<(Weight_Long-G))
Addr_Star=0; //第G层从Weight_Long-G位开始就能走完一遍了
else
{
if(Weight_Long<G)
Addr_Star=i-(Weight_Long-G);
else
Addr_Star=i;
}
if(i>=(Deal_Long-Weight_Long+G))
Addr_Stop=Deal_Long-1;
else
{
if(Weight_Long>=G)
Addr_Stop=i+Weight_Long-G;
else
Addr_Stop=i;
}
for(m=Addr_Star;m<=Addr_Stop;m++) //求起始点和终止点的和
{
temp_f+=(float)LSB_32(Priary_Data[m]);
data_long++;
}
}
Filter_Data[i]=temp_f/(float)data_long; //滤波值
temp_f=0.0f;
data_long=0;
}
}