Changeset 1815
- Timestamp:
- 06/23/03 22:57:49 (10 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/prog/pwm/fancontrol (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/prog/pwm/fancontrol
r1798 r1815 42 42 function LoadConfig { 43 43 echo "Loading configuration from $1 ..." 44 # grep configuration from file44 # grep configuration from file 45 45 INTERVAL=`egrep '^INTERVAL=.*$' $1 | sed -e 's/INTERVAL=//g'` 46 46 FCTEMPS=`egrep '^FCTEMPS=.*$' $1 | sed -e 's/FCTEMPS=//g'` … … 55 55 exit 1 56 56 fi 57 # here the other settings should be verified 58 57 59 58 60 # write settings to arrays for easier use and print them 59 61 echo 60 62 echo "Common settings:" 61 63 echo " INTERVAL=$INTERVAL" 62 64 63 #write values to arrays64 65 let fcvcount=0 65 66 for fcv in $FCTEMPS … … 97 98 fi 98 99 99 function calc () { awk "BEGIN { print $@ }"; } 100 # function doing all the math 101 function calc () { 102 awk "BEGIN { print $@ }" 103 } 100 104 105 # main function 101 106 function UpdateFanSpeeds { 102 107 let fcvcount=0 103 while (( $fcvcount < ${#AFCPWM[@]} )) 108 while (( $fcvcount < ${#AFCPWM[@]} )) # go through all pwm outputs 104 109 do 105 110 #hopefully shorter vars will improve readability: … … 124 129 125 130 if (( $tval <= $mint )) 126 then pwmval=0 131 then pwmval=0 # at specified mintemp shut fan off 127 132 elif (( $tval >= $maxt )) 128 then pwmval=255 133 then pwmval=255 # at specified maxtemp switch to 100% 129 134 else 135 # calculate the new value from temperature and settings 130 136 pwmval=`calc "((10/(${maxt}-${mint})*(${tval}-${mint}))^2/1000*(${maxt}-${mint})*(255-${minso})+${minso})" |cut -d'.' -f1` 131 if (( $pwmpval == 0 )) # if fan was stopped, start it132 then 137 if (( $pwmpval == 0 )) 138 then # if fan was stopped start it using a safe value 133 139 echo $minsa > $pwmo 134 140 sleep 1 135 141 fi 136 142 fi 137 echo $pwmval > $pwmo 143 echo $pwmval > $pwmo # write new value to pwm output 138 144 fcvcount=$fcvcount+1 139 145 done 140 146 } 141 147 148 # main loop calling the main function at specified intervals 142 149 while true 143 150 do
