大家好,又见面了,我是你们的朋友全栈君。
#define A 10char value;char filter(){ char new_value; new_value = get_ad(); if ( ( new_value - value > A ) || ( value - new_value > A )) { return value; } return new_value; }
#define N 11char filter(){ char value_buf[N]; char count,i,j,temp; for ( count=0;count<N;COUNT++) { value_buf[count] = get_ad(); delay(); } for (j=0;j<N-1;J++) { for (i=0;i<N-J;I++) { if ( value_buf>value_buf[i+1] ) { temp = value_buf; value_buf = value_buf[i+1]; value_buf[i+1] = temp; } } } return value_buf[(N-1)/2];}
#define N 12char filter(){ int sum = 0; for ( count=0;count<N;COUNT++) { sum + = get_ad(); delay(); } return (char)(sum/N);}
#define N 12 char value_buf[N];char i=0;char filter(){ char count; int sum=0; value_buf[i++] = get_ad(); if ( i == N ) { i = 0; } for ( count=0;count<N,COUNT++) { sum = value_buf[count]; } return (char)(sum/N);}
#define N 12char filter(){ char count,i,j; char value_buf[N]; int sum=0; for (count=0;count<N;COUNT++) { value_buf[count] = get_ad(); delay(); } for (j=0;j<N-1;J++) { for (i=0;i<N-J;I++) { if ( value_buf>value_buf[i+1] ) { temp = value_buf; value_buf = value_buf[i+1]; value_buf[i+1] = temp; } } } for(count=1;count<N-1;COUNT++) { sum += value[count]; } return (char)(sum/(N-2));}
#define a 50char value;char filter(){ char new_value; new_value = get_ad(); return (100-a)*value + a*new_value; }
#define N 12char code coe[N] = {1,2,3,4,5,6,7,8,9,10,11,12};char code sum_coe = 1+2+3+4+5+6+7+8+9+10+11+12;char filter(){ char count; char value_buf[N]; int sum=0; for (count=0,count<N;COUNT++) { value_buf[count] = get_ad(); delay(); } for (count=0,count<N;COUNT++) { sum += value_buf[count]*coe[count]; } return (char)(sum/sum_coe);}
#define N 12char filter(){ char count=0; char new_value; new_value = get_ad(); while (value !=new_value); { count++; if (count>=N) { return new_value; } delay(); new_value = get_ad(); } return value; }
int BandpassFilter4(int InputAD4){ int ReturnValue; int ii; RESLO=0; RESHI=0; MACS=*PdelIn; OP2=1068; //FilterCoeff4[4]; MACS=*(PdelIn+1); OP2=8; //FilterCoeff4[3]; MACS=*(PdelIn+2); OP2=-2001;//FilterCoeff4[2]; MACS=*(PdelIn+3); OP2=8; //FilterCoeff4[1]; MACS=InputAD4; OP2=1068; //FilterCoeff4[0]; MACS=*PdelOu; OP2=-7190;//FilterCoeff4[8]; MACS=*(PdelOu+1); OP2=-1973; //FilterCoeff4[7]; MACS=*(PdelOu+2); OP2=-19578;//FilterCoeff4[6]; MACS=*(PdelOu+3); OP2=-3047; //FilterCoeff4[5]; *p=RESLO; *(p+1)=RESHI; mytestmul<<=2; ReturnValue=*(p+1); for(ii=0;ii<3;ii++) { DelayInput[ii]=DelayInput[ii+1]; DelayOutput[ii]=DelayOutput[ii+1]; } DelayInput[3]=InputAD4; DelayOutput[3]=ReturnValue; // if (ReturnValue<0) // { // ReturnValue=-ReturnValue; // } return ReturnValue; }
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/135700.html原文链接:https://javaforall.cn