Users no longer need Python: run.bat or install_autostart.ps1; agent reconnects when CYD is plugged in.
104 lines
3.7 KiB
Markdown
104 lines
3.7 KiB
Markdown
# CYD 本机 / 服务器信息面板
|
||
|
||
在 **2.8" / 3.5" CYD** 上显示当前电脑的 **CPU、GPU、内存、磁盘** 等主要信息。显示/触控骨架对齐 [tftest](../tftest) / [wifitest](../wifitest);板型差异按 [CYD_PROJECT_GUIDE.md](../CYD_PROJECT_GUIDE.md)。
|
||
|
||
| 板型 | env | 屏 / 触控 | 背光 |
|
||
|------|-----|-----------|------|
|
||
| **2.8" · 2432S028R** | `cyd`(默认) | ILI9341 + XPT2046 SoftSPI | GPIO**21** |
|
||
| **3.5" · 3248S035C** | `cyd_35r` | ST7796 + GT911 I2C | GPIO**27** |
|
||
|
||
本工程**无外设接线**(只吃 USB 供电 + 串口)。
|
||
|
||
## 原理
|
||
|
||
ESP32 无法直接读 PC 硬件。主机端跑跨平台脚本,经 **USB 串口** 按行推送:
|
||
|
||
```
|
||
SI|host=DESKTOP|cpu=i7-13700K|cpu%=12.3|gpu=RTX 4070|gpu%=5|ram=18.2/31.8|disk=512/931
|
||
```
|
||
|
||
屏上 LVGL 面板解析后画进度条;超过约 5 秒无新包显示 **stale**。
|
||
|
||
### 通用主机方案(Win10/11 · Linux · macOS)
|
||
|
||
ESP32 **读不到** PC 的 CPU/GPU,主机上必须有个小代理——但**不必安装 Python**。
|
||
|
||
| 用法 | 谁适合 |
|
||
|------|--------|
|
||
| **Windows 插上即用** | 双击 [`host/run.bat`](host/run.bat) 或跑一次 [`host/install_autostart.ps1`](host/install_autostart.ps1)(开机自启 + 等 USB) |
|
||
| **免安装单文件** | [`host/send_sysinfo.exe`](host/send_sysinfo.exe)(PyInstaller 打包,目标机无需 Python) |
|
||
| **开发 / Linux / macOS** | [`host/send_sysinfo.py`](host/send_sysinfo.py) + `pip install -r requirements.txt` |
|
||
|
||
采集栈(业界常规):
|
||
|
||
| 层级 | 库 / 接口 | 覆盖 |
|
||
|------|-----------|------|
|
||
| **CPU / 内存 / 磁盘** | [`psutil`](https://psutil.readthedocs.io/) | Windows / Linux / macOS… |
|
||
| **串口** | [`pyserial`](https://pyserial.readthedocs.io/) | 同上;断线自动重连、无口时等待插入 |
|
||
| **GPU 占用(可选)** | `nvidia-ml-py` → `nvidia-smi` → `amd-smi`/`rocm-smi` | 没有则 `gpu%=-1` |
|
||
|
||
```powershell
|
||
# Windows 最终用户(推荐)
|
||
cd host
|
||
.\install_autostart.ps1 # 装一次:以后插 USB 就推
|
||
# 或临时:
|
||
.\run.bat
|
||
|
||
# 开发者重打包 exe:
|
||
.\build_exe.ps1
|
||
|
||
# Linux / macOS / 有 Python 时:
|
||
pip install -r requirements.txt
|
||
python send_sysinfo.py -p /dev/ttyUSB0
|
||
```
|
||
|
||
## 刷写
|
||
|
||
| 板型 | 目录 |
|
||
|------|------|
|
||
| 2.8" | [`firmware/cyd/`](firmware/cyd/) |
|
||
| 3.5" | [`firmware/cyd_35r/`](firmware/cyd_35r/) |
|
||
|
||
```powershell
|
||
cd firmware\cyd # 或 firmware\cyd_35r
|
||
.\flash.ps1
|
||
# 或
|
||
.\flash.ps1 -Port COM3
|
||
```
|
||
|
||
源码烧录:`pio run -e cyd -t upload`(3.5:`-e cyd_35r`)
|
||
重新打包:`.\firmware\export_from_build.ps1`(3.5 加 `-Env cyd_35r`)
|
||
串口监视:`pio device monitor -b 460800`
|
||
|
||
## 本地 git(必做)
|
||
|
||
本工程是**独立本地 repo**,有效改动都要提交;**不 push**(除非明确要求)。顺序对齐 [CYD_PROJECT_GUIDE.md](../CYD_PROJECT_GUIDE.md) §0 / §3:
|
||
|
||
1. 改代码
|
||
2. `pio run -e cyd -t upload`(或 `cyd_35r`)真机验证
|
||
3. `.\firmware\export_from_build.ps1`(需要时加 `-Env cyd_35r`)
|
||
4. `git add -A` → `git commit`
|
||
|
||
禁止:只改代码不烧录、不导出固件、**不本地 commit** 就收工。
|
||
|
||
## 推送本机信息
|
||
|
||
板子刷好后:
|
||
|
||
1. Windows:`cd host` → `.\install_autostart.ps1`(装一次)或 `.\run.bat`
|
||
2. 插上 USB;代理会等串口并自动推送(状态变 **live**)
|
||
|
||
注意:串口同时只能被一个程序占用;跑代理时不要开 `pio device monitor`。卸载自启:`.\uninstall_autostart.ps1`。
|
||
|
||
## 文件
|
||
|
||
```
|
||
include/… src/… firmware/
|
||
host/send_sysinfo.exe # Windows 免 Python(入库)
|
||
host/run.bat # 双击启动
|
||
host/install_autostart.ps1 / uninstall_autostart.ps1
|
||
host/build_exe.ps1 # 重新打包 exe
|
||
host/send_sysinfo.py # 源码(Linux/macOS/开发)
|
||
host/requirements.txt
|
||
```
|