From d6fa78ae5f5b1fb9e0b590bfe35b4a02c16de935 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Wed, 1 Apr 2020 05:07:30 +0200 Subject: [PATCH] Change temperature curve to cubic --- fantemp/controller.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fantemp/controller.cpp b/fantemp/controller.cpp index 5f3c931..06977d8 100644 --- a/fantemp/controller.cpp +++ b/fantemp/controller.cpp @@ -24,7 +24,14 @@ void Controller::callback() uint8_t Controller::mapTemperature(double temperature) { - double fanSpeed = (10 * temperature - 200) / 3; + [[maybe_unused]] constexpr auto linearCurve = [](double x) { return (10 * x - 200) / 3; }; + constexpr auto cubicCurve = [](double x) { + if (x < 20) + return 0.0; + return 0.002246 * x * x * x - 0.09 * x * x + 0.91 * x; + }; + + double fanSpeed = cubicCurve(temperature); return clamp(fanSpeed, 0, 100); }