Skip to content

Commit

Permalink
fix update_fan_max_value
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed Oct 1, 2024
1 parent 655b267 commit a46cdc5
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions backend/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ def update_fan_max_value(self, cpu_temp: int):
current_rpm = self.get_fanRPM(index)
max_value = fan_config.pwm_value_max
cup_temp = cpu_temp if cpu_temp > 0 else self.get_fanTemp(index)
# 如果 current_rpm 和 fan_config.FAN_RPMVALUE_MAX 相差大于 5%, 则更新 max_value
# 更新 pwm_value_max
if (
cup_temp > 75000 and (max_value - max_value) / int(max_value) > 0.05
) or (int(current_rpm) - max_value) / int(max_value) > 0.05:
((int(current_rpm) - max_value) / int(max_value)) > 0.05
and current_rpm < 2 * max_value
and cup_temp > 75000
):
logging.info(
f"cup_temp {cup_temp}, 风扇{index} 当前转速已达到最大值, 更新最大值: {max_value} -> {current_rpm}"
)
Expand Down Expand Up @@ -281,8 +283,14 @@ def __parse_fan_configuration_EC(self):
# 判断是否配置好ec(控制地址、读和写至少各有一种方法,最大写入和最大读取必须有配置数值)
fc.is_ec_configured = (
(fc.manual_offset is not None or fc.ram_manual_offset is not None)
and (fc.pwm_write_offset is not None or fc.ram_pwm_write_offset is not None)
and (fc.pwm_read_offset is not None or fc.ram_pwm_read_offset is not None)
and (
fc.pwm_write_offset is not None
or fc.ram_pwm_write_offset is not None
)
and (
fc.pwm_read_offset is not None
or fc.ram_pwm_read_offset is not None
)
and (fc.pwm_write_max != 0 and fc.pwm_value_max != 0)
)
if fc.is_ec_configured:
Expand Down

0 comments on commit a46cdc5

Please sign in to comment.