Changeset 4437
- Timestamp:
- 06/10/07 14:36:44 (6 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 2 modified
-
CHANGES (modified) (1 diff)
-
prog/pwm/fancontrol (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/CHANGES
r4436 r4437 16 16 Fix Super-I/O exit sequence for Winbond/Fintek chips 17 17 Program fancontrol: Use let for arithmetic evaluation 18 No longer need awk and grep 19 Limit calls to external programs (Linux 2.6 only) 18 20 Program pwmconfig: Use smaller steps for low PWM values 19 21 Program rrd: Support non-i2c devices (hwmon class) -
lm-sensors/trunk/prog/pwm/fancontrol
r4436 r4437 3 3 # Simple script implementing a temperature dependent fan speed control 4 4 # 5 # Version 0.6 45 # Version 0.65 6 6 # 7 7 # Usage: fancontrol [CONFIGFILE] 8 8 # 9 9 # Dependencies: 10 # bash, awk, egrep, sed, lm_sensors :)10 # bash, egrep, sed, cut, sleep, lm_sensors :) 11 11 # 12 12 # Please send any questions, comments or success stories to … … 105 105 then 106 106 # For Linux 2.6, detect if config file uses the hwmon class or not yet 107 if echo "$ AFCPWM[0]" | grep'^hwmon[0-9]'107 if echo "${AFCPWM[0]}" | egrep -q '^hwmon[0-9]' 108 108 then 109 109 SDIR=/sys/class/hwmon … … 196 196 197 197 trap restorefans SIGHUP SIGINT SIGQUIT SIGTERM SIGKILL 198 199 # function doing all the math200 function calc () {201 awk "BEGIN { print $@ }"202 }203 198 204 199 # main function … … 216 211 minso=${AFCMINSTOP[$fcvcount]} 217 212 218 tval=`cat ${tsens}`213 read tval < ${tsens} 219 214 if [ $? -ne 0 ] 220 215 then … … 222 217 restorefans 223 218 fi 224 tval=`echo ${tval} |cut -d' ' -f3 |cut -d'.' -f1`225 219 if [ "$SYSFS" = "1" ] 226 220 then 227 let tval="$tval / 1000" 228 fi 229 230 pwmpval=`cat ${pwmo}` 221 let tval="($tval+500)/1000" 222 else 223 tval=`echo ${tval} | cut -d' ' -f3 | cut -d'.' -f1` 224 fi 225 226 read pwmpval < ${pwmo} 231 227 if [ $? -ne 0 ] 232 228 then … … 234 230 restorefans 235 231 fi 236 pwmpval=`echo ${pwmpval} | cut -d' ' -f1` 232 if [ "$SYSFS" != "1" ] 233 then 234 pwmpval=`echo ${pwmpval} | cut -d' ' -f1` 235 fi 237 236 238 237 # If fanspeed-sensor output shall be used, do it 239 238 if [[ -n ${fan} ]] 240 239 then 241 fanval=`cat ${fan}`240 read fanval < ${fan} 242 241 if [ $? -ne 0 ] 243 242 then … … 245 244 restorefans 246 245 fi 247 fanval=`echo ${fanval} | cut -d' ' -f2` 246 if [ "$SYSFS" != "1" ] 247 then 248 fanval=`echo ${fanval} | cut -d' ' -f2` 249 fi 248 250 else 249 251 fanval=1 # set it to a non zero value, so the rest of the script still works … … 271 273 else 272 274 # calculate the new value from temperature and settings 273 pwmval=`calc "(((${tval}-${mint})/(${maxt}-${mint}))^2*(255-${minso})+${minso})" |cut -d'.' -f1`275 let pwmval="((${tval}-${mint})**2)*(255-${minso})/((${maxt}-${mint})**2)+${minso}" 274 276 if [ $pwmpval -eq 0 -o $fanval -eq 0 ] 275 277 then # if fan was stopped start it using a safe value
