FILTER_NUM;=20;
void Prepare_Data(T_int16_xyz *acc_in,T_int16_xyz *acc_out)
{
static uint8_t filter_cnt=0;
static int16_tACC_X_BUF[FILTER_NUM],ACC_Y_BUF[FILTER_NUM],ACC_Z_BUF[FILTER_NUM];
ACC_X_BUF[filter_cnt] = acc_in->X;
ACC_Y_BUF[filter_cnt] = acc_in->Y;
ACC_Z_BUF[filter_cnt] = acc_in->Z;
for(i=0;i<FILTER_NUM;i++)
{
temp1 += ACC_X_BUF[i];
temp2 += ACC_Y_BUF[i];
temp3 += ACC_Z_BUF[i];
}//为什么 只赋值了一次就进入for循环 加了20次
acc_out->X = temp1 / FILTER_NUM;
acc_out->Y = temp2 / FILTER_NUM;
acc_out->Z = temp3 / FILTER_NUM;
filter_cnt++;
if(filter_cnt==FILTER_NUM)filter_cnt=0;
}
关键词:
加速度
滑动
滤波
循环
20次