Commit 3ff1aad9 authored by Daniel Graziotin's avatar Daniel Graziotin

Taking into account the number of sensors in averaging temp #24

parent 45755d62
......@@ -277,12 +277,18 @@ unsigned short get_temp(t_sensors* sensors)
t_sensors* tmp = sensors;
int number_sensors = 0;
while(tmp != NULL) {
sum_temp += tmp->temperature;
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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment