This commit is contained in:
DHDAXCW
2023-06-10 17:23:59 +00:00
parent 46ada0542d
commit b8ec85b33a
2 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
#!/bin/sh /etc/rc.common
START=96
start() {
echo "fa-pwmfan started"
/usr/bin/rockchip-pwm-fan.sh > /dev/null&
}

View File

@@ -0,0 +1,46 @@
#!/bin/bash
echo -n 4 > /sys/class/thermal/cooling_device0/cur_state
sleep 5
echo -n 0 > /sys/class/thermal/cooling_device0/cur_state
declare -a CpuTemps=(70000 60000 50000 40000 35000)
declare -a PwmDutyCycles=(4 3 2 1 0)
declare -a Percents=(100 70 50 20 0)
DefaultDuty=0
DefaultPercents=0
while true
do
temp=$(cat /sys/class/thermal/thermal_zone0/temp)
INDEX=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=${PwmDutyCycles[$i]}
PERCENT=${Percents[$i]}
fi
if [[ $last_dutu -eq '0' ]]; then
if [[ $DUTY -ne '0' ]]; then
echo -n 4 > /sys/class/thermal/cooling_device0/cur_state;
sleep 1s;
echo -n $DUTY > /sys/class/thermal/cooling_device0/cur_state;
else
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
echo "temp: $temp, duty: $DUTY, ${PERCENT}%"
sleep 10s;
done