占位符
1 /* 加权平均滤波 */ 2 static unsigned char coe[13] = {1,2,3,4,5,6,7,8,9,10,11,12,13}; 3 static unsigned int coeSum= 1+2+3+4+5+6+7+8+9+10+11+12+13; 4 unsigned long temp = 0; 5 6 for (i = 0; i<ADCN; i++) 7 { 8 temp += arr[i]*coe[i]; 9 } 10 temp = (unsigned long )( temp * 1.0 / coeSum);
占位符
1 /* 中值滤波 */ 2 unsigned long temp = 0; 3 4 // 选择排序 5 for (i = 0; i<ADCN-1; i++) 6 { 7 k = i; 8 for (j = i+1; j<ADCN; j++) 9 { 10 if (arr[j] < arr[k]) 11 k = j; 12 } 13 if (k != i) 14 { 15 temp = arr[k]; 16 arr[k] = arr[i]; 17 arr[i] = temp; 18 } 19 } 20 temp = arr[ (ADCN - 1) / 2]; //返回中值