From 6ed045020cd453e73020535802a44df3214f2963 Mon Sep 17 00:00:00 2001 From: honjow Date: Mon, 25 Mar 2024 20:30:26 +0800 Subject: [PATCH] Fix GPD devices with expec --- backend/config.py | 6 ++---- backend/cpu.py | 10 +++++----- backend/fan.py | 14 +++++++++++++- main.py | 2 +- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/backend/config.py b/backend/config.py index 6062428..f8177cd 100755 --- a/backend/config.py +++ b/backend/config.py @@ -131,16 +131,14 @@ }, "pwm_write":{ "pwm_write_max":{ - "default":255, - "ONEXPLAYER F1":255, - "ONEXPLAYER F1 EVA-01":255 + "default":255 }, "pwm_write_path":"pwm1" }, "pwm_input":{ "hwmon_label":"oxpec", "pwm_read_path":"fan1_input", - "pwm_read_max": 5030 + "pwm_read_max": 6000 }, "temp_mode":0 }], diff --git a/backend/cpu.py b/backend/cpu.py index 3bcea5f..8a0c616 100755 --- a/backend/cpu.py +++ b/backend/cpu.py @@ -128,11 +128,11 @@ def set_cpuTDP(self, value: int): command = f"{sys_ryzenadj_path} -a {stapm_limit} -b {fast_minit} -c {slow_limit} -f {tctl_temp}" command_args = command.split() - logging.info(f"set_cpuTDP command: {command}") - logging.info(f"set_cpuTDP {value}") + logging.debug(f"set_cpuTDP command: {command}") + logging.debug(f"set_cpuTDP {value}") process = subprocess.run(command_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.stdout.decode('utf-8'), process.stderr.decode('utf-8') - logging.info(f"set_cpuTDP result:\n{stdout}") + logging.debug(f"set_cpuTDP result:\n{stdout}") if stderr: logging.error(f"set_cpuTDP error:\n{stderr}") @@ -145,7 +145,7 @@ def set_cpuTDP(self, value: int): def set_cpuOnline(self, value: int): try: - logging.info("set_cpuOnline {} {}".format(value,cpu_maxNum)) + logging.debug("set_cpuOnline {} {}".format(value,cpu_maxNum)) global enable_cpu_num enable_cpu_num = value @@ -167,7 +167,7 @@ def set_cpuOnline(self, value: int): # # cpu_num 作为索引, 取出对应的核心, 作为开启的最大 cpuid, 关闭大于最大 cpuid 的线程 max_enable_cpuid = self.cps_ids[enable_cpu_num - 1] - logging.info(f"enable_cpu_num {enable_cpu_num}, max_enable_cpuid {max_enable_cpuid}") + logging.debug(f"enable_cpu_num {enable_cpu_num}, max_enable_cpuid {max_enable_cpuid}") if enable_cpu_num is not None and enable_cpu_num < len(enabled_cores): for processor_id, core_id in cpu_topology.items(): if int(core_id) > max_enable_cpuid: diff --git a/backend/fan.py b/backend/fan.py index ac3fcbd..846e07b 100755 --- a/backend/fan.py +++ b/backend/fan.py @@ -118,7 +118,7 @@ def parse_fan_configuration(self): #若已获取到风扇hwmon信息则不再获取ec信息 if len(self.fan_config_list) > 0: - logging.debug(f"已获取到风扇hwmon信息:{[config.FAN_HWMON_NAME for config in self.fan_config_list]}") + logging.info(f"已获取到风扇hwmon信息:{[config.FAN_HWMON_NAME for config in self.fan_config_list]}") else: logging.debug(f"未获取到风扇hwmon信息,开始获取风扇ec信息") #转化ec信息 @@ -287,6 +287,13 @@ def set_fanAuto(self, index:int, value:bool): return False else: fanIsManual = enable_manual_value + + # GPD 设备没有实际的单独的控制位。但是在oxpec中有控制位,写入手动控制时会将转速设置为 70%。所以添加判断,只在需要时写入控制位 + currentFanIsManual = int(open(hwmon_pwm_enable_path).read().strip()) + if currentFanIsManual == fanIsManual: + logging.debug(f"currentFanIsManual:{currentFanIsManual} fanIsManual:{fanIsManual} 无需写入") + return True + open(hwmon_pwm_enable_path,'w').write(str(fanIsManual)) logging.debug(f"写入hwmon数据 写入hwmon地址:{hwmon_pwm_enable_path} 写入风扇是否控制:{fanIsManual}") return True @@ -357,6 +364,11 @@ def set_fanPercent(self, index:int,value:int): try: if is_find_hwmon and hwmon_mode == 0: fanWriteValue = max(min(int(value/100*rpm_write_max),rpm_write_max),0) + currentVal = int(open(hwmon_pwm_path).read().strip()) + # 转速相差小于5%时不写入 + if currentVal > 0 and abs(currentVal - fanWriteValue) / currentVal < 0.05: + logging.debug(f"当前风扇转速{currentVal} 与目标转速{fanWriteValue} 相差小于5% 不写入") + return True open(hwmon_pwm_path,'w').write(str(fanWriteValue)) logging.debug(f"写入hwmon数据 写入hwmon地址:{hwmon_pwm_path} 风扇转速百分比{value} 风扇最大值{rpm_write_max} 风扇转速写入值:{fanWriteValue}") return True diff --git a/main.py b/main.py index 998a4f2..09cb94b 100755 --- a/main.py +++ b/main.py @@ -30,7 +30,7 @@ async def get_settings(self): async def set_settings(self, settings): self.settings.setSetting(CONFIG_KEY, settings) - logging.info(f"save Settings: {settings}") + # logging.info(f"save Settings: {settings}") return True async def _unload(self):