├── Esp32 ├── Wifi通信版本 │ └── main.py └── 串口通信版本 │ └── main.py ├── Image ├── 成品展示1.jpg ├── 成品展示2.jpg ├── 接线图.png ├── 硬件清单.jpg └── 组装细节.jpg ├── README.md ├── 外壳3D模型 ├── CpuGpuMonitor.obj └── CpuGpuMonitor_NoLogo.obj ├── 客户端 ├── .vs │ └── CpuRamGet │ │ └── DesignTimeBuild │ │ └── .dtbcache.v2 ├── App.config ├── HardwareMonitor.csproj ├── HardwareMonitor.csproj.user ├── HardwareMonitor.sln ├── LibreHardwareMonitorLib.dll ├── Program.cs └── Properties │ ├── AssemblyInfo.cs │ ├── app.manifest │ └── launchSettings.json └── 表盘PSD源文件 ├── 表盘背景.psd ├── 表盘背景2233_CPU.jpg └── 表盘背景2233_RAM.jpg /Esp32/Wifi通信版本/main.py: -------------------------------------------------------------------------------- 1 | from machine import I2C, Pin 2 | import time 3 | from machine import Pin,DAC 4 | import utime, math 5 | import _thread 6 | import socket 7 | import sys 8 | 9 | def getTime(): 10 | t = time.gmtime() 11 | timeY = str(t[0]) #年 12 | timeM = str(t[1]) #月 13 | timeD = str(t[2]) #日 14 | timeHour = str(t[3]) #时 15 | timeMinute = str(t[4]) #分 16 | timeSecond = str(t[5]) #秒 17 | return str(timeY+"/"+timeM+"/"+timeD +" "+timeHour+":"+timeMinute+":"+timeSecond) 18 | 19 | def do_connect(): 20 | global addressIp 21 | try: 22 | import network 23 | wlan = network.WLAN(network.STA_IF) 24 | wlan.active(False) #先将Wifi断开,方便模拟断网调试 25 | wlan.active(True) 26 | if not wlan.isconnected(): 27 | print('connecting to network...') 28 | wlan.connect('Wifi账号', '密码') 29 | while not wlan.isconnected():#没有返回True将循环等待 30 | pass 31 | print('network config:', wlan.ifconfig()) 32 | addressIp = str(wlan.ifconfig()) 33 | except: 34 | pass 35 | 36 | def lerp(v1,v2,d): 37 | return v1 * (1 - d) + v2 * d 38 | 39 | def dacThread( threadName, delay): 40 | global ram_value 41 | ramlerp = 0 42 | i = 0.0 43 | while(True): 44 | i += 0.01 45 | ramlerp = lerp(ramlerp,ram_value,i) 46 | dac25.write(int(ramlerp)) 47 | if(ramlerp >= ram_value): 48 | i = 0.0 49 | time.sleep(0.015) 50 | 51 | 52 | def dacThread2( threadName, delay): 53 | global cpu_value 54 | global ram_value 55 | cpulerp = 0 56 | i = 0.0 57 | countZero = 0 58 | cpu_valueOld = 0 59 | ram_valueOld = 0 60 | while(True): 61 | i += 0.01 62 | cpulerp = lerp(cpulerp,cpu_value,i) 63 | dac26.write(int(cpulerp)) 64 | if(cpulerp >= cpu_value): 65 | i = 0.0 66 | time.sleep(0.015) 67 | 68 | #如果在1.5秒内数值都相同那么归零表值 69 | countZero += 1 70 | if(countZero == 100): 71 | if(cpu_value == cpu_valueOld and ram_value == ram_valueOld): 72 | ram_value = 0 73 | cpu_value = 0 74 | cpu_valueOld = cpu_value 75 | ram_valueOld = ram_value 76 | countZero = 0 77 | 78 | 79 | 80 | def dacThread3( threadName, delay): 81 | global ram_value 82 | global cpu_value 83 | while(True): 84 | try: 85 | #print(getTime() + " 开始监听...") 86 | data,addr=s.recvfrom(32) 87 | stringKey = data.decode("utf-8") 88 | array_value = stringKey.split(",") 89 | cpu_value = int(array_value[1]) 90 | ram_value = int(array_value[0]) 91 | #print(getTime()+" 接收信息..."+ stringKey) 92 | time.sleep(0.1) 93 | except: 94 | #print(getTime()+" 连接断开...") 95 | time.sleep(0.1) 96 | 97 | 98 | cpu_value = 0 99 | ram_value = 0 100 | 101 | #初始化DAC 102 | dac_pin25 = Pin(25, Pin.OUT) 103 | dac_pin26 = Pin(26, Pin.OUT) 104 | 105 | dac25 = DAC(dac_pin25) 106 | dac26 = DAC(dac_pin26) 107 | dac25.write(0) 108 | dac26.write(0) 109 | 110 | #连接Wifi 111 | do_connect() 112 | 113 | #创建socks,监听4999 114 | port = 4999 115 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 116 | 117 | addressIp = addressIp.replace("(","") 118 | addressIp = addressIp.replace(")","") 119 | addressIp = addressIp.replace("'","") 120 | addressIp = addressIp.split(",") 121 | s.bind((addressIp[0], port)) 122 | 123 | _thread.start_new_thread( dacThread, ("Thread_1", 1, ) ) 124 | _thread.start_new_thread( dacThread2, ("Thread_2", 2, ) ) 125 | _thread.start_new_thread( dacThread3, ("Thread_3", 3, ) ) -------------------------------------------------------------------------------- /Esp32/串口通信版本/main.py: -------------------------------------------------------------------------------- 1 | from machine import I2C, Pin 2 | import time 3 | from machine import Pin,DAC 4 | import utime, math 5 | import select 6 | import _thread 7 | import socket 8 | import sys 9 | 10 | 11 | def lerp(v1,v2,d): 12 | return v1 * (1 - d) + v2 * d 13 | 14 | def dacThread( threadName, delay): 15 | global ram_value 16 | ramlerp = 0 17 | i = 0.0 18 | while(True): 19 | i += 0.01 20 | ramlerp = lerp(ramlerp,ram_value,i) 21 | dac25.write(int(ramlerp)) 22 | if(ramlerp >= ram_value): 23 | i = 0.0 24 | time.sleep(0.015) 25 | 26 | 27 | def dacThread2( threadName, delay): 28 | global cpu_value 29 | global ram_value 30 | cpulerp = 0 31 | i = 0.0 32 | countZero = 0 33 | cpu_valueOld = 0 34 | ram_valueOld = 0 35 | while(True): 36 | i += 0.01 37 | cpulerp = lerp(cpulerp,cpu_value,i) 38 | dac26.write(int(cpulerp)) 39 | if(abs(cpulerp - cpu_value) <3): 40 | i = 0.0 41 | time.sleep(0.015) 42 | 43 | #如果在1.5秒内数值都相同那么归零表值 44 | countZero += 1 45 | if(countZero == 500): 46 | if(cpu_value == cpu_valueOld and ram_value == ram_valueOld): 47 | ram_value = 0 48 | cpu_value = 0 49 | cpu_valueOld = cpu_value 50 | ram_valueOld = ram_value 51 | countZero = 0 52 | 53 | 54 | cpu_value = 0 55 | ram_value = 0 56 | 57 | #初始化DAC 58 | dac_pin25 = Pin(25, Pin.OUT) 59 | dac_pin26 = Pin(26, Pin.OUT) 60 | 61 | dac25 = DAC(dac_pin25) 62 | dac26 = DAC(dac_pin26) 63 | dac25.write(0) 64 | dac26.write(0) 65 | 66 | p22 = Pin(2, Pin.OUT) 67 | 68 | p = select.poll() 69 | p.register( 70 | sys.stdin, # 检测标准输入 (REPL) 71 | select.POLLIN # 检查是否有数据待读取 72 | ) 73 | 74 | _thread.start_new_thread( dacThread, ("Thread_1", 1, ) ) 75 | _thread.start_new_thread( dacThread2, ("Thread_2", 2, ) ) 76 | 77 | while(True): 78 | try: 79 | readInfo = sys.stdin.read(8) 80 | print(str(readInfo)) 81 | array_value = readInfo.split(".")[0].split(",") 82 | cpu_value = int(array_value[1]) 83 | ram_value = int(array_value[0]) 84 | time.sleep(0.1) 85 | except: 86 | #print(getTime()+" 连接断开...") 87 | time.sleep(0.1) 88 | -------------------------------------------------------------------------------- /Image/成品展示1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShaderFallback/CpuRamGet/88e91a7d2cfa92ac03cfb461e7eaee66dffe7aba/Image/成品展示1.jpg -------------------------------------------------------------------------------- /Image/成品展示2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShaderFallback/CpuRamGet/88e91a7d2cfa92ac03cfb461e7eaee66dffe7aba/Image/成品展示2.jpg -------------------------------------------------------------------------------- /Image/接线图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShaderFallback/CpuRamGet/88e91a7d2cfa92ac03cfb461e7eaee66dffe7aba/Image/接线图.png -------------------------------------------------------------------------------- /Image/硬件清单.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShaderFallback/CpuRamGet/88e91a7d2cfa92ac03cfb461e7eaee66dffe7aba/Image/硬件清单.jpg -------------------------------------------------------------------------------- /Image/组装细节.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShaderFallback/CpuRamGet/88e91a7d2cfa92ac03cfb461e7eaee66dffe7aba/Image/组装细节.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## PC Status Physical Monitoring Table 2 | 3 | - **1. All materials are not for commercial use; please credit the source when sharing [Hyperlink]** 4 | - **2. The copyright of the dial images belongs to the original author** 5 | - **3. Adjust the size of the 3D print model according to the slicer software's units (the units used during creation are centimeters). It is recommended to use KT board to make the shell, as it is more cost-effective** 6 | (Note: If using this 3D model to print the shell, you need to purchase a development board without soldered headers to fit it in) 7 | - **4. Use 300 DPI when creating the dial, and make sure to set 300 DPI when printing. Arrange the layout according to the printer's print size** 8 | - **5. The voltmeter model in the video is 91C4. The maximum voltage range should be less than 3.3V** 9 | - **6. The esp32 firmware uses MicroPython; please download the latest version from the official website** 10 | - **7. Before downloading the program, remember to modify the WiFi name and password in main.py. If the port does not conflict, keep the default 4999. No changes are needed for the serial version** 11 | - **8. Thonny IDE is recommended for flashing the firmware or downloading the program** 12 | - **9. You can use Windows to run the program automatically on startup** 13 | - **10. Create a basic task -> Set the trigger to "At startup" -> Start a program -> Browse to CpuRamGet.exe, and add parameters** 14 | (By default, the "console program" started by Task Scheduler will run in the background. Remember to uncheck "Stop the task if it runs longer than 3 days" in the settings and check "Run with highest privileges") 15 | - **Configurable parameter IDs (select 2 out of 6): 1 CPU Usage, 2 CPU Temperature, 3 Memory Usage, 4 GPU Usage, 5 GPU Memory Usage, 6 GPU Temperature** 16 | - **11. Download the CP210x Windows Drivers for the Esp32 USB development board serial driver** [CP210x Windows Drivers](https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers) 17 | 18 | - **. New USB serial communication support, no WiFi configuration needed** 19 | Go to My Computer -> Device Manager -> Ports to see your development board's port number. Use a baud rate of 115200 20 | USB serial example: com4 115200 1 500 1 2 21 | 22 | - **. If you have any questions, feel free to leave a comment under the video** 23 | [https://www.youtube.com/watch?v=8Lh_D1dhlAI](https://www.youtube.com/watch?v=8Lh_D1dhlAI) 24 | 25 | ### Have fun, everyone! 26 | 27 | ## PC 状态物理监控表 28 | - **1.全部资料请勿用作商业用途,转载请注明出处[超连接]** 29 | - **2.表盘图片版权归原作者所有** 30 | - **3.3D打印模型请根据切片软件单位放大或缩小 (制作时的单位是厘米), 推荐使用KT板制作外壳,成本更低** 31 | (注意如果使用这个3D模型打印外壳,开发板要购买没有焊接排针版本,才能安装进去) 32 | - **4.表盘制作时使用300 DPI,打印时注意设置300 DPI, 根据打印机画幅排版即可** 33 | - **5.视频中的电压表的型号是 91C4 ,电压最大量程要小于3.3V** 34 | - **6.esp32 固件采用MicroPython,请去官网下载最新** 35 | - **7.下载程序前请记得修改main.py 中的 Wifi 名和密码, 端口不冲突可保持默认4999串口版本无需修改** 36 | - **8.IDE 推荐使用 thonny 刷机 or 下载程序** 37 | - **9.开机自动运行可以使用 Windows <任务计划程序>** 38 | - **10.创建基本任务 -> 触发器设置为计算机启动时 -> 启动程序 -> 浏览到CpuRamGet.exe ,添加参数即可** 39 | (任务计划程序启动的 "控制台程序"默认会在后台运行,记得在设置里取消"运行超过3天停止任务选项",勾选使用管理员运行 ) 40 | - **可配置的参数ID(6选2): 1 CPU使用率, 2 CPU温度, 3 内存使用率, 4 GPU使用率, 5 GPU显存占用, 6 GPU温度** 41 | - **11.Esp32 USB 开发板的串口驱动下载 CP210x Windows Drivers** [CP210x Windows Drivers](https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers) 42 | 43 | - **.新增USB串口通信支持,无需配置Wifi** 44 | 我的电脑属性-> 设备管理器 -> 端口 -> 查看你开发板的端口号,波特率使用115200 45 | USB串口示例: com4 115200 1 500 1 2 46 | 47 | - **.有任何疑问欢迎在视频下留言** 48 | [www.bilibili.com/video/BV1jL4y1x7gx](https://www.bilibili.com/video/BV1jL4y1x7gx) 49 | 50 | - **.搜集的其他网友的实现** 51 | https://github.com/gitsang/loadoutput 52 | [https://space.bilibili.com/3490242](https://space.bilibili.com/3490242) 53 | [https://github.com/hanchengxu](https://github.com/hanchengxu) 54 | 55 | ### 祝大家玩的开心~ 56 | 57 | ![image](https://github.com/ShaderFallback/CpuRamGet/blob/main/Image/成品展示1.jpg) 58 | ![image](https://github.com/ShaderFallback/CpuRamGet/blob/main/Image/成品展示2.jpg) 59 | ![image](https://github.com/ShaderFallback/CpuRamGet/blob/main/Image/接线图.png) 60 | ![image](https://github.com/ShaderFallback/CpuRamGet/blob/main/Image/硬件清单.jpg) 61 | ![image](https://github.com/ShaderFallback/CpuRamGet/blob/main/Image/组装细节.jpg) 62 | -------------------------------------------------------------------------------- /客户端/.vs/CpuRamGet/DesignTimeBuild/.dtbcache.v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShaderFallback/CpuRamGet/88e91a7d2cfa92ac03cfb461e7eaee66dffe7aba/客户端/.vs/CpuRamGet/DesignTimeBuild/.dtbcache.v2 -------------------------------------------------------------------------------- /客户端/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /客户端/HardwareMonitor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {25B85514-8430-4BCB-9CD9-2CDF3E6C9C8A} 8 | Exe 9 | HardwareMonitor 10 | HardwareMonitor 11 | v4.7.2 12 | 512 13 | true 14 | 15 | false 16 | publish\ 17 | true 18 | Disk 19 | false 20 | Foreground 21 | 7 22 | Days 23 | false 24 | false 25 | true 26 | 0 27 | 1.0.0.%2a 28 | false 29 | true 30 | 31 | 32 | AnyCPU 33 | true 34 | full 35 | false 36 | bin\Debug\ 37 | DEBUG;TRACE 38 | prompt 39 | 4 40 | 41 | 42 | AnyCPU 43 | pdbonly 44 | true 45 | bin\Release\ 46 | TRACE 47 | prompt 48 | 4 49 | 50 | 51 | LocalIntranet 52 | 53 | 54 | true 55 | 56 | 57 | Properties\app.manifest 58 | 59 | 60 | 61 | .\LibreHardwareMonitorLib.dll 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | False 84 | .NET Framework 3.5 SP1 85 | false 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /客户端/HardwareMonitor.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 192.168.3.162 4999 1.03 800 1 4 5 | 6 | 7 | publish\ 8 | 9 | 10 | 11 | 12 | 13 | zh-CN 14 | false 15 | 16 | 17 | false 18 | 19 | -------------------------------------------------------------------------------- /客户端/HardwareMonitor.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31205.134 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HardwareMonitor", "HardwareMonitor.csproj", "{25B85514-8430-4BCB-9CD9-2CDF3E6C9C8A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {25B85514-8430-4BCB-9CD9-2CDF3E6C9C8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {25B85514-8430-4BCB-9CD9-2CDF3E6C9C8A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {25B85514-8430-4BCB-9CD9-2CDF3E6C9C8A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {25B85514-8430-4BCB-9CD9-2CDF3E6C9C8A}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {C49319BD-FD47-4073-8F04-3193E604E642} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /客户端/LibreHardwareMonitorLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShaderFallback/CpuRamGet/88e91a7d2cfa92ac03cfb461e7eaee66dffe7aba/客户端/LibreHardwareMonitorLib.dll -------------------------------------------------------------------------------- /客户端/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Management; 3 | using System.Diagnostics; 4 | using System.Threading; 5 | using System.Net.Sockets; 6 | using System.Text; 7 | using System.Net; 8 | using System.Collections.Generic; 9 | using System.IO.Ports; 10 | using System.Collections; 11 | using LibreHardwareMonitor.Hardware; 12 | 13 | namespace ConsoleApp1 14 | { 15 | public class Class1 16 | { 17 | static double useVoltage = 0; 18 | static int updateTime = 0; 19 | static int sendValueID_1 = 0; 20 | static int sendValueID_2 = 0; 21 | 22 | static string esp32Ip; 23 | static int esp32Port = 4999; 24 | static UdpClient udpClient = new UdpClient(); 25 | static Computer computer; 26 | 27 | static double cpuLoad = 0; 28 | static double cpuTemperature = 0; 29 | static double ramLoad = 0; 30 | static double gpuLoad = 0; 31 | static double gpuRamLoad = 0; 32 | static double gpuTemperature = 0; 33 | 34 | static IPAddress remoteIp; 35 | static IPEndPoint remotePoint; 36 | 37 | static SerialPort serialPort = new SerialPort(); 38 | static bool isWiredWireless = false; 39 | static string serialPortIndex = ""; 40 | static int baudRateValue = 115200; 41 | static string esp32ReadString = ""; 42 | 43 | static void Main(string[] args) 44 | { 45 | 46 | if (args.Length != 6) 47 | { 48 | Console.WriteLine("输入的配置项不正确!\n"); 49 | Console.WriteLine("【1】右键CpuRamGet.exe -> 创建快捷方式 -> 快捷方式右键属性 -> 目标 -> CpuRamGet.exe 尾部依照下列说明添加\n"); 50 | Console.WriteLine("【2】1.IP/串口号 2.端口号/波特率 3.电压表最大值(3.3V以内) 4.刷新时间(单位毫秒) 5.发送数据ID_1 6.发送数据ID_2\n"); 51 | Console.WriteLine("【3】可选的ID(6选2): 1 CPU使用率, 2 CPU温度, 3 内存使用率, 4 GPU使用率, 5 GPU显存占用, 6 GPU温度\n"); 52 | Console.WriteLine("注意:每项中间空格区分\n"); 53 | Console.WriteLine("\n无线示例: 192.168.1.199 2333 1 500 1 2"); 54 | Console.WriteLine("\nUSB串口示例: com4 115200 1 500 1 2"); 55 | Console.ReadKey(); 56 | return; 57 | } 58 | char[] switchString = "com".ToCharArray(); 59 | char[] switchString2 = "COM".ToCharArray(); 60 | int inquiryIndex = args[0].ToString().IndexOfAny(switchString); 61 | int inquiryIndex2 = args[0].ToString().IndexOfAny(switchString2); 62 | 63 | if (inquiryIndex == 0 || inquiryIndex2 == 0) 64 | { 65 | serialPortIndex = args[0]; 66 | baudRateValue = Convert.ToInt32(args[1]); 67 | isWiredWireless = true; 68 | } 69 | else 70 | { 71 | esp32Ip = args[0]; 72 | esp32Port = Convert.ToInt32(args[1]); 73 | } 74 | 75 | useVoltage = (255.0f / 3.30f) * Convert.ToDouble(args[2]); 76 | updateTime = Convert.ToInt32(args[3]); 77 | sendValueID_1 = Convert.ToInt32(args[4]); 78 | sendValueID_2 = Convert.ToInt32(args[5]); 79 | 80 | Init(); 81 | Thread thread = new Thread(SetEsp32); 82 | thread.Start(); 83 | Thread thread2 = new Thread(UpdateReceive); 84 | thread2.Start(); 85 | 86 | } 87 | 88 | static double RamapValue(double Value, double Low1Val, double High1Val, double Low2Val, double High2Val) 89 | { 90 | double re = (Value - Low1Val) * (High2Val - Low2Val) / (High1Val - Low1Val) + Low2Val; 91 | return re; 92 | } 93 | static void SetEsp32() 94 | { 95 | while (true) 96 | { 97 | Console.Clear(); 98 | 99 | foreach (var hardware in computer.Hardware) 100 | { 101 | hardware.Update(); 102 | 103 | if (hardware.HardwareType == HardwareType.Cpu) 104 | { 105 | foreach (var sensor in hardware.Sensors) 106 | { 107 | if (sensor.SensorType == SensorType.Load) 108 | { 109 | if (sensor != null && sensor.Value != null) 110 | { 111 | if (sensor.Name.Contains("Total")) 112 | { 113 | //总占用率 114 | cpuLoad = (double)sensor.Value; 115 | } 116 | } 117 | } 118 | 119 | if (sensor.SensorType == SensorType.Temperature) 120 | { 121 | if (sensor != null && sensor.Value != null) 122 | { 123 | //显示平均温度 124 | //不同CPU返回的Name不同 125 | if (sensor.Name.Contains("Average")) 126 | { 127 | cpuTemperature = (double)sensor.Value; 128 | } 129 | } 130 | } 131 | } 132 | } 133 | else if (hardware.HardwareType == HardwareType.Memory) 134 | { 135 | foreach (var sensor in hardware.Sensors) 136 | { 137 | if (sensor.SensorType == SensorType.Load) 138 | { 139 | if (sensor != null && sensor.Value != null) 140 | { 141 | ramLoad = (double)sensor.Value; 142 | } 143 | } 144 | } 145 | } //没有此显卡为空 146 | else if (hardware.HardwareType == HardwareType.GpuAmd) 147 | { 148 | foreach (var sensor in hardware.Sensors) 149 | { 150 | if (sensor.SensorType == SensorType.Load) 151 | { 152 | if (sensor != null && sensor.Value != null) 153 | { 154 | if (sensor.Index == 0) //总占用率 155 | { 156 | gpuLoad = (double)sensor.Value; 157 | } 158 | else if (sensor.Index == 4) //显存占用 159 | { 160 | gpuRamLoad = (double)sensor.Value; 161 | } 162 | } 163 | } 164 | if (sensor.SensorType == SensorType.Temperature) 165 | { 166 | if (sensor != null && sensor.Value != null) 167 | { 168 | if (sensor.Index == 0) //Gpu温度 169 | { 170 | gpuTemperature = (double)sensor.Value; 171 | } 172 | } 173 | } 174 | } 175 | } 176 | else if (hardware.HardwareType == HardwareType.GpuNvidia) 177 | { 178 | foreach (var sensor in hardware.Sensors) 179 | { 180 | if (sensor.SensorType == SensorType.Load) 181 | { 182 | if (sensor != null && sensor.Value != null) 183 | { 184 | if (sensor.Index == 0) //总占用率 185 | { 186 | gpuLoad = (double)sensor.Value; 187 | } 188 | else if (sensor.Index == 4) //显存占用 189 | { 190 | gpuRamLoad = (double)sensor.Value; 191 | } 192 | } 193 | } 194 | if (sensor.SensorType == SensorType.Temperature) 195 | { 196 | if (sensor != null && sensor.Value != null) 197 | { 198 | if (sensor.Index == 0) //总占用率 199 | { 200 | gpuTemperature = (double)sensor.Value; 201 | } 202 | } 203 | } 204 | } 205 | } 206 | } 207 | 208 | cpuLoad = Math.Round(cpuLoad,0); 209 | cpuTemperature = Math.Round(cpuTemperature, 0); 210 | ramLoad = Math.Round(ramLoad, 0); 211 | gpuLoad = Math.Round(gpuLoad, 0); 212 | gpuRamLoad = Math.Round(gpuRamLoad, 0); 213 | gpuTemperature = Math.Round(gpuTemperature, 0); 214 | 215 | //dac的数值范围为0-255,实际输出电压值为0-3.3v 216 | string _sendType_1; 217 | string _sendType_2; 218 | double _sendValue_1 = SwitchSendValue(sendValueID_1, out _sendType_1); 219 | double _sendValue_2 = SwitchSendValue(sendValueID_2, out _sendType_2); 220 | 221 | string sendStr1 = Math.Round(RamapValue(_sendValue_1, 0.0, 99.0, 0.0, useVoltage), 0).ToString("00"); 222 | string sendStr2 = Math.Round(RamapValue(_sendValue_2, 0.0, 99.0, 0.0, useVoltage), 0).ToString("00"); 223 | 224 | string writeLine = "\n===================bilibili日出东水===================\n" + 225 | "\nID_1 CPU 使用率: " + cpuLoad.ToString() + " %\n" + 226 | "\nID_2 CPU 温度: " + cpuTemperature.ToString() + " C\n" + 227 | "\nID_3 内存使用率:: " + ramLoad.ToString() + " %\n" + 228 | "\nID_4 GPU 使用率: " + gpuLoad.ToString() + " %\n" + 229 | "\nID_5 GPU 显存占用: " + gpuRamLoad.ToString() + " %\n"+ 230 | "\nID_6 GPU 温度: " + gpuTemperature.ToString() + " C\n"+ 231 | "\n配置的数据类型: [" + _sendType_1.ToString() + "] / ["+ _sendType_2.ToString() + "] \n"+ 232 | "\n----------------LibreHardwareMonitor------------------\n"; 233 | Console.WriteLine(writeLine); 234 | Esp32Connected(sendStr2.ToString() + "," + sendStr1.ToString()); 235 | 236 | System.Threading.Thread.Sleep(updateTime); 237 | } 238 | } 239 | 240 | static double SwitchSendValue(int index,out string dataType) 241 | { 242 | switch (index) 243 | { 244 | case 1: 245 | dataType = "CPU 使用率"; 246 | return cpuLoad; 247 | case 2: 248 | dataType = "CPU 温度"; 249 | return cpuTemperature; 250 | case 3: 251 | dataType = "内存使用率"; 252 | return ramLoad; 253 | case 4: 254 | dataType = "GPU 使用率"; 255 | return gpuLoad; 256 | case 5: 257 | dataType = "GPU 显存占用"; 258 | return gpuRamLoad; 259 | case 6: 260 | dataType = "GPU 温度"; 261 | return gpuTemperature; 262 | } 263 | dataType = "传参错误"; 264 | return 0; 265 | } 266 | 267 | static void Init() 268 | { 269 | //初始化OpenHardwareMonitorLib 270 | computer = new Computer(); 271 | computer.IsCpuEnabled = true; 272 | computer.IsMemoryEnabled = true; 273 | computer.IsGpuEnabled = true; 274 | computer.Open(); 275 | 276 | if (isWiredWireless) 277 | { 278 | serialPort.PortName = serialPortIndex;//串口号 279 | serialPort.BaudRate = baudRateValue;//波特率 280 | serialPort.DataBits = 8;//数据位 281 | try 282 | { 283 | serialPort.Open(); 284 | } 285 | catch (Exception _exception) 286 | { 287 | serialPort.Close(); 288 | Console.WriteLine(_exception.Message); 289 | } 290 | } 291 | else 292 | { 293 | try 294 | { 295 | remoteIp = IPAddress.Parse(esp32Ip); 296 | remotePoint = new IPEndPoint(remoteIp, esp32Port); 297 | } 298 | catch (Exception _exception) 299 | { 300 | Console.WriteLine(_exception.Message); 301 | } 302 | } 303 | 304 | } 305 | 306 | static void UpdateReceive() 307 | { 308 | while (true) 309 | { 310 | System.Threading.Thread.Sleep(updateTime); 311 | try 312 | { 313 | esp32ReadString = serialPort.ReadTo(".").Replace("\r","").Replace("\n", ""); 314 | //string[] _readStrArray = _readStr.Split(','); 315 | } 316 | catch 317 | { 318 | Console.WriteLine("回读失败"); 319 | } 320 | } 321 | } 322 | 323 | static void Esp32Connected(string message) 324 | { 325 | if (isWiredWireless) 326 | { 327 | if(serialPort.IsOpen) 328 | { 329 | serialPort.Write(message + ".");//添加截至标记使读取的数据完整 330 | Console.WriteLine("串口号: {0} 波特率: {1} 发送信息: {2} \n\n>>回读数据: {3}", serialPortIndex, baudRateValue, message, esp32ReadString); 331 | } 332 | else 333 | { 334 | serialPort.Close(); 335 | Console.WriteLine("出错啦! 串口: {0} 无法打开,请检查!", serialPortIndex); 336 | try 337 | { 338 | serialPort.Open(); 339 | } 340 | catch (Exception _exception) 341 | { 342 | Console.WriteLine(_exception.Message); 343 | } 344 | } 345 | } 346 | else 347 | { 348 | //UDP 方式发送信息给开发板 349 | byte[] buffer = Encoding.UTF8.GetBytes(message); 350 | 351 | if (udpClient != null) 352 | { 353 | if (remotePoint !=null) 354 | { 355 | udpClient.Send(buffer, buffer.Length, remotePoint); 356 | Console.WriteLine("IP: {0} 端口: {1} 发送信息: {2}", esp32Ip, esp32Port, message); 357 | } 358 | else 359 | { 360 | Console.WriteLine("出错啦! IP地址: {0} 无效,请检查!", esp32Ip); 361 | } 362 | } 363 | } 364 | } 365 | } 366 | } 367 | -------------------------------------------------------------------------------- /客户端/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("HardwareMonitor")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("HardwareMonitor")] 13 | [assembly: AssemblyCopyright("Copyright © 2022")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 会使此程序集中的类型 18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("25b85514-8430-4bcb-9cd9-2cdf3e6c9c8a")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 33 | //通过使用 "*",如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /客户端/Properties/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 50 | 58 | 59 | 73 | -------------------------------------------------------------------------------- /客户端/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "CpuRamGet": { 4 | "commandName": "Project", 5 | "commandLineArgs": "192.168.3.160 4999 1 500" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /表盘PSD源文件/表盘背景.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShaderFallback/CpuRamGet/88e91a7d2cfa92ac03cfb461e7eaee66dffe7aba/表盘PSD源文件/表盘背景.psd -------------------------------------------------------------------------------- /表盘PSD源文件/表盘背景2233_CPU.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShaderFallback/CpuRamGet/88e91a7d2cfa92ac03cfb461e7eaee66dffe7aba/表盘PSD源文件/表盘背景2233_CPU.jpg -------------------------------------------------------------------------------- /表盘PSD源文件/表盘背景2233_RAM.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShaderFallback/CpuRamGet/88e91a7d2cfa92ac03cfb461e7eaee66dffe7aba/表盘PSD源文件/表盘背景2233_RAM.jpg --------------------------------------------------------------------------------