Skip to content

Commit

Permalink
1.修改风扇的配置方式以适配多风扇和rogally
Browse files Browse the repository at this point in the history
2.更新前端代码适配多风扇
3.在前端限制控制和转速的写入顺序,先写入转速再写入控制。
4.当转速变化超过3%时,才设置一次转速,而不是每秒设置一次,减少风扇的写入次数
  • Loading branch information
Gawah committed Dec 14, 2023
1 parent 1151878 commit 8bf8d60
Show file tree
Hide file tree
Showing 8 changed files with 963 additions and 630 deletions.
416 changes: 261 additions & 155 deletions backend/config.py

Large diffs are not rendered by default.

592 changes: 383 additions & 209 deletions backend/fan.py

Large diffs are not rendered by default.

30 changes: 1 addition & 29 deletions backend/sysInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import asyncio
from ec import EC
from config import logging,SH_PATH,PRODUCT_NAME
from config import FAN_GPUTEMP_PATH,FAN_CPUTEMP_PATH,GPU_DEVICE_PATH
from config import GPU_DEVICE_PATH
from helpers import get_user

cpu_busyPercent = 0
Expand Down Expand Up @@ -120,34 +120,6 @@ def get_language(self):
logging.error(e)
return self._language


def get_gpuTemp(self):
try:
global FAN_GPUTEMP_PATH
if(FAN_GPUTEMP_PATH==""):
hwmon_path="/sys/class/hwmon"
hwmon_files=os.listdir(hwmon_path)
for file in hwmon_files:
path=hwmon_path+"/"+file
name = open(path+"/name").read().strip()
if(name=="amdgpu"):
FAN_GPUTEMP_PATH=path+"/temp1_input"
temp = int(open(FAN_GPUTEMP_PATH).read().strip())
logging.debug(f"获取gpu温度:{temp}")
return temp
except Exception as e:
logging.error(f"获取gpu温度异常:{e}")
return -1

def get_cpuTemp(self):
try:
temp = int(open(FAN_CPUTEMP_PATH).read().strip())
logging.debug(f"获取cpu温度:{temp}")
return temp
except Exception as e:
logging.error(f"获取cpu温度异常:{e}")
return -1

def updateCpuData(self):
global cpu_DataErrCnt
global cpu_busyPercent
Expand Down
40 changes: 15 additions & 25 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,61 +67,51 @@ async def get_language(self):
logging.error(e)
return ""

async def get_fanRPM(self):
async def get_fanRPM(self,index):
try:
return fanManager.get_fanRPM()
return fanManager.get_fanRPM(index)
except Exception as e:
logging.error(e)
return 0

async def get_fanRPMPercent(self):
async def get_fanRPMPercent(self,index):
try:
return fanManager.get_fanRPMPercent()
return fanManager.get_fanRPMPercent(index)
except Exception as e:
logging.error(e)
return 0

async def get_fanTemp(self):
async def get_fanTemp(self,index):
try:
gpuTemp = sysInfoManager.get_gpuTemp()
if gpuTemp!=-1:
return gpuTemp
return sysInfoManager.get_cpuTemp()
return fanManager.get_fanTemp(index)
except Exception as e:
logging.error(e)
return 0

async def get_fanIsAuto(self):
async def get_fanIsAuto(self,index):
try:
return fanManager.get_fanIsAuto()
return fanManager.get_fanIsAuto(index)
except Exception as e:
logging.error(e)
return 0

async def get_fanMAXRPM(self):
async def get_fanConfigList(self):
try:
return fanManager.get_fanMAXRPM()
return fanManager.get_fanConfigList()
except Exception as e:
logging.error(e)
return 0

async def get_fanIsAdapted(self):
try:
return fanManager.get_fanIsAdapted()
except Exception as e:
logging.error(e)
return 0
return []

def set_fanAuto(self, value:bool):
def set_fanAuto(self, index:int, value:bool):
try:
return fanManager.set_fanAuto(value)
return fanManager.set_fanAuto(index,value)
except Exception as e:
logging.error(e)
return False

def set_fanPercent(self, value:int):
def set_fanPercent(self,index:int, value:int):
try:
return fanManager.set_fanPercent(value)
return fanManager.set_fanPercent(index,value)
except Exception as e:
logging.error(e)
return False
Expand Down
Loading

0 comments on commit 8bf8d60

Please sign in to comment.