Taking into account the number of sensors in averaging temp #24
This commit is contained in:
parent
45755d6228
commit
3ff1aad95f
1 changed files with 7 additions and 1 deletions
|
@ -277,12 +277,18 @@ unsigned short get_temp(t_sensors* sensors)
|
||||||
|
|
||||||
t_sensors* tmp = sensors;
|
t_sensors* tmp = sensors;
|
||||||
|
|
||||||
|
int number_sensors = 0;
|
||||||
while(tmp != NULL) {
|
while(tmp != NULL) {
|
||||||
sum_temp += tmp->temperature;
|
sum_temp += tmp->temperature;
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
|
number_sensors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp = (unsigned short)( ceil( (float)( sum_temp ) / 2000. ) );
|
// just to be safe
|
||||||
|
if (number_sensors == 0)
|
||||||
|
number_sensors++;
|
||||||
|
|
||||||
|
temp = (unsigned short)( ceil( (float)( sum_temp ) / (number_sensors * 1000) ) );
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue