Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # define TEMP_AVG_SIZE 10;
- float temp_avg_arr[TEMP_AVG_SIZE ] = {1};
- int temp_avg_ind=0;
- void tempOnextInd(){
- if(temp_avg_ind== 9){ // wrap around to start of array
- temp_avg_ind=0;
- return;
- }
- temp_avg_ind++;
- }
- float tempCalcAvg(){
- int i;
- float sum =0;
- for (i=0;i<TEMP_AVG_SIZE ;i++){
- sum+=temp_avg_arr;
- }
- return sum/TEMP_AVG_SIZE;
- }
- void readTemp(){
- float new_temp = Tr; // TODO: update this line to read new temp!
- temp_avg_arr[temp_avg_ind] = new_temp;
- tempNextInd();
- float current_avg= tempClacAvg();
- // TODO: use current_avg for whatever
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement