aboutsummaryrefslogtreecommitdiff
path: root/devices/thinkpad-fan.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'devices/thinkpad-fan.cpp')
-rw-r--r--devices/thinkpad-fan.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/devices/thinkpad-fan.cpp b/devices/thinkpad-fan.cpp
index 11b7284..286cfe0 100644
--- a/devices/thinkpad-fan.cpp
+++ b/devices/thinkpad-fan.cpp
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
+#include <math.h>
#include "../lib.h"
@@ -66,13 +67,21 @@ double thinkpad_fan::power_usage(struct result_bundle *result, struct parameter_
double utilization;
power = 0;
- factor = get_parameter_value("thinkpad-fan", bundle);
utilization = get_result_value("thinkpad-fan", result);
utilization = utilization - 50;
if (utilization < 0)
utilization = 0;
- power += utilization * factor / 100.0;
+
+ factor = get_parameter_value("thinkpad-fan-sqr", bundle);
+ power += factor * pow(utilization / 100.0, 2);
+
+ factor = get_parameter_value("thinkpad-fan", bundle);
+ power -= utilization * factor / 100.0;
+
+ if (power <= 0.0)
+ power = 0.0;
+
return power;
}