Update rockchip-pwm-fan.sh
rockchip:optimize temperature control and start fan script
This commit is contained in:
parent
81828eda28
commit
e8c6f8f165
@ -1,46 +1,30 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
echo -n 4 > /sys/class/thermal/cooling_device0/cur_state
|
|
||||||
sleep 5
|
|
||||||
echo -n 0 > /sys/class/thermal/cooling_device0/cur_state
|
echo -n 0 > /sys/class/thermal/cooling_device0/cur_state
|
||||||
declare -a CpuTemps=(65000 60000 50000 40000 20000)
|
|
||||||
|
declare -a CpuTemps=(65000 60000 55000 50000 49000)
|
||||||
declare -a CoolState=(4 3 2 1 0)
|
declare -a CoolState=(4 3 2 1 0)
|
||||||
declare -a Percents=(100 70 50 20 0)
|
|
||||||
DefaultDuty=0
|
last_duty=0
|
||||||
DefaultPercents=0
|
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
temp=$(cat /sys/class/thermal/thermal_zone0/temp)
|
temp=$(cat /sys/class/thermal/thermal_zone0/temp)
|
||||||
INDEX=0
|
DUTY=0
|
||||||
FOUNDTEMP=0
|
|
||||||
DUTY=$DefaultDuty
|
|
||||||
PERCENT=$DefaultPercents
|
|
||||||
|
|
||||||
for i in 0 1 2 3 4; do
|
|
||||||
if [ $temp -gt ${CpuTemps[$i]} ]; then
|
|
||||||
INDEX=$i
|
|
||||||
FOUNDTEMP=1
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ ${FOUNDTEMP} == 1 ]; then
|
|
||||||
DUTY=${CoolState[$i]}
|
|
||||||
PERCENT=${Percents[$i]}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $last_dutu -eq '0' ]]; then
|
for i in ${!CpuTemps[@]}; do
|
||||||
if [[ $DUTY -ne '0' ]]; then
|
if [ $temp -ge ${CpuTemps[$i]} ]; then
|
||||||
echo -n 4 > /sys/class/thermal/cooling_device0/cur_state;
|
DUTY=${CoolState[$i]}
|
||||||
sleep 1s;
|
break
|
||||||
echo -n $DUTY > /sys/class/thermal/cooling_device0/cur_state;
|
fi
|
||||||
else
|
done
|
||||||
echo -n 0 > /sys/class/thermal/cooling_device0/cur_state;
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -n $DUTY > /sys/class/thermal/cooling_device0/cur_state;
|
|
||||||
fi
|
|
||||||
|
|
||||||
last_dutu=$DUTY
|
if [ $DUTY -ne $last_duty ]; then
|
||||||
echo "temp: $temp, duty: $DUTY, ${PERCENT}%"
|
echo -n $DUTY > /sys/class/thermal/cooling_device0/cur_state
|
||||||
sleep 60s;
|
last_duty=$DUTY
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "temp: $temp, duty: $DUTY"
|
||||||
|
|
||||||
|
sleep 60s
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user