AaronKelley / DellFanManagement

A suite of tools for managing the fans in many Dell laptops.
GNU General Public License v3.0
245 stars 30 forks source link

Give fine control of fan by constantly switching between states #24

Open DonFlymoor opened 2 years ago

DonFlymoor commented 2 years ago

It would be possible to have five control of the fan by constantly switching between states. For instance, %75 could be achieved by turning the fan to state 2 until it reaches %75, then switch between state 1 and state 2 constantly, with a short delay. This would allow the fan to start to slow a bit, then does it back up. If done fast enough, it could keep the fan turing at the desired speed without slowing. Then you could create a fan curve in speedfan or hwinfo to get optimal temperatures and volume.

DonFlymoor commented 2 years ago

I've tried it, and with a bit of fine-tuning it works. Here's the python code I used:

import subprocess
import time

def fancmd(command):
    si = subprocess.STARTUPINFO()
    si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    cmd = '"<pathtocommand>\\DellFanCmd.exe"'+" "+command
    subprocess.call(cmd, startupinfo=si)
    print(command)

def disable_ec():
    fancmd("ec-disable")

def enable_ec():
    fancmd("ec-enable")

def set_10():
    fancmd("fan1-level0")

def set_11():
    fancmd("fan1-level1")

def set_12():
    fancmd("fan1-level2")

def set_20():
    fancmd("fan2-level0")

def set_21():
    fancmd("fan2-level1")

def set_22():
    fancmd("fan2-level2")

def set_0():
    set_10()
    set_20()

def set_50():
    set_11()
    set_21()

def set_100():
    set_12()
    set_22()

def set_level(percentage):
    #60, 70, 80, or 90
    if percentage == 60:
        delay = 1.5
    elif percentage == 70:
        delay = 3
    elif percentage == 80:
        delay = 4.5
    elif percentage == 90:
        delay = 6
    set_50()
    time.sleep(10)
    set_100()
    time.sleep(delay)
    for i in range(0,10):
        set_50()
        time.sleep(0.1)
        set_100()
        time.sleep(0.1)

def main():
    disable_ec()
    set_level(70)
    set_50()
    #enable_ec()

if __name__ == "__main__":
    main()
shadowzlh commented 1 year ago

I want to know if there will be some bad effects from such frequent switching states