Advertisement
barohayon

Eden_readTemp

Jun 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. # define TEMP_AVG_SIZE 10;
  2. float temp_avg_arr[TEMP_AVG_SIZE ] = {1};
  3. int temp_avg_ind=0;
  4. void tempOnextInd(){
  5.     if(temp_avg_ind== 9){ // wrap around to start of array
  6.         temp_avg_ind=0;
  7.         return;
  8.     }
  9.     temp_avg_ind++;
  10. }
  11. float tempCalcAvg(){
  12.     int i;
  13.     float sum =0;
  14.     for (i=0;i<TEMP_AVG_SIZE ;i++){
  15.         sum+=temp_avg_arr;
  16.     }
  17.     return sum/TEMP_AVG_SIZE;
  18. }
  19.    
  20. void readTemp(){
  21.     float new_temp = Tr; // TODO: update this line to read new temp!
  22.     temp_avg_arr[temp_avg_ind] = new_temp;
  23.     tempNextInd();
  24.     float current_avg= tempClacAvg();
  25.     // TODO: use current_avg for whatever
  26.    
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement