Skip to content

Commit 481c85d

Browse files
author
AhmedYasserrr
committed
refactor: rename fan control functions for clarity
1 parent d36c050 commit 481c85d

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/core/libectool.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ bool is_on_ac() {
142142
return ac_present;
143143
}
144144

145-
void pause_fan_control() {
145+
void auto_fan_control() {
146146
if (libectool_init() < 0)
147147
fprintf(stderr, "Failed initializing EC connection\n");
148148

@@ -154,23 +154,23 @@ void pause_fan_control() {
154154
libectool_release();
155155
}
156156

157-
void set_fan_speed(int speed) {
157+
void set_fan_duty(int duty) {
158158
if (libectool_init() < 0)
159159
fprintf(stderr, "Failed initializing EC connection\n");
160160

161161
struct ec_params_pwm_set_fan_duty_v0 p_v0;
162162
int rv;
163163

164-
if (speed < 0 || speed > 100) {
165-
fprintf(stderr, "Error: Fan speed must be between 0 and 100.\n");
164+
if (duty < 0 || duty > 100) {
165+
fprintf(stderr, "Error: Fan duty cycle must be between 0 and 100.\n");
166166
return;
167167
}
168168

169-
p_v0.percent = speed;
169+
p_v0.percent = duty;
170170
rv = ec_command(EC_CMD_PWM_SET_FAN_DUTY, 0, &p_v0, sizeof(p_v0),
171171
NULL, 0);
172172
if (rv < 0)
173-
fprintf(stderr, "Error: Can't set speed\n");
173+
fprintf(stderr, "Error: Can't set duty cycle\n");
174174

175175
libectool_release();
176176
}

src/core/libectool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ void libectool_release();
1313

1414
// API functions to expose
1515
bool is_on_ac();
16-
void pause_fan_control();
17-
void set_fan_speed(int speed);
16+
void auto_fan_control();
17+
void set_fan_duty(int duty);
1818
float get_max_temperature();
1919
float get_max_non_battery_temperature();
2020

tests/test_libectool.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ int main() {
3434
break;
3535
}
3636
case 2:
37-
printf("Pausing fan control...\n");
38-
pause_fan_control();
37+
printf("Enable automatic fan control...\n");
38+
auto_fan_control();
3939
break;
4040
case 3:
4141
printf("Enter fan speed (0-100): ");
4242
if (scanf("%d", &speed) == 1) {
43-
set_fan_speed(speed);
43+
set_fan_duty(speed);
4444
} else {
4545
printf("Invalid speed.\n");
4646
// clear invalid input

0 commit comments

Comments
 (0)