Skip to content

Commit 143fb77

Browse files
committed
Minor fixes
1 parent c245514 commit 143fb77

File tree

5 files changed

+8
-26
lines changed

5 files changed

+8
-26
lines changed

FanControl++.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static BOOL MainThread(HWND hWnd) noexcept(false) {
183183
update_average_temperature(temp);
184184

185185
if (toggle_change_fan_speed) {
186-
int perc = calc_fan_percent(current_mode);
186+
float perc = calc_fan_percent(current_mode);
187187
if (perc < 0) _dErr(_ts(L"[Thread] Invalid fan percent!"));
188188
else asus_control.set_fan_speed(perc);
189189
}

controller.cpp

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ bool AsusDLL::set_fan_test_mode(char mode)
7474
set_fan_idx(fanIdx);
7575
FanTestMode set_fan_test_mode = (FanTestMode)GetProcAddress(asus_dll, "HealthyTable_SetFanTestMode");
7676
set_fan_test_mode(mode);
77-
Sleep(50);
7877
}
7978

8079
current_fan_test_mode = mode;
@@ -103,39 +102,23 @@ bool AsusDLL::set_fan_speed_idx(byte value, byte fanIdx = 0)
103102
return success(_ts(L"Set fan speed #") + _ts(fanIdx) + _ts(L" to ") + _ts(value), false);
104103
}
105104

106-
bool AsusDLL::set_fan_speed(int percent)
105+
bool AsusDLL::set_fan_speed(float percent)
107106
{
108107
if (!init_status) return failed();
109108

110109
// wont change if the delta is too small
111110
if (abs(AsusDLL::current_fan_percent - percent) <= 1) return success();
112111

113112
// set to 0 if the percent is too small
114-
if (percent < 20) percent = 0;
113+
if (percent < 10) percent = 0;
115114

116-
inipp::Ini<wchar_t> settings;
117-
read_settings(settings);
118-
int update_interval = 2000;
119-
inipp::extract(settings.sections[L"General"][L"UpdateInterval"], update_interval);
120-
settings.clear();
121-
122-
// soften the curve e.g. not change the speed too fast
123-
float delta = 5.0f * update_interval / 1000; // not faster than 5% per second
124-
125-
if (abs(AsusDLL::current_fan_percent - percent) >= delta) { // if the delta is big enough, change it
126-
if (AsusDLL::current_fan_percent < percent) AsusDLL::current_fan_percent += delta;
127-
else AsusDLL::current_fan_percent -= delta;
128-
}
129-
else { // if the delta is too small, just set it to the target
130-
AsusDLL::current_fan_percent = percent;
131-
}
115+
AsusDLL::current_fan_percent = percent;
132116

133117
byte value = max((byte)1, (byte)(AsusDLL::current_fan_percent / 100.0f * 255));
134118

135119
int fan_cnt = AsusDLL::get_fan_count();
136120
for (byte fanIdx = 0; fanIdx < fan_cnt; ++fanIdx) {
137121
if (!AsusDLL::set_fan_speed_idx(value, fanIdx)) return failed();
138-
Sleep(50);
139122
}
140123
return success(_ts(L"Set fan speed to ") + _ts(value), true);
141124
}
@@ -177,7 +160,6 @@ std::vector<int> AsusDLL::get_fan_speed()
177160
int val = AsusDLL::get_fan_speed_idx(fanIdx);
178161
if (val == -1) break;
179162
fan_speed_list.push_back(val);
180-
Sleep(50);
181163
}
182164

183165
last_update_fan_speed = convert_to_ull(st);
@@ -200,7 +182,7 @@ ULONG AsusDLL::get_thermal()
200182
TherGPU thermal_gpu = (TherGPU)GetProcAddress(asus_dll, "Thermal_Read_GpuTS1L_Temperature");
201183
current_cpu_thermal = thermal_cpu();
202184
current_gpu_thermal = thermal_gpu();
203-
current_combined_thermal = max(current_cpu_thermal, current_gpu_thermal);
185+
current_combined_thermal = max(current_cpu_thermal, current_gpu_thermal*5/4); // GPU overheats faster than CPU, but not too much
204186
last_update_thermal = convert_to_ull(st);
205187

206188
return current_combined_thermal;

controller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AsusDLL {
2929
public:
3030
AsusDLL();
3131
~AsusDLL() noexcept(false);
32-
bool set_fan_speed(int percent);
32+
bool set_fan_speed(float percent);
3333
bool set_fan_test_mode(char mode);
3434
int get_fan_speed_idx(byte fanIdx);
3535
std::vector<int> get_fan_speed();

temp_handle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ float get_average_temperature() {
9797
return (1.0f * total_temp) / temp_history.size();
9898
}
9999

100-
ULONG calc_fan_percent(int mode)
100+
float calc_fan_percent(int mode)
101101
{
102102
float temperature = get_average_temperature();
103103
inipp::Ini<wchar_t> settings;

temp_handle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "settings.h"
77
#include <queue>
88

9-
ULONG calc_fan_percent(int mode);
9+
float calc_fan_percent(int mode);
1010
void update_average_temperature(ULONG temperature);
1111
bool validator(std::wstring& str);
1212
bool validator(wchar_t* str);

0 commit comments

Comments
 (0)