From f213a525704cde537d778cf9829682a698d4dd7f Mon Sep 17 00:00:00 2001 From: Carl Philipp Klemm Date: Tue, 2 May 2023 13:01:26 +0200 Subject: [PATCH] fix negative fan speed --- main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 63ee89e..d8e1fb3 100644 --- a/main.cpp +++ b/main.cpp @@ -57,8 +57,8 @@ std::vector gather_sensors(std::vector& ipmi_sensors, ipmi_monit double fan_curve(double temperature, double min_fan, double max_fan, double low_temperature, double high_temperature) { - double slope = (max_fan-min_fan)/(low_temperature-high_temperature); - return std::min(max_fan, min_fan+slope*temperature-low_temperature); + double slope = (max_fan-min_fan)/(high_temperature-low_temperature); + return std::max(std::min(max_fan, min_fan+slope*(temperature-low_temperature)), min_fan); } double gpu_fan_zone(const std::vector& sensors)