alou-S / omen-fan

Utility to control fans in Omen laptops
GNU General Public License v3.0
49 stars 5 forks source link

added boxcar averaging functionality #10

Open itsonlyaudio opened 3 months ago

itsonlyaudio commented 3 months ago

When running the original code, I often encountered one fluke temperature value sent the fans spinning like crazy, only to come back down really quickly. The time behaviour of the fan speed adaptation was much faster than the thermal mass of the system could absorb heat, so it appears instantaneous adaptation was too volatile.

Therefore I implemented a simple form of low-pass filtering where we simply average the last n temperature measurements, known as boxcar averaging. In the settings you can indicate how many temperature measurements are averaged. Together with the interval parameter, you can now express the temporal behaviour of the fan speed adaptation. The reaction speed to a step in temperature is now (interval * Nboxcar) so with the default values, the system now ramps up or down in 5 seconds. I've played with values as large as 30 seconds to really smooth out the fan speed modulation and it worked fine. The value of 5 I consider to be an absolutely safe value together with the default temp curve.