tweak fan profiles, thanks doc brown
This commit is contained in:
parent
e2f5130532
commit
84961cb815
3 changed files with 128 additions and 44 deletions
|
@ -4,7 +4,16 @@
|
|||
|
||||
. /etc/profile
|
||||
|
||||
### Enable logging
|
||||
case $(get_setting system.loglevel) in
|
||||
verbose)
|
||||
DEBUG=true
|
||||
;;
|
||||
*)
|
||||
DEBUG=false
|
||||
;;
|
||||
esac
|
||||
|
||||
COOLING_PROFILE=$(get_setting "cooling.profile")
|
||||
FAN_PWM="${DEVICE_PWM_FAN}"
|
||||
|
||||
|
@ -22,7 +31,7 @@ trap "set_control 0 && exit 0" SIGHUP SIGINT SIGQUIT SIGABRT
|
|||
|
||||
if [ -e "/storage/.config/fancontrol.conf" ] && [ "${COOLING_PROFILE}" = "custom" ]
|
||||
then
|
||||
log $0 "Loading configuration file" 2>/dev/null
|
||||
$DEBUG && log $0 "Loading configuration file" 2>/dev/null
|
||||
source /storage/.config/fancontrol.conf
|
||||
if [ ! $? = 0 ]
|
||||
then
|
||||
|
@ -37,17 +46,17 @@ if [ ! "${COOLING_PROFILE}" = "custom" ]
|
|||
then
|
||||
if [ "${COOLING_PROFILE}" = "aggressive" ]
|
||||
then
|
||||
SPEEDS=(255 225 192)
|
||||
TEMPS=(70000 65000 0)
|
||||
SPEEDS=(192 225 255)
|
||||
TEMPS=(45000 75000 85000)
|
||||
elif [ "${COOLING_PROFILE}" = "moderate" ]
|
||||
then
|
||||
SPEEDS=(255 192 128 96)
|
||||
TEMPS=(75000 70000 65000 0)
|
||||
SPEEDS=(48 64 96 128 192 255)
|
||||
TEMPS=(50000 55000 60000 70000 80000 90000)
|
||||
elif [ "${COOLING_PROFILE}" = "quiet" ]
|
||||
then
|
||||
# Quiet.
|
||||
SPEEDS=(255 192 128 96 64 48 32)
|
||||
TEMPS=(75000 70000 65000 60000 55000 50000 0)
|
||||
SPEEDS=(32 48 64 96 128 192 255)
|
||||
TEMPS=(50000 55000 60000 65000 70000 80000 90000)
|
||||
else
|
||||
# auto
|
||||
set_control 0 >/dev/null 2>&1
|
||||
|
@ -58,22 +67,41 @@ fi
|
|||
log $0 "Enabling fan control."
|
||||
set_control 1 >/dev/null 2>&1
|
||||
|
||||
CURRENTSPEED=0
|
||||
TEMP=${TEMPS[0]}
|
||||
declare -a HISTORY
|
||||
while true
|
||||
do
|
||||
INDEX=0
|
||||
CPU_TEMP=$(printf "%.0f" $(awk '{ total += $1; count++ } END { print total/count }' ${DEVICE_TEMP_SENSOR}))
|
||||
$DEBUG && log $0 "CPU TEMP: ${CPU_TEMP}" 2>/dev/null
|
||||
|
||||
### Keep a rolling history of CPU temps.
|
||||
HISTORY+=(${CPU_TEMP})
|
||||
while (( ${#HISTORY[@]} > 10 ))
|
||||
do
|
||||
unset HISTORY[-0]
|
||||
PRIOR_HISTORY=( ${HISTORY[*]} )
|
||||
HISTORY=( ${PRIOR_HISTORY[*]} )
|
||||
unset PRIOR_HISTORY
|
||||
done
|
||||
AVERAGE=$(echo $(IFS=+; echo "$((${HISTORY[*]}))") / ${#HISTORY[@]} | bc)
|
||||
|
||||
$DEBUG && log $0 "Current/Average/Ceiling (Speed): ${CPU_TEMP}/${AVERAGE}/${TEMP} (${CURRENTSPEED})."
|
||||
for TEMP in "${TEMPS[@]}"
|
||||
do
|
||||
if (( "${CPU_TEMP}" > "${TEMP}" )) && \
|
||||
[ ! "${LASTSPEED}" = "${SPEEDS[${INDEX}]}" ]
|
||||
if (( "${CPU_TEMP}" >= "90000" )) || \
|
||||
(( "${AVERAGE}" <= "${TEMP}" ))
|
||||
then
|
||||
$DEBUG && log $0 "Setting PWM FAN to ${SPEEDS[${INDEX}]} (${TEMP})" 2>/dev/null
|
||||
if (( ${CURRENTSPEED} != ${SPEEDS[${INDEX}]} ))
|
||||
then
|
||||
CURRENTSPEED=${SPEEDS[${INDEX}]}
|
||||
echo ${SPEEDS[${INDEX}]} >${FAN_PWM}
|
||||
LASTSPEED=${SPEEDS[${INDEX}]}
|
||||
break
|
||||
$DEBUG && log $0 "Set fan to ${CURRENTSPEED}."
|
||||
fi
|
||||
break
|
||||
else
|
||||
INDEX=$(( $INDEX + 1 ))
|
||||
fi
|
||||
done
|
||||
sleep 2
|
||||
done
|
||||
|
|
|
@ -4,7 +4,16 @@
|
|||
|
||||
. /etc/profile
|
||||
|
||||
### Enable logging
|
||||
case $(get_setting system.loglevel) in
|
||||
verbose)
|
||||
DEBUG=true
|
||||
;;
|
||||
*)
|
||||
DEBUG=false
|
||||
;;
|
||||
esac
|
||||
|
||||
COOLING_PROFILE=$(get_setting "cooling.profile")
|
||||
FAN_PWM="${DEVICE_PWM_FAN}"
|
||||
|
||||
|
@ -38,17 +47,17 @@ if [ ! "${COOLING_PROFILE}" = "custom" ]
|
|||
then
|
||||
if [ "${COOLING_PROFILE}" = "aggressive" ]
|
||||
then
|
||||
SPEEDS=(255 225 195)
|
||||
TEMPS=(55000 45000 0)
|
||||
SPEEDS=(195 225 255)
|
||||
TEMPS=(45000 60000 80000)
|
||||
elif [ "${COOLING_PROFILE}" = "moderate" ]
|
||||
then
|
||||
SPEEDS=(255 192 128 96)
|
||||
TEMPS=(65000 55000 45000 0)
|
||||
SPEEDS=(48 64 96 128 192 255)
|
||||
TEMPS=(45000 55000 65000 75000 85000 90000)
|
||||
elif [ "${COOLING_PROFILE}" = "quiet" ]
|
||||
then
|
||||
# Quiet.
|
||||
SPEEDS=(255 192 128 96 64 48 32)
|
||||
TEMPS=(70000 60000 55000 50000 49000 47000 0)
|
||||
SPEEDS=(32 48 64 96 128 192 255)
|
||||
TEMPS=(45000 50000 55000 65000 75000 85000 90000)
|
||||
else
|
||||
# auto
|
||||
set_control 0 >/dev/null 2>&1
|
||||
|
@ -59,22 +68,41 @@ fi
|
|||
log $0 "Enabling fan control."
|
||||
set_control 1 >/dev/null 2>&1
|
||||
|
||||
CURRENTSPEED=0
|
||||
TEMP=${TEMPS[0]}
|
||||
declare -a HISTORY
|
||||
while true
|
||||
do
|
||||
INDEX=0
|
||||
CPU_TEMP=$(printf "%.0f" $(awk '{ total += $1; count++ } END { print total/count }' ${DEVICE_TEMP_SENSOR}))
|
||||
$DEBUG && log $0 "CPU TEMP: ${CPU_TEMP}" 2>/dev/null
|
||||
|
||||
### Keep a rolling history of CPU temps.
|
||||
HISTORY+=(${CPU_TEMP})
|
||||
while (( ${#HISTORY[@]} > 10 ))
|
||||
do
|
||||
unset HISTORY[-0]
|
||||
PRIOR_HISTORY=( ${HISTORY[*]} )
|
||||
HISTORY=( ${PRIOR_HISTORY[*]} )
|
||||
unset PRIOR_HISTORY
|
||||
done
|
||||
AVERAGE=$(echo $(IFS=+; echo "$((${HISTORY[*]}))") / ${#HISTORY[@]} | bc)
|
||||
|
||||
$DEBUG && log $0 "Current/Average/Ceiling (Speed): ${CPU_TEMP}/${AVERAGE}/${TEMP} (${CURRENTSPEED})."
|
||||
for TEMP in "${TEMPS[@]}"
|
||||
do
|
||||
if (( "${CPU_TEMP}" > "${TEMP}" )) && \
|
||||
[ ! "${LASTSPEED}" = "${SPEEDS[${INDEX}]}" ]
|
||||
if (( "${CPU_TEMP}" >= "90000" )) || \
|
||||
(( "${AVERAGE}" <= "${TEMP}" ))
|
||||
then
|
||||
$DEBUG && log $0 "Setting PWM FAN to ${SPEEDS[${INDEX}]} (${TEMP})" 2>/dev/null
|
||||
if (( ${CURRENTSPEED} != ${SPEEDS[${INDEX}]} ))
|
||||
then
|
||||
CURRENTSPEED=${SPEEDS[${INDEX}]}
|
||||
echo ${SPEEDS[${INDEX}]} >${FAN_PWM}
|
||||
LASTSPEED=${SPEEDS[${INDEX}]}
|
||||
break
|
||||
$DEBUG && log $0 "Set fan to ${CURRENTSPEED}."
|
||||
fi
|
||||
break
|
||||
else
|
||||
INDEX=$(( $INDEX + 1 ))
|
||||
fi
|
||||
done
|
||||
sleep 2
|
||||
done
|
||||
|
|
|
@ -4,7 +4,16 @@
|
|||
|
||||
. /etc/profile
|
||||
|
||||
### Enable logging
|
||||
case $(get_setting system.loglevel) in
|
||||
verbose)
|
||||
DEBUG=true
|
||||
;;
|
||||
*)
|
||||
DEBUG=false
|
||||
;;
|
||||
esac
|
||||
|
||||
COOLING_PROFILE=$(get_setting "cooling.profile")
|
||||
|
||||
log $0 "Setting profile to ${COOLING_PROFILE}"
|
||||
|
@ -34,16 +43,16 @@ if [ ! "${COOLING_PROFILE}" = "custom" ]
|
|||
then
|
||||
if [ "${COOLING_PROFILE}" = "aggressive" ]
|
||||
then
|
||||
SPEEDS=(128 96 72)
|
||||
TEMPS=(70000 65000 0)
|
||||
SPEEDS=(72 96 128)
|
||||
TEMPS=(45000 75000 85000)
|
||||
elif [ "${COOLING_PROFILE}" = "moderate" ]
|
||||
then
|
||||
SPEEDS=(128 96 72 64 48)
|
||||
TEMPS=(70000 65000 60000 55000 0)
|
||||
SPEEDS=(32 48 64 72 96 128)
|
||||
TEMPS=(50000 55000 60000 70000 80000 90000)
|
||||
elif [ "${COOLING_PROFILE}" = "quiet" ]
|
||||
then
|
||||
SPEEDS=(128 96 64 48 32)
|
||||
TEMPS=(70000 65000 60000 55000 0)
|
||||
SPEEDS=(24 32 48 64 72 96 128)
|
||||
TEMPS=(50000 55000 60000 65000 70000 80000 90000)
|
||||
else
|
||||
# auto
|
||||
set_control 0x01 >/dev/null 2>&1
|
||||
|
@ -51,25 +60,44 @@ then
|
|||
fi
|
||||
fi
|
||||
|
||||
log $0 "Enabling fan control."
|
||||
$DEBUG && log $0 "Enabling fan control."
|
||||
set_control 0x00 >/dev/null 2>&1
|
||||
|
||||
CURRENTSPEED=0
|
||||
TEMP=${TEMPS[0]}
|
||||
declare -a HISTORY
|
||||
while true
|
||||
do
|
||||
INDEX=0
|
||||
CPU_TEMP=$(printf "%.0f" $(awk '{ total += $1; count++ } END { print total/count }' ${DEVICE_TEMP_SENSOR}))
|
||||
$DEBUG && log $0 "CPU TEMP: ${CPU_TEMP}" 2>/dev/null
|
||||
|
||||
### Keep a rolling history of CPU temps.
|
||||
HISTORY+=(${CPU_TEMP})
|
||||
while (( ${#HISTORY[@]} > 10 ))
|
||||
do
|
||||
unset HISTORY[-0]
|
||||
PRIOR_HISTORY=( ${HISTORY[*]} )
|
||||
HISTORY=( ${PRIOR_HISTORY[*]} )
|
||||
unset PRIOR_HISTORY
|
||||
done
|
||||
AVERAGE=$(echo $(IFS=+; echo "$((${HISTORY[*]}))") / ${#HISTORY[@]} | bc)
|
||||
|
||||
$DEBUG && log $0 "Current/Average/Ceiling (Speed): ${CPU_TEMP}/${AVERAGE}/${TEMP} (${CURRENTSPEED})."
|
||||
for TEMP in "${TEMPS[@]}"
|
||||
do
|
||||
if (( "${CPU_TEMP}" > "${TEMP}" )) && \
|
||||
[ ! "${LASTSPEED}" = "${SPEEDS[${INDEX}]}" ]
|
||||
if (( "${CPU_TEMP}" >= "90000" )) || \
|
||||
(( "${AVERAGE}" <= "${TEMP}" ))
|
||||
then
|
||||
$DEBUG && log $0 "Setting PWM FAN to ${SPEEDS[${INDEX}]} (${TEMP})" 2>/dev/null
|
||||
ectool -w 0x11 -z $(printf '%x\n' ${SPEEDS[${INDEX}]}) >/dev/null 2>&1
|
||||
LASTSPEED=${SPEEDS[${INDEX}]}
|
||||
break
|
||||
if (( ${CURRENTSPEED} != ${SPEEDS[${INDEX}]} ))
|
||||
then
|
||||
CURRENTSPEED=${SPEEDS[${INDEX}]}
|
||||
ectool -w 0x11 -z $(printf '%x\n' ${CURRENTSPEED}) >/dev/null 2>&1
|
||||
$DEBUG && log $0 "Set fan to ${CURRENTSPEED}."
|
||||
fi
|
||||
break
|
||||
else
|
||||
INDEX=$(( $INDEX + 1 ))
|
||||
fi
|
||||
done
|
||||
sleep 2
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue