Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/lua5.3
- posix = require "socket"
- local low=75
- local high=92
- local sleep=0.5
- local tempfile="/sys/class/thermal/thermal_zone0/temp"
- local divisor=1000
- local boostfile="/sys/devices/system/cpu/cpufreq/boost"
- local last=-1
- function setboost(n)
- if last~=n then
- last=n
- bh=io.open(boostfile,"w")
- if bh then
- bh:write(n.."\n")
- bh:close()
- end
- end
- end
- while true do
- posix.sleep(sleep)
- h=io.open(tempfile,"rb")
- if h then
- local sensor=h:read("*n")
- h:close()
- if sensor then
- sensor=tonumber(sensor)/1000
- io.write(math.floor(sensor+0.5).." C")
- local float=1-math.min(1,math.max(0,((sensor-low)/(high-low))))
- io.write("\tBoost: "..math.floor(float*100+0.5) .."%")
- local boost=math.random()<float and 1 or 0
- setboost(boost)
- print("\t"..(boost==1 and "BOOST" or ""))
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement