You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: temp.sh
+3-58Lines changed: 3 additions & 58 deletions
Original file line number
Diff line number
Diff line change
@@ -113,54 +113,29 @@ re_elem() {
113
113
}
114
114
loop_cmds() {
115
115
get_temp
116
-
case${cur_t#-}in
117
-
''|*[!0-9]*) cur_t=$ot ;;
118
-
esac
119
116
if [ "$cur_t"-ne"$ot" ];then
120
117
# Calculate difference and make sure it's positive
121
118
if [ "$cur_t"-le"$ot" ];then
122
119
tdiff="$((ot-cur_t))"
123
-
decrease="1"
124
120
else
125
121
tdiff="$((cur_t-ot))"
126
-
decrease="0"
127
122
fi
128
-
if [ "$tdiff"-ge"$chd" ]|| [ "$equation_mode"-eq"1" ] || [ "$smooth_decrease"-eq"1" ];then# if the temperature difference is big enough or equation-mode is active
123
+
if [ "$tdiff"-ge"$chd" ];then
129
124
if [ "$cur_t"-lt"$mnt" ];then
130
125
new_spd="0"; otl="-1"
131
126
elif [ "$cur_t"-lt"$mxt" ];then
132
127
tl=0
133
128
forarr_tin$tc;do
134
-
if [ "$cur_t"-le"$((arr_t-2))" ];then
129
+
if [ "$cur_t"-le"$arr_t" ];then
135
130
break
136
-
elif [ "$cur_t"-ge"$arr_t" ];then
131
+
else
137
132
tl=$((tl+1))
138
133
fi
139
134
done
140
135
if [ "$tl"-ne"$otl" ];then
141
136
arr="$fc"; n="$tl"; re_elem
142
137
new_spd="$elem"; otl="$tl"
143
138
fi
144
-
if [[ "$equation_mode"-eq"1" ]];then# if equation-mode is on
145
-
eval equationWithTemp=$equation
146
-
fanSpeed=$(printf "%.0f"$(bc <<<$equationWithTemp))# calculate the needed fan speed and round to integer
147
-
if [[ "$fanSpeed"-lt"100"&&"$fanSpeed"-gt"0" ]];then# check if calculated fan speed is between 0 and 100
148
-
new_spd=$fanSpeed
149
-
fi
150
-
fi
151
-
if [[ "$smooth_decrease"-eq"1" ]];then# if smooth-decrease is on
152
-
if [ "$decrease"-eq"1" ];then# and temperature is decreasing
153
-
if [ -z"$speedToDeclineFrom" ];then# if speedToDeclineFrom is empty (e.g. in the first cycle of the script)
154
-
speedToDeclineFrom="$new_spd"
155
-
fi
156
-
if [[ "$speedToDeclineFrom"-gt"$smooth_decrease_setpoint"&&"$speedToDeclineFrom"-gt"0" ]];then# if current fan speed is greater than setpoint
157
-
speedToDeclineFrom=$((speedToDeclineFrom-1))# decrease the fan-speed
158
-
fi
159
-
new_spd="$speedToDeclineFrom"
160
-
else
161
-
speedToDeclineFrom="$new_spd"# if temperature is not decreasing, update the value for next cycle
162
-
fi
163
-
fi
164
139
else
165
140
new_spd="100"
166
141
fi
@@ -202,16 +177,10 @@ set_stuff() {
202
177
chd="$check_diff1"
203
178
mnt="$min_t"; mxt="$max_t"
204
179
tc="$tcurve"; fc="$fcurve"
205
-
equation=$equation1# for fan1
206
180
else
207
181
chd="$check_diff2"
208
182
mnt="$min_t2"; mxt="$max_t2"
209
183
tc="$tcurve2"; fc="$fcurve2"
210
-
equation=$equation2# for fan2
211
-
fi
212
-
# check if equation_mode is being used
213
-
if [[ "$equation_mode"=="1" ]];then
214
-
mxt=$equation_max# set the maximum temp, as tcurve is not being used in this case
0 commit comments