optical/NxFuncs/stadc/filter.h
2025-09-04 09:45:08 +08:00

80 lines
1.2 KiB
C

#ifndef __FILTER_H__
#define __FILTER_H__
#include "config.h"
//----------------------------------------------------------
// 中位值平均滤波器
int MAFilter(int * pBuff, int len);
//----------------------------------------------------------
// 加权递推平均滤波器(线性权值)
int WRAFilter(int * pBuff, int len);
//----------------------------------------------------------
// 一阶低通滤波
typedef struct
{
float f1value;
float lowpassxs;
}LPF1stData;
#ifdef _IN_FILTER_C
// 参考默认值
const LPF1stData defaultLPF1st =
{
-1,
0.5f,
};
#else
extern const LPF1stData defaultLPF1st;
#endif
int LPF1st(LPF1stData * pLpf1st, int newData);
//----------------------------------------------------------
// 二阶滤波
typedef struct
{
float f2value;
//
float b0;
float a1;
float a2;
float preout;
float lastout;
}LPF2ndData;
#ifdef _IN_FILTER_C
// 参考默认值
// 截止频率(中心频率f0):30Hz 采样频率fs:500Hz
const LPF2ndData defaultLPF2nd =
{
-1,
0.1883633f,
1.023694f,
0.2120577f,
0,
0,
};
#else
extern const LPF2ndData defaultLPF2nd;
#endif
int LPF2nd(LPF2ndData * pLpf2nd, int newData);
//----------------------------------------------------------
#endif