@@ -24,6 +24,9 @@ public LegacyConsistencyModeHandler(Core core, State state, FanController fanCon
24
24
/// <summary>
25
25
/// Consistency mode logic; lock the fans if temperature and RPM thresholds are met.
26
26
/// </summary>
27
+ static int cpu_cool_loops = 0 ;
28
+ const short CPU_COOL_DELAY = 5 ;
29
+
27
30
public override void RunConsistencyModeLogic ( )
28
31
{
29
32
if ( _core . LowerTemperatureThreshold != null && _core . UpperTemperatureThreshold != null && _core . RpmThreshold != null )
@@ -38,8 +41,16 @@ public override void RunConsistencyModeLogic()
38
41
{
39
42
if ( _state . Fan1Rpm == 0 && ( ! _state . Fan2Present || _state . Fan2Rpm == 0 ) )
40
43
{
41
- thresholdsMet = false ;
42
- _state . ConsistencyModeStatus = string . Format ( "风扇未启动,等待EC激活{0}风扇" , _state . Fan2Present ? "全部" : "" ) ; // Waiting for embedded controller to activate the fan{0}", _state.Fan2Present ? "s" : string.Empty);
44
+ if ( ! _core . EnableStopFan ||
45
+ LegacyConsistencyModeHandler . cpu_cool_loops <= 0 )
46
+ {
47
+ thresholdsMet = false ;
48
+ _state . ConsistencyModeStatus = string . Format ( "风扇未启动,等待EC激活{0}风扇" , _state . Fan2Present ? "全部" : "" ) ; // Waiting for embedded controller to activate the fan{0}", _state.Fan2Present ? "s" : string.Empty);
49
+ }
50
+ else
51
+ {
52
+ _state . ConsistencyModeStatus = string . Format ( "风扇未启动,自动调节等待中..." ) ;
53
+ }
43
54
}
44
55
else
45
56
{
@@ -121,7 +132,9 @@ public override void RunConsistencyModeLogic()
121
132
_fanController . SetFanLevel ( FanLevel . Medium , FanIndex . AllFans ) ;
122
133
_state . ConsistencyModeStatus = "温度在设定范围内,但风扇速度超过设定限值,尝试保持中速" ;
123
134
}
124
- else if ( is_cpu_cool )
135
+ else if ( is_cpu_cool &&
136
+ LegacyConsistencyModeHandler . cpu_cool_loops >= _core . CpuCoolDelay &&
137
+ _core . EnableStopFan )
125
138
{
126
139
_fanController . SetFanLevel ( FanLevel . Off , FanIndex . AllFans ) ;
127
140
_state . ConsistencyModeStatus = "温度低于下限,但风扇速度超过设定限值,尝试关闭风扇" ;
@@ -132,11 +145,14 @@ public override void RunConsistencyModeLogic()
132
145
}
133
146
134
147
//if (is_cpu_cool) thresholdsMet = false;
148
+ if ( is_cpu_warm || ! thresholdsMet ) LegacyConsistencyModeHandler . cpu_cool_loops = 0 ;
135
149
136
150
if ( thresholdsMet )
137
151
{
138
152
if ( ! is_cpu_cool )
139
153
{
154
+ LegacyConsistencyModeHandler . cpu_cool_loops -= 1 ;
155
+
140
156
if ( _state . EcFanControlEnabled )
141
157
{
142
158
_state . EcFanControlEnabled = false ;
@@ -153,11 +169,36 @@ public override void RunConsistencyModeLogic()
153
169
}
154
170
else
155
171
{
156
- if ( ! _state . EcFanControlEnabled )
172
+ if ( LegacyConsistencyModeHandler . cpu_cool_loops < 0 )
173
+ LegacyConsistencyModeHandler . cpu_cool_loops = 0 ;
174
+ LegacyConsistencyModeHandler . cpu_cool_loops += 1 ;
175
+
176
+ if ( ! _state . EcFanControlEnabled &&
177
+ ( ! _core . EnableStopFan || LegacyConsistencyModeHandler . cpu_cool_loops < _core . CpuCoolDelay ) )
157
178
{
158
179
_state . EcFanControlEnabled = true ;
159
180
_fanController . EnableAutomaticFanControl ( ) ;
160
181
_state . ConsistencyModeStatus = "温度低于下限,等待减小风速" ;
182
+ _core . TrayIconColor = TrayIconColor . Blue ;
183
+ }
184
+ else if ( LegacyConsistencyModeHandler . cpu_cool_loops >= _core . CpuCoolDelay ) // stop fan after cpu was cooling for 15 secs
185
+ {
186
+ // EC did control the fan speed and cpu has been kept on cooling for a longer, then we'll try to shutdown the fan.
187
+ if ( _core . EnableStopFan && ( _state . Fan1Rpm > 0 || ( _state . Fan2Present && _state . Fan2Rpm > 0 ) ) )
188
+ {
189
+ _state . EcFanControlEnabled = false ;
190
+ _fanController . DisableAutomaticFanControl ( ) ;
191
+ _fanController . SetFanLevel ( FanLevel . Off , FanIndex . AllFans ) ;
192
+ _state . ConsistencyModeStatus = "温度低于下限,尝试关闭风扇" ;
193
+ _core . TrayIconColor = TrayIconColor . Blue ;
194
+ }
195
+ }
196
+ //else
197
+ {
198
+ if ( _state . Fan1Rpm > 0 || ( _state . Fan2Present && _state . Fan2Rpm > 0 ) )
199
+ _core . TrayIconColor = TrayIconColor . Blue ;
200
+ else
201
+ _core . TrayIconColor = TrayIconColor . Gray ;
161
202
}
162
203
}
163
204
}
0 commit comments