mirror of
https://github.com/clockworkpi/DevTerm.git
synced 2025-12-12 18:28:50 +01:00
New fan_loop function which starts the fan when the temperature reaches the threshold and doesn't stop it until the temperatue is a bit lower than the threshold. Also lowered the threshold a bit.
This commit is contained in:
parent
4664328eaf
commit
d119b30d56
@ -10,9 +10,11 @@ cpus = []
|
|||||||
mid_freq = 0
|
mid_freq = 0
|
||||||
max_freq = 0
|
max_freq = 0
|
||||||
|
|
||||||
MAX_TEMP=70000
|
MAX_TEMP=60000
|
||||||
ONCE_TIME=30
|
ONCE_TIME=30
|
||||||
|
|
||||||
|
lastTemp = 0
|
||||||
|
|
||||||
gpiopath="/sys/class/gpio"
|
gpiopath="/sys/class/gpio"
|
||||||
gpiopin=96
|
gpiopin=96
|
||||||
def init_fan_gpio():
|
def init_fan_gpio():
|
||||||
@ -82,8 +84,8 @@ def set_performance(scale):
|
|||||||
#print(_f)
|
#print(_f)
|
||||||
subprocess.run( "echo %s | sudo tee %s" %(freq,_f),shell=True)
|
subprocess.run( "echo %s | sudo tee %s" %(freq,_f),shell=True)
|
||||||
|
|
||||||
|
|
||||||
def fan_loop():
|
def fan_loop():
|
||||||
|
global lastTemp
|
||||||
while True:
|
while True:
|
||||||
temps = glob.glob('/sys/class/thermal/thermal_zone[0-9]/')
|
temps = glob.glob('/sys/class/thermal/thermal_zone[0-9]/')
|
||||||
temps.sort()
|
temps.sort()
|
||||||
@ -93,12 +95,18 @@ def fan_loop():
|
|||||||
_t = open(_f).read().strip("\n")
|
_t = open(_f).read().strip("\n")
|
||||||
if isDigit(_t):
|
if isDigit(_t):
|
||||||
if int(_t) > MAX_TEMP:
|
if int(_t) > MAX_TEMP:
|
||||||
|
if lastTemp <= MAX_TEMP:
|
||||||
|
sys.stderr.write("Temp: " + str(_t) + " Fan on.\n")
|
||||||
fan_on()
|
fan_on()
|
||||||
fan_off()
|
else:
|
||||||
|
#Don't turn it off right at the threshold
|
||||||
|
if int(_t) + 2000 < MAX_TEMP:
|
||||||
|
if lastTemp + 2000 >= MAX_TEMP:
|
||||||
|
sys.stderr.write("Temp: " + str(_t) + " Fan off.\n")
|
||||||
|
fan_off()
|
||||||
|
lastTemp = int(_t)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
global cpus
|
global cpus
|
||||||
scale = 'mid'
|
scale = 'mid'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user