Changeset 1815

Show
Ignore:
Timestamp:
06/23/03 22:57:49 (10 years ago)
Author:
peglags
Message:

(marius) added some comments.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/pwm/fancontrol

    r1798 r1815  
    4242function LoadConfig { 
    4343        echo "Loading configuration from $1 ..." 
    44         #grep configuration from file 
     44        # grep configuration from file 
    4545        INTERVAL=`egrep '^INTERVAL=.*$' $1 | sed -e 's/INTERVAL=//g'` 
    4646        FCTEMPS=`egrep '^FCTEMPS=.*$' $1 | sed -e 's/FCTEMPS=//g'` 
     
    5555                exit 1 
    5656        fi 
     57        # here the other settings should be verified 
     58         
    5759 
    58  
     60        # write settings to arrays for easier use and print them 
    5961        echo 
    6062        echo "Common settings:" 
    6163        echo "  INTERVAL=$INTERVAL" 
    6264                                                 
    63         #write values to arrays 
    6465        let fcvcount=0 
    6566        for fcv in $FCTEMPS 
     
    9798fi 
    9899 
    99 function calc () { awk "BEGIN { print $@ }"; } 
     100# function doing all the math 
     101function calc () { 
     102        awk "BEGIN { print $@ }" 
     103} 
    100104 
     105# main function 
    101106function UpdateFanSpeeds { 
    102107        let fcvcount=0 
    103         while (( $fcvcount < ${#AFCPWM[@]} )) 
     108        while (( $fcvcount < ${#AFCPWM[@]} )) # go through all pwm outputs 
    104109        do 
    105110                #hopefully shorter vars will improve readability: 
     
    124129                 
    125130                if (( $tval <= $mint )) 
    126                   then pwmval=0 
     131                  then pwmval=0 # at specified mintemp shut fan off 
    127132                elif (( $tval >= $maxt )) 
    128                   then pwmval=255 
     133                  then pwmval=255 # at specified maxtemp switch to 100% 
    129134                else  
     135                  # calculate the new value from temperature and settings 
    130136                  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 it 
    132                   then 
     137                  if (( $pwmpval == 0 )) 
     138                  then # if fan was stopped start it using a safe value 
    133139                        echo $minsa > $pwmo 
    134140                        sleep 1 
    135141                  fi 
    136142                fi 
    137                 echo $pwmval > $pwmo 
     143                echo $pwmval > $pwmo # write new value to pwm output 
    138144                fcvcount=$fcvcount+1 
    139145        done 
    140146} 
    141147 
     148# main loop calling the main function at specified intervals 
    142149while true 
    143150do