From 3ff1aad95f63d8802fcfb58be3a6e204ef5a2a48 Mon Sep 17 00:00:00 2001 From: Daniel Graziotin Date: Wed, 24 Oct 2012 14:18:11 +0200 Subject: [PATCH] Taking into account the number of sensors in averaging temp #24 --- src/mbpfan.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mbpfan.c b/src/mbpfan.c index ea8d9c0..e9478e8 100644 --- a/src/mbpfan.c +++ b/src/mbpfan.c @@ -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; }