mirror of
https://github.com/clockworkpi/DevTerm.git
synced 2025-12-12 18:28:50 +01:00
Added cooldown threshold in separate variable. Fixed bug where state change might happen twice on one loop iteration.
This commit is contained in:
parent
d119b30d56
commit
6765b86f86
@ -10,7 +10,10 @@ cpus = []
|
|||||||
mid_freq = 0
|
mid_freq = 0
|
||||||
max_freq = 0
|
max_freq = 0
|
||||||
|
|
||||||
|
#Start the fan above this temperature
|
||||||
MAX_TEMP=60000
|
MAX_TEMP=60000
|
||||||
|
#Cool additionally this far past MAX_TEMP before turning the fan off
|
||||||
|
TEMP_THRESH=2000
|
||||||
ONCE_TIME=30
|
ONCE_TIME=30
|
||||||
|
|
||||||
lastTemp = 0
|
lastTemp = 0
|
||||||
@ -86,9 +89,11 @@ def set_performance(scale):
|
|||||||
|
|
||||||
def fan_loop():
|
def fan_loop():
|
||||||
global lastTemp
|
global lastTemp
|
||||||
|
statechange = False
|
||||||
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()
|
||||||
|
statechange = False
|
||||||
for var in temps:
|
for var in temps:
|
||||||
_f = os.path.join(var,"temp")
|
_f = os.path.join(var,"temp")
|
||||||
#print( open(_f).read().strip("\n") )
|
#print( open(_f).read().strip("\n") )
|
||||||
@ -98,13 +103,17 @@ def fan_loop():
|
|||||||
if lastTemp <= MAX_TEMP:
|
if lastTemp <= MAX_TEMP:
|
||||||
sys.stderr.write("Temp: " + str(_t) + " Fan on.\n")
|
sys.stderr.write("Temp: " + str(_t) + " Fan on.\n")
|
||||||
fan_on()
|
fan_on()
|
||||||
|
statechange = True
|
||||||
else:
|
else:
|
||||||
#Don't turn it off right at the threshold
|
#Don't turn it off right at the threshold
|
||||||
if int(_t) + 2000 < MAX_TEMP:
|
if int(_t) + TEMP_THRESH < MAX_TEMP:
|
||||||
if lastTemp + 2000 >= MAX_TEMP:
|
if lastTemp + TEMP_THRESH >= MAX_TEMP:
|
||||||
sys.stderr.write("Temp: " + str(_t) + " Fan off.\n")
|
sys.stderr.write("Temp: " + str(_t) + " Fan off.\n")
|
||||||
fan_off()
|
fan_off()
|
||||||
|
statechange = True
|
||||||
lastTemp = int(_t)
|
lastTemp = int(_t)
|
||||||
|
if statechange:
|
||||||
|
break
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user