Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e91e661f1 | ||
|
|
ac76c10132 | ||
|
|
7ba01eae5e | ||
|
|
42ff258b35 | ||
|
|
74469cfe66 | ||
|
|
2a9a5f5b96 | ||
|
|
e5b2e45f57 | ||
|
|
296e220f20 | ||
|
|
e3ef359df4 | ||
|
|
be32efa806 | ||
|
|
8fde79c071 | ||
|
|
b4328b8be6 | ||
|
|
4149d203b0 | ||
|
|
264a0c74a6 | ||
|
|
190cf29aa5 | ||
|
|
d658fd459a | ||
|
|
b627f79dad | ||
|
|
c26d2cdbaa | ||
|
|
372cb6b7a0 | ||
|
|
68fb81fb13 | ||
|
|
733847a58c | ||
|
|
f594f60fdd | ||
|
|
e92fa9f349 | ||
|
|
fe4bca5a33 | ||
|
|
b58cdc42b6 | ||
|
|
21c1b7bcc1 | ||
|
|
144730fb3a | ||
|
|
ca898be299 | ||
|
|
511e7dfa44 | ||
|
|
6d1e2c6f8d | ||
|
|
a0d64c322a | ||
|
|
a666ed7c43 | ||
|
|
1f68665860 | ||
|
|
668a7e1ca5 | ||
|
|
bf9d70722c | ||
|
|
5d06e69a41 | ||
|
|
a3430d15e0 | ||
|
|
419c902a38 | ||
|
|
b1bb320b50 | ||
|
|
2d1d8f83b1 | ||
|
|
d991d57447 | ||
|
|
43d78de045 | ||
|
|
739fdeedf3 | ||
|
|
b7eda91ca7 | ||
|
|
763d80534c | ||
|
|
31fcd93607 | ||
|
|
df6a5f4343 | ||
|
|
32d0d26c5a | ||
|
|
afb6513e56 |
@@ -2,14 +2,34 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
# PyInstaller 工作目录(打包产物 exe 已直接入库, 构建中间物不入库)
|
# PyInstaller 工作目录(构建中间物不入库)
|
||||||
build/
|
build/
|
||||||
dist/
|
dist/
|
||||||
*.spec
|
*.spec
|
||||||
|
|
||||||
|
# exe 一律不入库(2026-10-13 起): 交付物只走 Gitea Release 附件, 本地保留。
|
||||||
|
# 历史 39 个 exe blob 已用 git filter-repo 清除(仓库 1.1 GiB -> ~1 MB (pack 实测))
|
||||||
|
*.exe
|
||||||
|
|
||||||
# 发布 zip: 可由 src/package_release.py 重新生成, 只上传 Gitea Release
|
# 发布 zip: 可由 src/package_release.py 重新生成, 只上传 Gitea Release
|
||||||
HDMI-Tool/release/*.zip
|
|
||||||
DLPilot/release/*.zip
|
DLPilot/release/*.zip
|
||||||
|
EDID-viewer/release/*.zip
|
||||||
|
SerialMate/release/*.zip
|
||||||
|
|
||||||
|
# 源码模式运行时的配置写入(config.BASE_DIR=src/), 与 release/ 下入库的预置栏位区分
|
||||||
|
DLPilot/src/pattern_slots.json
|
||||||
|
# SerialMate 无预置栏位, 运行态配置(最近串口/通道等)一律不入库
|
||||||
|
SerialMate/src/serial_mate.json
|
||||||
|
SerialMate/**/serial_assistant.json
|
||||||
|
SerialMate/release/serial_mate.json
|
||||||
|
# 板型档案(board_profiles.json)是用户本机数据, 首次运行自动生成默认值
|
||||||
|
SerialMate/src/board_profiles.json
|
||||||
|
SerialMate/release/board_profiles.json
|
||||||
|
|
||||||
|
# I2C-Lab 运行态配置不入库; 固件构建产物在 firmware/build/(build/ 规则已覆盖)
|
||||||
|
# release/ 交付物(exe/UF2/BIN/zip)不入库: 本地保留, 待真机验收发布时再走流水线
|
||||||
|
I2C-Lab/src/i2c_lab.json
|
||||||
|
I2C-Lab/release/
|
||||||
|
|
||||||
# ZCode 客户端本地会话数据(计划留档等), 非项目配置
|
# ZCode 客户端本地会话数据(计划留档等), 非项目配置
|
||||||
.zcode/
|
.zcode/
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "gd32e230f8_firmware_merge_tool"]
|
||||||
|
path = gd32e230f8_firmware_merge_tool
|
||||||
|
url = https://gitea.hulk.wang/hulk/gd32e230f8_firmware_merge_tool.git
|
||||||
@@ -0,0 +1,268 @@
|
|||||||
|
# AGENTS.md — DLPilot 工程档案(开发约束与进度)
|
||||||
|
|
||||||
|
> 人类文档 [README.md](README.md) 回答"这是什么、怎么用";本文记录"代码怎么组织、
|
||||||
|
> 怎么构建发布、改动时哪些约束不能破坏",兼作本工具的进度记录。
|
||||||
|
> 修改本目录代码前先读完本文。仓库整体的开发需求与进度管理见根目录 `agent.md`。
|
||||||
|
|
||||||
|
## 1. 项目定位
|
||||||
|
|
||||||
|
仓库 `HW-Debug-Tools` 是 LT8619C(HDMI→RGB888)→ DLPC3421 投影转接板的**调试上位机工具集**,
|
||||||
|
上游主仓库(固件)为 `hulk/LT8619C_DLPC3421_HDMI`(同 Gitea 实例 `gitea.hulk.wang`),
|
||||||
|
上游固件本机路径 `E:\Hulk-Coding\LT8619C_DLPC3421_HDMI`;工具仓库路径 `E:\Hulk-Coding\HW-Debug-Tools`。
|
||||||
|
DLPilot 工作在两端:HDMI **源端**(PC 显卡侧,EDID/分辨率/图案)与**光机控制端**
|
||||||
|
(RS485 → 板载 GD32E230 网关 → DLPC3421)。寄存器语义判读基线(0x606E 位交换 /
|
||||||
|
0x606D 整组顺序)与光机协议规程都在上游仓库 `doc/architecture/` 与 `protocols.md`,不在本仓库。
|
||||||
|
|
||||||
|
## 2. 目录契约(重要)
|
||||||
|
|
||||||
|
```
|
||||||
|
DLPilot/
|
||||||
|
├── src/ 源代码区 —— 只有这里可以手改(logos/ 改图标源后重跑 make_ico.py)
|
||||||
|
├── assets/ 生成资产区 —— gen_*.py 的产物(PNG 图案),可随时再生成,改动需提交
|
||||||
|
├── release/ 产物区 —— 机器生成,禁止手改:DLPilot.exe、pattern_slots.json、
|
||||||
|
│ bw/solid 图案(package_release.py 从 assets/ 平铺复制来,均入库)、
|
||||||
|
│ *.zip(gitignore,只上传 Release)。release/ 本身=完整可直接运行的
|
||||||
|
│ 发布文件夹(exe+附属平铺),内容与 zip 一致
|
||||||
|
├── README.md 人类文档
|
||||||
|
└── AGENTS.md 本文
|
||||||
|
```
|
||||||
|
|
||||||
|
划分原则:**"人写的"在 src/,"生成的"按去向分 assets/(随包分发)与 release/(直接交付)**。
|
||||||
|
新文件必须落对区域;不要在 src/ 外新建源码,不要手改 assets/ 下的 PNG(改生成脚本再跑)。
|
||||||
|
|
||||||
|
### 文件角色速查
|
||||||
|
|
||||||
|
| 文件 | 角色 |
|
||||||
|
|---|---|
|
||||||
|
| `src/hdmi_gui.py` | 入口: argparse 命令行分发(--dump/--edid-fields/--test-pattern/--dlpc-cmd/--seconds), GUI 委托 app_fluent |
|
||||||
|
| `src/app_fluent.py` | PySide6-Fluent-Widgets 主界面: 双栏仪表盘(左 HDMI 源端五卡/右 光机五卡), 光强/定时快捷滑条 |
|
||||||
|
| `src/display_win.py` | Win32 显示器枚举/分辨率切换/智能拓扑(纯 ctypes) |
|
||||||
|
| `src/edid_parse.py` | EDID 1.4/CEA-861 解析(纯标准库, 上游 lt8619c_edid.c 以此为参考解码器) |
|
||||||
|
| `src/patterns.py` | 测试图案全屏投屏窗口(tkinter, ESC 退出, 测试卡区域 1:1 居中) |
|
||||||
|
| `src/config.py` | 运行目录定位(BASE_DIR)与 pattern_slots.json 读写(slots/area/serial 三键) |
|
||||||
|
| `src/dlpc_rs485.py` | 光机 RS485 协议模块: 帧构造/增量解析/译码表/预设命令/串口线程(DLPC485) |
|
||||||
|
| `src/selftest_rs485.py` | 光机协议自检(对照上游实测帧向量, 无硬件回归, 改协议代码后必跑) |
|
||||||
|
| `src/selftest_theme.py` | 主题切换回归(离屏, swatch 底色/渲染像素/标题字号, 改样式后必跑) |
|
||||||
|
| `src/selftest_log.py` | 收发日志上限与队列消费回归(离屏, 改 _dlpc_log/_poll_dlpc 后必跑) |
|
||||||
|
| `src/build_exe.py` | PyInstaller 打包 → `release/DLPilot.exe`(onefile/noconsole, 内嵌图标+pyserial+PySide6-Fluent-Widgets) |
|
||||||
|
| `src/package_release.py` | 复制图案到 release/(平铺) → `release/DLPilot-v<ver>-win64.zip`(校验栏位引用完整性; release/ 与 zip 内容一致) |
|
||||||
|
| `src/publish_gitea.py` | 建/复用 Gitea Release 并上传 zip(tag 默认取 zip 文件名) |
|
||||||
|
| `src/hdmi_source.ps1/.bat` | 独立 PowerShell 命令行工具(自包含,与 GUI 无代码共享) |
|
||||||
|
| `src/gen_bw_patterns.py` | 生成 `assets/bw_*.png` ×5(640x360 黑白,需 Pillow) |
|
||||||
|
| `src/gen_solid_colors.py` | 生成 `assets/solid_*.png` ×10(800x600 纯色,需 Pillow) |
|
||||||
|
| `src/la_wave_analyzer*.py` | 逻辑分析仪 CSV 波形判读(2/3 通道,40MHz 像素时钟假设) |
|
||||||
|
| `src/logos/make_ico.py` | svg/png → ico(写在其自身目录) |
|
||||||
|
| `release/pattern_slots.json` | 预置栏位:西门子星/波带片/综合测试卡,area=640x360;`serial` 键记忆光机串口 |
|
||||||
|
| `UI参考布局.svg/.png` | 界面布局设计稿(app_fluent.py 双栏布局的规格来源, 随分支入库) |
|
||||||
|
|
||||||
|
## 3. 代码不变量(改 hdmi_gui.py 必须维持)
|
||||||
|
|
||||||
|
1. **依赖分层**:CLI/显示/EDID/协议/配置模块(display_win/edid_parse/config/
|
||||||
|
dlpc_rs485)纯标准库;PySide6-Fluent-Widgets 是 GUI(app_fluent)的**硬依赖**(装了
|
||||||
|
才能开界面,CLI 不受影响),GUI 图案窗口使用 Qt,CLI 图案窗口由 patterns.py 使用 tkinter 创建。可选依赖
|
||||||
|
仍走"try-import + HAS_* 标志 + 缺失降级"模式:Pillow、pyserial——缺失时对应功能
|
||||||
|
禁用/提示安装,其余功能必须照常工作。
|
||||||
|
2. **模块边界**:hdmi_gui.py 只是入口, 不放实现; GUI 的显示器/EDID 访问走 display_win/edid_parse;ctypes 仅用于
|
||||||
|
单实例锁、Windows 标题栏与 frozen DLL 加载; pyserial 只准在 dlpc_rs485.py 里 import
|
||||||
|
(hdmi_gui/app_fluent 经 `dlpc_rs485.HAS_SERIAL` 与 `DLPC485` 类间接使用)。
|
||||||
|
3. **BASE_DIR 语义**(定义在 config.py):frozen(PyInstaller onefile)时
|
||||||
|
`BASE_DIR=exe 所在目录`(`sys.executable`),源码运行时 `=config.py 所在目录`
|
||||||
|
(即 src/)。所有用户数据(pattern_slots.json、自定义图片)都写/读自 BASE_DIR
|
||||||
|
**平铺**存放,不建子目录。
|
||||||
|
4. **自定义栏位 `file` 字段是裸文件名**:加载时 `os.path.join(BASE_DIR, file)` 解析,
|
||||||
|
因此 pattern_slots.json 引用的图片必须与 exe 同目录 —— package_release.py 正是按此平铺打包。
|
||||||
|
5. **exe 自包含**:图标经 `--add-data` 内嵌(运行时从 `_MEIPASS` 读);内置五种图案
|
||||||
|
(红/绿/蓝/棋盘格/网格线)由程序绘制,运行时**不依赖** assets/;solid/bw PNG 只服务自定义栏位。
|
||||||
|
6. **DPI 感知**:进程启动即 `SetProcessDpiAwareness(2)`,图案窗口按物理像素定位,勿移除。
|
||||||
|
7. **智能显示拓扑(勿改回无条件扩展)**:启动时枚举"接入但不在桌面"的显示器,仅当其
|
||||||
|
EDID 厂商字节为转接板签名 `61 93`(压缩码 "XLS",上游 lt8619c_edid.c)时才
|
||||||
|
`SetDisplayConfig(SDC_TOPOLOGY_EXTEND|SDC_APPLY)` 拉回桌面,静默容错。动机:板卡
|
||||||
|
热插拔后 Windows 可能停留在"仅电脑屏幕"导致枚举不到板卡。用户主动选择的拓扑
|
||||||
|
(家里的"仅第二屏幕"等,未激活的是笔记本内屏,厂商非 XLS)一律不动。
|
||||||
|
8. **分辨率切换是临时的**:走 `CHANGEDISPLAYSETTINGS`(不写注册表),"恢复"用会话开始时快照。
|
||||||
|
9. **EDID 来源是注册表**(`HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\...\Device Parameters\EDID`),
|
||||||
|
不是 WMI/DDC;exe 的 noconsole 版无 stdout,`--dump/--edid-fields` 只在源码/控制台版可用。
|
||||||
|
10. **光机串口线程回调不直接碰 GUI**:DLPC485 的 on_event/on_status 在后台线程触发,
|
||||||
|
必须经 `queue.Queue` + Qt 定时器轮询投递回主线程(现行 `_poll_dlpc` 模式,
|
||||||
|
与 I2C-Inject 的 Injector 同源);退出路径(关窗与 `--seconds` 自动关)都会走到
|
||||||
|
`App.closeEvent()`,在那里 `dlpc.close()` 收线程。
|
||||||
|
11. **pattern_slots.json 格式**:`{'area', 'slots', 'serial'}` 三键共存;load 兼容旧版
|
||||||
|
纯数组(无 area)与无 serial 键两种历史格式,save 永远写全三键。`serial` 子键为
|
||||||
|
`{port, baud, bytesize(8/7/6/5), parity(N/E/O), stopbits(1/2)}`,旧配置缺子键按
|
||||||
|
默认 8-N-1 补齐。
|
||||||
|
12. **GUI = app_fluent.py 双栏仪表盘**(规格:`DLPilot/UI参考布局.svg`):左列 HDMI 源端
|
||||||
|
五卡(显示器/模式/EDID 信息/测试图案/hex),右列光机五卡(串口/数据/电源/命令/滑条),
|
||||||
|
支持的模式和 EDID 信息默认折叠;顶栏 Dark/Light/System 切换。Light/Dark 同时更新
|
||||||
|
Fluent 主题、Qt 调色板、容器样式与 Windows DWM 标题栏,勿只调用 setTheme。
|
||||||
|
**fluent 控件的自定义样式禁止直接 setStyleSheet**:setTheme 会用库自带 qss 重刷全部
|
||||||
|
已注册控件,直写样式随之丢失(v0.4.0 swatch 丢底色的根因)。须走
|
||||||
|
`setCustomStyleSheet(控件, lightQss, darkQss)`(qss 需覆盖 hover/pressed/disabled 态,
|
||||||
|
否则悬停瞬间被自带态样式盖回);仅 PushButton 等无 themeChanged 钩子的控件可幸存。
|
||||||
|
FluentLabelBase 系(StrongBodyLabel 等)例外:其 setTextColor 在每次切主题时整体重写
|
||||||
|
自定义槽,任何 setCustomStyleSheet 都会被冲掉——字号等改用 QFont(自带 label.qss 无
|
||||||
|
font-size 规则,QFont 不会被冲)。RGB swatch 底色回归测试见 selftest_theme.py。
|
||||||
|
PD 协议成功显示绿色,FPDO 仍独立判定。打包必须收集 `qfluentwidgets` 资源,并加入 Windows 系统 `icuuc.dll`,否则 QtCore 可能被其它 ICU DLL 解析失败。
|
||||||
|
|
||||||
|
## 4. 领域语义(测试值都有含义,勿"顺手改")
|
||||||
|
|
||||||
|
- 纯色值 55/AA/FF:55(01010101) 与 AA(10101010) 互为字节镜像对(检出位序颠倒/位交换),
|
||||||
|
FF(11111111) 全高基准;R/G/B 三行对应 RGB888 三字节组(R=D[23:16]/G=D[15:8]/B=D[7:0])。
|
||||||
|
- 800x600@60:LT8619C **demo 板** shadow EDID 首选时序(solid 系列分辨率与之一致)。
|
||||||
|
- 640x360:测试卡区域默认值(16:9 半分辨率,点对点检查用);full=铺满所选屏。
|
||||||
|
**同时是转接板光机 DLPC3421 的 nHD 面板原生分辨率**(该板 shadow EDID 只声明 640x360@60),
|
||||||
|
投 640x360 图案 + RS485 开光机 = 整链路 1:1 验证。
|
||||||
|
- bw 系列图案各自目的见 `src/gen_bw_patterns.py` 顶部清单注释。
|
||||||
|
- 光机 RS485 命令集(M730/M731/M732/M201/M202/M737/M999/M888/M7/M8/M1/**M303/M304**)语义、
|
||||||
|
帧格式 `D5 01 LEN <ASCII> CRC`(累加和校验)、错误码与**就绪门禁**
|
||||||
|
(DLPC 未就绪时 M730/M731/M732 被拒回 0xFF)以上游 `protocols.md` 为唯一权威,
|
||||||
|
本仓不维护协议文档副本;注意 **M7S0 是"开启"TEC 自动控温**(方向反直觉)、
|
||||||
|
M737 在定时投光中延迟应答(CLI 等待上限 35s)。
|
||||||
|
- **M303/M304/M305 载荷是二进制例外**(SQ52205 电源实测):成功载荷为大端原始值,
|
||||||
|
**不是 ASCII**——Frame.payload 解出来是乱码,必须走 `payload_bytes()` 取原始字节;
|
||||||
|
M303=u16 mV(12V 轨窗口 11400~12600),M304=s16 补码 mA(正=正向,固件原样上总线,
|
||||||
|
上位机按有符号解析,FF 06=−250),**M305=u32 mW(LEN=4,勿复用双字节解析;
|
||||||
|
恒非负,量程 0~295000,能量方向看 M304 符号;显示 mW→W 两位小数)**。
|
||||||
|
封装在 `payload_u16_be/payload_s16_be/payload_u32_be/format_power`,
|
||||||
|
回归向量在 selftest_rs485.py(M303/M304 真机帧,M305 算法推演帧)。
|
||||||
|
- **电源自检序列**(M301 协议→M302 挡位最大电流→M303 实测母线电压,帧驱动状态机
|
||||||
|
`_pd_on_frame/_pd_seq`,超时 3s/步):FPDO 判定 = 电压就近挡(标准 PD 固定挡
|
||||||
|
5/9/12/15/20/28V,±5% 容差)+ M302 挡位电流;**12V 且 ≥3A 绿底,挡位不符红底,
|
||||||
|
无匹配挡 ERR**。应答按 TYPE=0xF0 判成功;
|
||||||
|
CH224Q 电压配置寄存器(0x0A)只写不可读,挡位只能实测判定。
|
||||||
|
- **功率检测** = M303+M304+M305 序列 → 读数框 电压V / 电流mA / 功率W(M305 u32 mW
|
||||||
|
换算两位小数);各步载荷长度按 kind 校验(2/2/4 字节),坏帧中止显示 ERR。
|
||||||
|
|
||||||
|
## 5. 构建 / 发布流水线(全部在 src/ 下执行)
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
python gen_bw_patterns.py ; python gen_solid_colors.py # 仅当改了图案生成逻辑
|
||||||
|
python build_exe.py # → ../release/DLPilot.exe(缺 PyInstaller 会自动 pip install)
|
||||||
|
python build_exe.py --debug # 附加带控制台的 DLPilot-console.exe(调试 --dump 用)
|
||||||
|
python package_release.py <版本> # → ../release/DLPilot-v<版本>-win64.zip
|
||||||
|
python publish_gitea.py ../release/DLPilot-v<版本>-win64.zip --replace --insecure # 上传(需 GITEA_TOKEN)
|
||||||
|
```
|
||||||
|
|
||||||
|
发布约定:
|
||||||
|
- tag/release 命名 `DLPilot-vX.Y.Z`,zip 命名 `DLPilot-vX.Y.Z-win64.zip`(publish_gitea.py
|
||||||
|
依赖此命名从文件名推 tag);
|
||||||
|
- **pattern_slots.json 与 release/ 下平铺的图案 png 改动跟随源码/资产生成提交入库;
|
||||||
|
exe 不入库**(2026-10-13 起全仓 `.gitignore` 挡 `*.exe`,交付物只走 Gitea
|
||||||
|
Release 附件,本地保留);**zip 永不入库**(.gitignore 已挡);
|
||||||
|
- publish_gitea.py 幂等:release 已存在则复用,同名资产默认跳过,`--replace` 删旧重传;
|
||||||
|
- token 读环境变量 `GITEA_TOKEN`:本机已用 setx 持久化为用户级变量(新开的会话/终端自动
|
||||||
|
继承,值不入库;在 setx 之前启动的进程读不到,需重开终端),急用时也可临时传 `--token`;
|
||||||
|
- Gitea 实例 `gitea.hulk.wang`,API 走 https(443),git 走 ssh(1234)——从 origin 远程自动解析;
|
||||||
|
python urllib 连该实例会在部分请求上报 `SSL: UNEXPECTED_EOF`,**实际发布需加 `--insecure`**;
|
||||||
|
- 本实例 Gitea 的 API 兼容性怪癖:`GET /releases/tags/{tag}` 返回的 `assets` 是纯数组,
|
||||||
|
而 `GET /releases/{id}` 是 `{items:[...]}` —— publish_gitea.py 已按两种形状兼容,勿"简化"回去。
|
||||||
|
|
||||||
|
## 6. 已知坑(历史踩过,勿重蹈)
|
||||||
|
|
||||||
|
- onefile 运行时 `__file__` 指向临时解压目录 `_MEIPASS`,定位 exe 必须用 `sys.executable`(§3.3);
|
||||||
|
- 重新打包前旧 exe 可能被残留进程占用 → build_exe.py 会 taskkill 同名进程,手改打包脚本时保留;
|
||||||
|
- 打包后本机图标缓存不刷新:`ie4uinit -show`,不是产物问题;
|
||||||
|
- 改图标流程:改 svg → `make_ico.py` 生成 ico → 重新打包(ico 同时是文件图标与运行时窗口图标);
|
||||||
|
- GUI 与 hdmi_source.ps1 各自独立实现显示器枚举,行为可能微差(GUI 与 `-List` 序号一致,
|
||||||
|
但与"设置"面板序号无保证);多屏操作前先确认序号;
|
||||||
|
- `pattern_slots.json` 兼容两种历史格式,写出只写新格式(详见 §3.11);
|
||||||
|
- `--seconds` 冒烟在已有 DLPilot 实例(含用户开着的 exe)运行时会"挂起":run_gui
|
||||||
|
检测到单实例互斥后弹模态框等点击。无头验证改用直启 `App(5)` 的等效脚本,或先关实例;
|
||||||
|
重打包同理——build_exe.py 会 taskkill 同名进程,等于替用户关掉开着的实例;
|
||||||
|
- 旧版 `app_gui.py` 仅保留作历史对照,当前入口使用 `app_fluent.py`;新增或修改界面时
|
||||||
|
应遵循 PySide6-Fluent-Widgets 的控件和 Qt 布局,不要把旧版 CustomTkinter 依赖带回入口。
|
||||||
|
|
||||||
|
## 7. 验证清单(改完代码后)
|
||||||
|
|
||||||
|
1. `python -m compileall -q src`(在 DLPilot/ 下) —— 全模块可编译;
|
||||||
|
2. `python selftest_rs485.py` —— 光机协议回归(改 dlpc_rs485.py 后必跑,向量来自上游 protocols.md);
|
||||||
|
3. `python selftest_theme.py` —— 主题切换回归(改 app_fluent.py 涉及样式/主题后必跑;
|
||||||
|
离屏渲染,Dark/Light 往返后校验 swatch 底色样式与渲染像素、标题字号);
|
||||||
|
3b. `python selftest_log.py` —— 收发日志上限/队列消费回归(改 `_dlpc_log`/`_poll_dlpc`
|
||||||
|
后必跑;600 行封顶 500、坏条目不中断 drain);
|
||||||
|
4. `python hdmi_gui.py --seconds 5` —— GUI 冒烟(自动开关);
|
||||||
|
5. `python hdmi_gui.py --test-pattern Checker --area 800x600 --seconds 3` —— 投图链路;
|
||||||
|
6. `python hdmi_gui.py --dump` —— EDID 解算不抛异常;
|
||||||
|
7. `python hdmi_gui.py --dlpc-cmd M999`(不带 --port)—— 应明确报错而非崩溃(无硬件时的优雅降级);
|
||||||
|
8. `python build_exe.py` → 双击 release/DLPilot.exe 确认图标/双栏布局/投图/光机区渲染;
|
||||||
|
9. `python package_release.py <版本>` —— 不报"引用图片缺失"即栏位完整性 OK。
|
||||||
|
|
||||||
|
## 8. v0.4.0 进度记录(2026-09-24)
|
||||||
|
|
||||||
|
- 入口已切换 `app_fluent.py`;历史 `app_gui.py` 保留,不改其历史版本号。
|
||||||
|
- 本次验证:源码编译通过、RS485 自测 ALL PASS、Qt 离屏浅色渲染、正式 EXE 定时退出码 0。
|
||||||
|
原生桌面自动化不可用,未完成成品 Light 截图;未将硬件功能标记为本次实机验证通过。
|
||||||
|
- 发布已将本次源码、文档、EXE 纳入同一个提交(`74b64dc`),远端标签 `DLPilot-v0.4.0`
|
||||||
|
指向该提交、附件已核对;zip 不入库。
|
||||||
|
- `release/pattern_slots.json` 的本机串口记忆改动属于运行态配置,勿随提交悄悄带入;
|
||||||
|
发布使用仓库预置配置,临时打包后恢复本机文件。
|
||||||
|
- 关联动态:EDID-Viewer 已于 2026-09-25 从本工具的"源端 EDID 查看"需求独立成工具
|
||||||
|
入库并发布 v0.1.0,与本目录无代码共享;I2C-Inject 已标记暂停开发(详见根 `agent.md`)。
|
||||||
|
|
||||||
|
## 9. v0.4.0 后修复记录
|
||||||
|
|
||||||
|
- 2026-09-28 修复"切换 Light 后 R/G/B hex 按钮底色丢失、切回 Dark 也不恢复":根因是
|
||||||
|
fluent 控件直接 `setStyleSheet` 的自定义样式在 `setTheme` 时被库重刷的自带 qss 整体
|
||||||
|
覆盖(任何方向的切换都会丢,非 Light 特有)。swatch 改走 `setCustomStyleSheet`(qss
|
||||||
|
覆盖 hover/pressed/disabled 态),同病的顶栏标题 24px 字号改用 QFont(FluentLabelBase
|
||||||
|
的自定义槽被库的 setTextColor 每次切主题重写,见 §3.12)。新增 `src/selftest_theme.py`
|
||||||
|
离屏回归(样式表存活 + 渲染像素比对),本次验证:compileall / selftest_rs485 /
|
||||||
|
selftest_theme / GUI 冒烟全部通过。
|
||||||
|
- 2026-09-28 以 v0.4.1 重新打包:APP_VERSION → 0.4.1,`build_exe.py` 生成新
|
||||||
|
release/DLPilot.exe(67.1 MB,exe `--seconds 5` 定时退出冒烟 exit 0),按 §8 约定
|
||||||
|
临时还原预置 pattern_slots.json 后 `package_release.py 0.4.1` 生成
|
||||||
|
`DLPilot-v0.4.1-win64.zip`(66.8 MB,zip 内为预置 COM15 配置,本机 COM5 运行态
|
||||||
|
已还原未入库)。Gitea Release 已发布:tag `DLPilot-v0.4.1` 指向提交 `62b325c`
|
||||||
|
(源码+exe+文档同一提交),资产 `DLPilot-v0.4.1-win64.zip`(66.8 MB),
|
||||||
|
https://gitea.hulk.wang/hulk/HW-Debug-Tools/releases/tag/DLPilot-v0.4.1 。
|
||||||
|
发布说明用 --notes-file 传入(内置 DEFAULT_NOTES 模板还是 v0.1.0 旧内容,下次
|
||||||
|
发布记得先写说明文件)。
|
||||||
|
- 2026-09-28 第二修:"串口未选/选错点连接后窗口被拉长、刷新按钮够不到"。根因:
|
||||||
|
pyserial 原始异常串(`could not open port '': FileNotFoundError...`)整段塞进
|
||||||
|
状态 BodyLabel,QLabel 不换行时最小宽度=整行文本宽,把右列参数行最小宽度撑爆。
|
||||||
|
三层修复:①`_dlpc_toggle` 空串口直接短提示返回(不再先写 SERIAL_CFG/save_slots
|
||||||
|
再 open——旧代码这顺序还会把本机串口记忆覆写成空串,本机 COM5 记忆即这样丢失过,
|
||||||
|
已手工修回);②dlpc_rs485 open 失败消息分类为短提示(被占用/不存在/其它),
|
||||||
|
完整异常改走 on_event 进收发日志;③`lbl_dlpc_st.setWordWrap(True)` 兜底。
|
||||||
|
验证:compileall / selftest_rs485 ALL PASS / 离屏断言(空串口提示、长文本下标签
|
||||||
|
最小宽度<300 可换行)/ GUI 冒烟 / 新 exe `--seconds 5` exit 0;v0.4.1 exe(15:05)
|
||||||
|
与 zip 均已用该修复重打。
|
||||||
|
- 2026-09-28 v0.4.2 两处 UI 小修:①"串口数据 · 收发日志"卡的"清空"按钮原本自占
|
||||||
|
一行(_card 的标题行是独立 row,按钮行加在其下),与标题错位且多占一行高度——
|
||||||
|
`_card()` 增加 `trailing` 参数把按钮并入标题行右端;②v0.4.0 fluent 重写把旧版
|
||||||
|
app_gui.py 光机命令卡首行的快捷按钮排(开光机/关光机/查版本/软件重启/开TEC/
|
||||||
|
关TEC/TEC33.0°C)整行丢失,开/关光机只能走预设下拉——本次按旧版排布原样恢复,
|
||||||
|
位于电流行与预设行之间(命令直发 `_dlpc_send`,无新增协议逻辑)。
|
||||||
|
验证:compileall / selftest_rs485 / selftest_theme ALL PASS;离屏渲染断言"清空"
|
||||||
|
与标题垂直中心差 0px、7 个快捷按钮齐全;真实桌面冒烟 exit 0。APP_VERSION → 0.4.2
|
||||||
|
并重打包。v0.4.2 已发布:tag `DLPilot-v0.4.2` 指向提交 `7bd9943`(源码+exe+文档
|
||||||
|
同一提交),资产 `DLPilot-v0.4.2-win64.zip`(66.8 MB,zip 内为预置 COM15 配置,
|
||||||
|
本机 COM5 运行态已还原未入库),
|
||||||
|
https://gitea.hulk.wang/hulk/HW-Debug-Tools/releases/tag/DLPilot-v0.4.2 。
|
||||||
|
本次发布说明已用 --notes-file 传入(临时文件,未入库)。
|
||||||
|
- 2026-10-13 v0.4.3 修复"长会话越跑越卡、命令点了没反应"(FilmForge 同案):
|
||||||
|
根因是 `_dlpc_log` 的手工 textCursor 裁剪用了**实例级枚举访问**
|
||||||
|
(`cursor.Start`/`cursor.BlockUnderCursor`),PySide6 6.11 移除该形式,收发日志
|
||||||
|
超 500 行后每次追加必抛 AttributeError;异常又逃出 `_poll_dlpc` 的 drain 循环
|
||||||
|
(旧 try 只捕获 queue.Empty),每 tick 最多消费到第一条 event,`_dlpc_log_q`
|
||||||
|
棘轮积压、日志裁剪/自动滚动全失效;电源自检/功率检测序列在 `_pd_step_next()`
|
||||||
|
之前的 `_dlpc_log` 调用处被打断,`_pd_seq` 永不清空,后续所有手动命令被
|
||||||
|
"序列进行中"拦截直到断开重连。整改:①改用 `setMaximumBlockCount(500)` 环形
|
||||||
|
裁剪(O(1),不依赖枚举写法);②`_poll_dlpc` 改逐事件兜底 try/except,单条异常
|
||||||
|
只打栈放弃该条、不再中断本轮消费;③新增 `selftest_log.py` 回归(600 行封顶 +
|
||||||
|
坏条目 drain 不中断)。验证:compileall / selftest_rs485 / selftest_theme /
|
||||||
|
selftest_log ALL PASS;GUI 冒烟 exit 0;`--dump` / `--dlpc-cmd`(无串口)正常。
|
||||||
|
APP_VERSION → 0.4.3 重打包(67.1 MB),按 §8 约定临时还原预置 pattern_slots.json
|
||||||
|
后 `package_release.py 0.4.3` 生成 `DLPilot-v0.4.3-win64.zip`(66.8 MB,zip 内
|
||||||
|
为预置 COM15 配置,本机 COM5 运行态已还原未入库)。遗留(未随本版处理):
|
||||||
|
`dlpc_rs485.py` 的 `except OSError` 把写超时(SerialTimeoutException)与设备
|
||||||
|
拔出混判,一次转换器停滞即断链误报"设备拔出"。
|
||||||
|
- 2026-10-14 新增面向二供的独立使用手册 `使用说明.md` + `使用说明.pdf`(基于
|
||||||
|
README 与 v0.4.3 Release 编写,从解压安装包写起的操作级文档,含命令参考/典型
|
||||||
|
流程/FAQ/版本沿革;不随发布 zip 分发,单独发给供应商)。PDF 由 md 生成:
|
||||||
|
python-markdown → Chrome headless 矢量打印 → pymupdf 回填目录页码/页脚/元数据,
|
||||||
|
两遍编译(第一遍定位各章节页码,第二遍回填目录),构建脚本为一次性临时产物
|
||||||
|
未入库;后续改 md 后需按同流程重出 PDF。文档拓扑表述已按用户勘误校准:
|
||||||
|
HDMI 与 RS485 接同一块转接板,GD32E230 是板上主控 MCU(逻辑控制),无独立
|
||||||
|
"GD32 网关"说法(README/根 README/本文其他处旧措辞待同步)。§3 界面总览含
|
||||||
|
标注版主界面截图(`manual-img/ui-overview-quickstart.png`,手册配图目录)与
|
||||||
|
四条快速开始要点;已记录"转接板上电默认开光机"新事实(§3/§7.1)。现 11 页。
|
||||||
@@ -4,11 +4,11 @@
|
|||||||
> HDMI **源端**(EDID 查看、分辨率切换、纯色/测试图案投屏)+ **光机控制**
|
> HDMI **源端**(EDID 查看、分辨率切换、纯色/测试图案投屏)+ **光机控制**
|
||||||
> (RS485 直连板上 GD32 网关,开关光机/设光强/查温度电流)。
|
> (RS485 直连板上 GD32 网关,开关光机/设光强/查温度电流)。
|
||||||
>
|
>
|
||||||
> - **只想用工具**:到 [Gitea Releases](https://gitea.hulk.wang/hulk/LT8619C_Debug_Tools/releases)
|
> - **只想用工具**:到 [Gitea Releases](https://gitea.hulk.wang/hulk/HW-Debug-Tools/releases)
|
||||||
> 下载 `DLPilot-vX.Y.Z-win64.zip`,解压双击 `DLPilot.exe` 即可(Windows 10/11 x64,免安装、无需 Python)。
|
> 下载 `DLPilot-vX.Y.Z-win64.zip`,解压双击 `DLPilot.exe` 即可(Windows 10/11 x64,免安装、无需 Python)。
|
||||||
> - **要改代码/重新打包**:见 §8、§9。
|
> - **要改代码/重新打包**:见 §8、§9。
|
||||||
>
|
>
|
||||||
> 更新:2026-09-11
|
> 更新:2026-09-24
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
| EDID 逐字节解析 | "EDID 原始数据"框右上"逐字节解析"按钮:按偏移逐字段展开基础块与 CTA-861 扩展块,每字段附原始字节 hex;命令行等价 `--edid-fields` |
|
| EDID 逐字节解析 | "EDID 原始数据"框右上"逐字节解析"按钮:按偏移逐字段展开基础块与 CTA-861 扩展块,每字段附原始字节 hex;命令行等价 `--edid-fields` |
|
||||||
| 分辨率切换 | "分辨率"下拉列出显卡按该屏 EDID 提供的全部模式;**应用**=临时切换(不写注册表,重启/恢复即还原),**恢复**=回到本次会话切改前的模式 |
|
| 分辨率切换 | "分辨率"下拉列出显卡按该屏 EDID 提供的全部模式;**应用**=临时切换(不写注册表,重启/恢复即还原),**恢复**=回到本次会话切改前的模式 |
|
||||||
| 测试图案投屏 | 全屏投到所选显示器,测试卡区域可选 `640x360 / 800x600 / full 铺满`;内置 纯红/纯绿/纯蓝/黑白棋盘格/网格线 + R/G/B 三行 55/AA/FF 纯色值按钮 + 3 个自定义图片栏位 |
|
| 测试图案投屏 | 全屏投到所选显示器,测试卡区域可选 `640x360 / 800x600 / full 铺满`;内置 纯红/纯绿/纯蓝/黑白棋盘格/网格线 + R/G/B 三行 55/AA/FF 纯色值按钮 + 3 个自定义图片栏位 |
|
||||||
| 界面 | CustomTkinter 深色双栏仪表盘(左列 HDMI 源端 / 右列 光机控制),顶栏可切换 Dark/Light/System |
|
| 界面 | PySide6-Fluent-Widgets 双栏仪表盘(左列 HDMI 源端 / 右列 光机控制),顶栏可切换 Dark/Light/System |
|
||||||
| 光机控制 | RS485 → 板载 GD32E230 网关 → DLPC3421:开关光机(可定时)、设光强、查电流/温度/版本、TEC 控制、软件重启;光强/定时提供快捷滑条;收发日志带协议译码(见 §5) |
|
| 光机控制 | RS485 → 板载 GD32E230 网关 → DLPC3421:开关光机(可定时)、设光强、查电流/温度/版本、TEC 控制、软件重启;光强/定时提供快捷滑条;收发日志带协议译码(见 §5) |
|
||||||
| 智能显示拓扑 | 仅当检测到转接板(EDID 厂商 "XLS")接入但未进入桌面(Windows 卡在"仅电脑屏幕")时才强制扩展把它拉回;你主动选的"仅第二屏幕"等拓扑不会被改动 |
|
| 智能显示拓扑 | 仅当检测到转接板(EDID 厂商 "XLS")接入但未进入桌面(Windows 卡在"仅电脑屏幕")时才强制扩展把它拉回;你主动选的"仅第二屏幕"等拓扑不会被改动 |
|
||||||
| 命令行模式 | 全部功能可脚本化调用,供自动化测试(见 §6、§7) |
|
| 命令行模式 | 全部功能可脚本化调用,供自动化测试(见 §6、§7) |
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
## 2. 下载与安装
|
## 2. 下载与安装
|
||||||
|
|
||||||
1. 打开 [Releases 页面](https://gitea.hulk.wang/hulk/LT8619C_Debug_Tools/releases),取最新的
|
1. 打开 [Releases 页面](https://gitea.hulk.wang/hulk/HW-Debug-Tools/releases),取最新的
|
||||||
`DLPilot-vX.Y.Z-win64.zip`;
|
`DLPilot-vX.Y.Z-win64.zip`;
|
||||||
2. 解压到**任意可写目录**(自定义图片与栏位配置会写到 exe 旁边);
|
2. 解压到**任意可写目录**(自定义图片与栏位配置会写到 exe 旁边);
|
||||||
3. 双击 `DLPilot.exe`。首次启动比脚本慢一两秒(onefile 解压),属正常现象。
|
3. 双击 `DLPilot.exe`。首次启动比脚本慢一两秒(onefile 解压),属正常现象。
|
||||||
@@ -52,16 +52,18 @@ DLPilot/
|
|||||||
```
|
```
|
||||||
左列(HDMI 源端) 右列(光机控制 RS485)
|
左列(HDMI 源端) 右列(光机控制 RS485)
|
||||||
┌ 显示器选择区域 [刷新] ┐ ┌ 串口选择 + 波特率/8-N-1 参数/连接 ┐
|
┌ 显示器选择区域 [刷新] ┐ ┌ 串口选择 + 波特率/8-N-1 参数/连接 ┐
|
||||||
├ 支持的模式: 分辨率[应用][恢复] + 明细 ┐ ├ 串口数据 — 收发日志(译码+hex) ┤
|
├ 支持的模式: 分辨率[应用][恢复] + 明细 ┐ ├ 电源检查 — PD自检/FPDO挡位/功率读数 ┤
|
||||||
├ EDID 信息(表格) ┘ ├ 光机命令 — 快捷按钮+TEC │
|
├ EDID 信息 ┘ ├ 串口数据 — 收发日志(译码+hex) ┤
|
||||||
├ 测试图案 / 纯色 / 自定义 / 测试卡区域 │ 预设下拉 / 自定义 / 温度读取 │
|
├ 测试图案 / 纯色 / 校准图案 / 测试卡区域 │ ├ 光机命令 — 快捷按钮+TEC │
|
||||||
├ EDID 原始数据 [逐字节解析] ┘ └ 快捷滑条 — 光强/定时/TEC温度 ┘
|
├ EDID 原始数据 [逐字节解析] ┘ │ 预设下拉 / 温度电流读取 / 自定义 │
|
||||||
|
└─────────────────────────────┘ └ 快捷滑条 — 光强/定时/TEC温度 ┘
|
||||||
```
|
```
|
||||||
|
|
||||||
1. 左上显示器下拉选择目标屏(多屏时注意别选成主屏),"刷新"重新枚举;
|
1. 左上显示器下拉选择目标屏(多屏时注意别选成主屏),"刷新"重新枚举;
|
||||||
2. **切分辨率**:"支持的模式"卡片里选模式 → "应用";测完点"恢复";
|
2. **切分辨率**:"支持的模式"卡片里选模式 → "应用";测完点"恢复";
|
||||||
3. **投测试图**:"测试图案"卡片先选**测试卡区域**(640x360 / 800x600 / full)→
|
3. **投测试图**:"测试图案"卡片先选**测试卡区域**(640x360 / 800x600 / full)→
|
||||||
点图案按钮全屏投放,按 **ESC** 或点击退出;R/G/B 纯色按钮(55/AA/FF,按通道着色)
|
点图案按钮全屏投放(新图案自动替换旧图案),按 **ESC** 或点"停止测试图像"退出;
|
||||||
|
R/G/B 纯色按钮(55/AA/FF,按通道着色)
|
||||||
用于 RGB 位交换类测试;自定义图片点齿轮按钮配置(图片自动复制到 exe 旁),
|
用于 RGB 位交换类测试;自定义图片点齿轮按钮配置(图片自动复制到 exe 旁),
|
||||||
"校准图案"一排为 3D 光固化测试/校准图预留槽位;
|
"校准图案"一排为 3D 光固化测试/校准图预留槽位;
|
||||||
4. **光机控制**:右列选串口与参数(波特率/数据位/校验/停止位,默认 115200 8-N-1)→ 连接 →
|
4. **光机控制**:右列选串口与参数(波特率/数据位/校验/停止位,默认 115200 8-N-1)→ 连接 →
|
||||||
@@ -98,6 +100,12 @@ GUI"光机控制"区:选串口 → 连接 → 点快捷按钮或命令下拉/
|
|||||||
多口描述相同时自动附物理位置消歧。日志区实时显示 `→ 命令` / `← 译码结果 (原始 hex)`,
|
多口描述相同时自动附物理位置消歧。日志区实时显示 `→ 命令` / `← 译码结果 (原始 hex)`,
|
||||||
错误自动附释义(如 `err:3(I2C NACK)`)。
|
错误自动附释义(如 `err:3(I2C NACK)`)。
|
||||||
|
|
||||||
|
"电源检查"卡:**电源自检**依序发 M301(协议)→M302(挡位最大电流)→M303(实测母线电压),
|
||||||
|
按实测电压就近判定 PD 固定挡(5/9/12/15/20/28V,容差 ±5%):**12V 挡且 ≥3A 绿底
|
||||||
|
"FPDO: 12V@3A"**;挡位不符(如 9V 挡)**红底**显示实际挡位;不落在任何标准挡显示
|
||||||
|
**ERR**(CH224Q 电压配置寄存器只写不可读,挡位只能靠实测判定)。**功率检测**依序发
|
||||||
|
M303+M304+M305,读数框显示 电压(V) / 电流(mA) / 功率(W,mW 换算两位小数)。
|
||||||
|
|
||||||
| 命令 | 功能 | 响应示例 |
|
| 命令 | 功能 | 响应示例 |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `M730S0` / `M730S1` | 开 / 关光机 | `ok` |
|
| `M730S0` / `M730S1` | 开 / 关光机 | `ok` |
|
||||||
@@ -105,6 +113,11 @@ GUI"光机控制"区:选串口 → 连接 → 点快捷按钮或命令下拉/
|
|||||||
| `M731S100` | 设光强 54-800(RGB 同值,写后读回复核) | `ok` / `err:R..G..B..` |
|
| `M731S100` | 设光强 54-800(RGB 同值,写后读回复核) | `ok` / `err:R..G..B..` |
|
||||||
| `M732` | 查三路电流设置值(0-65535) | `okR110G110B110` |
|
| `M732` | 查三路电流设置值(0-65535) | `okR110G110B110` |
|
||||||
| `M201` / `M202` | 查 DMD / LAMP 温度(0.1°C) | `okTL:246` = 24.6°C |
|
| `M201` / `M202` | 查 DMD / LAMP 温度(0.1°C) | `okTL:246` = 24.6°C |
|
||||||
|
| `M301` | 查电源协议(CH224Q 握手结果) | ASCII:`PD` / `QC3.0` / `EPR` … |
|
||||||
|
| `M302` | 查 PD 挡位最大电流(u16 大端 **mA**,50mA/LSB 固件已换算) | 0x0BB8 = 3000 mA = 3 A |
|
||||||
|
| `M303` | 查母线电压(SQ52205 实测,**2 字节大端二进制载荷**) | 0x2EF4 = 12020 mV = 12.02 V(12V 轨窗口 11400~12600) |
|
||||||
|
| `M304` | 查负载电流(SQ52205 实测,**2 字节大端二进制载荷**) | s16 补码 mA:0x0034=+52;FF 06=−250(正=正向) |
|
||||||
|
| `M305` | 查负载功率(SQ52205 实测,**4 字节大端二进制载荷** u32) | mW→显示 W 两位小数:0x00008CA0=36000 mW=36.00 W(量程 0~295000 mW) |
|
||||||
| `M999` | 查固件版本 | `okv20.0.0.1` |
|
| `M999` | 查固件版本 | `okv20.0.0.1` |
|
||||||
| `M737` | 查投光是否结束(投光中延迟应答) | `ok` |
|
| `M737` | 查投光是否结束(投光中延迟应答) | `ok` |
|
||||||
| `M7S0` / `M7S1` | TEC 自动控温开 / 关(注意 S0=开) | `ok` |
|
| `M7S0` / `M7S1` | TEC 自动控温开 / 关(注意 S0=开) | `ok` |
|
||||||
@@ -185,7 +198,8 @@ python la_wave_analyzer3.py <capture.csv> # 3 通道(RGB 三组同拍, ch8/
|
|||||||
DLPilot/
|
DLPilot/
|
||||||
├── src/ # 源代码(人工维护区)
|
├── src/ # 源代码(人工维护区)
|
||||||
│ ├── hdmi_gui.py # 入口与命令行模式(argparse 分发)
|
│ ├── hdmi_gui.py # 入口与命令行模式(argparse 分发)
|
||||||
│ ├── app_gui.py # CustomTkinter 主界面(双栏仪表盘)
|
│ ├── app_fluent.py # PySide6-Fluent-Widgets 主界面(双栏仪表盘)
|
||||||
|
│ ├── app_gui.py # 历史 CustomTkinter 界面(保留,不由入口加载)
|
||||||
│ ├── display_win.py # Win32 显示器枚举/分辨率/智能拓扑(纯标准库)
|
│ ├── display_win.py # Win32 显示器枚举/分辨率/智能拓扑(纯标准库)
|
||||||
│ ├── edid_parse.py # EDID 1.4/CEA-861 解析(纯标准库)
|
│ ├── edid_parse.py # EDID 1.4/CEA-861 解析(纯标准库)
|
||||||
│ ├── patterns.py # 测试图案全屏投屏窗口
|
│ ├── patterns.py # 测试图案全屏投屏窗口
|
||||||
@@ -204,17 +218,17 @@ DLPilot/
|
|||||||
│ ├── bw_*.png ×5 # 640x360 黑白系列
|
│ ├── bw_*.png ×5 # 640x360 黑白系列
|
||||||
│ └── solid_*.png ×10 # 800x600 纯色系列
|
│ └── solid_*.png ×10 # 800x600 纯色系列
|
||||||
├── release/ # 构建与发布产物(机器生成区, 不手改)
|
├── release/ # 构建与发布产物(机器生成区, 不手改)
|
||||||
│ ├── DLPilot.exe # 打包单文件版(改动跟随源码提交入库)
|
│ ├── DLPilot.exe # 打包单文件版(不入库,本地保留;随发布上传 Gitea Release)
|
||||||
│ ├── pattern_slots.json # exe 运行配置(栏位预置 + 串口记忆)
|
│ ├── pattern_slots.json # exe 运行配置(栏位预置 + 串口记忆)
|
||||||
│ ├── *.png / README.md # 附属文件平铺副本(由 package_release.py 从 assets/ 同步)
|
│ ├── *.png / README.md # 附属文件平铺副本(由 package_release.py 从 assets/ 同步)
|
||||||
│ └── *.zip # 发布包(不入库, 上传 Gitea Release)
|
│ └── *.zip # 发布包(不入库, 上传 Gitea Release)
|
||||||
├── README.md # 本说明
|
├── README.md # 本说明
|
||||||
├── AGENTS.md # 面向 AI/Agent 的工程档案(结构/约定/构建规程)
|
├── AGENTS.md # 面向 AI/Agent 的工程档案(结构/约定/构建规程)
|
||||||
└── UI参考布局.svg/.png # 界面布局设计稿(app_gui.py 按此实现)
|
└── UI参考布局.svg/.png # 界面布局设计稿(app_fluent.py 双栏布局参考)
|
||||||
```
|
```
|
||||||
|
|
||||||
从源码运行:`python src/hdmi_gui.py`,需 Python ≥3.10;EDID/命令行纯标准库;
|
从源码运行:`python src/hdmi_gui.py`,需 Python ≥3.10;EDID/命令行纯标准库;
|
||||||
GUI 需 customtkinter(`py -m pip install customtkinter`);光机控制需 pyserial;
|
GUI 需 PySide6-Fluent-Widgets(`py -m pip install PySide6-Fluent-Widgets`);光机控制需 pyserial;
|
||||||
自定义图片要 JPG/BMP/WebP 需可选 Pillow。
|
自定义图片要 JPG/BMP/WebP 需可选 Pillow。
|
||||||
|
|
||||||
## 9. 构建与发布
|
## 9. 构建与发布
|
||||||
@@ -223,7 +237,7 @@ GUI 需 customtkinter(`py -m pip install customtkinter`);光机控制需 p
|
|||||||
cd src
|
cd src
|
||||||
python selftest_rs485.py # 光机协议回归(改 dlpc_rs485.py 后必跑)
|
python selftest_rs485.py # 光机协议回归(改 dlpc_rs485.py 后必跑)
|
||||||
python build_exe.py # 打包 → ../release/DLPilot.exe(自动装 PyInstaller;
|
python build_exe.py # 打包 → ../release/DLPilot.exe(自动装 PyInstaller;
|
||||||
# 内置 pyserial/customtkinter, CTk 主题数据自动收集)
|
# 内置 pyserial/PySide6-Fluent-Widgets, Fluent 主题资源自动收集)
|
||||||
python build_exe.py --debug # 额外出一个带控制台的调试变体(--dump 可见输出)
|
python build_exe.py --debug # 额外出一个带控制台的调试变体(--dump 可见输出)
|
||||||
python package_release.py 0.2.0 # 组装 release/DLPilot-v0.2.0-win64.zip
|
python package_release.py 0.2.0 # 组装 release/DLPilot-v0.2.0-win64.zip
|
||||||
python publish_gitea.py DLPilot-v0.2.0-win64.zip --insecure # 上传 Gitea Release(需 GITEA_TOKEN)
|
python publish_gitea.py DLPilot-v0.2.0-win64.zip --insecure # 上传 Gitea Release(需 GITEA_TOKEN)
|
||||||
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 889 B |
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 247 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 889 B |
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
@@ -4,11 +4,11 @@
|
|||||||
> HDMI **源端**(EDID 查看、分辨率切换、纯色/测试图案投屏)+ **光机控制**
|
> HDMI **源端**(EDID 查看、分辨率切换、纯色/测试图案投屏)+ **光机控制**
|
||||||
> (RS485 直连板上 GD32 网关,开关光机/设光强/查温度电流)。
|
> (RS485 直连板上 GD32 网关,开关光机/设光强/查温度电流)。
|
||||||
>
|
>
|
||||||
> - **只想用工具**:到 [Gitea Releases](https://gitea.hulk.wang/hulk/LT8619C_Debug_Tools/releases)
|
> - **只想用工具**:到 [Gitea Releases](https://gitea.hulk.wang/hulk/HW-Debug-Tools/releases)
|
||||||
> 下载 `DLPilot-vX.Y.Z-win64.zip`,解压双击 `DLPilot.exe` 即可(Windows 10/11 x64,免安装、无需 Python)。
|
> 下载 `DLPilot-vX.Y.Z-win64.zip`,解压双击 `DLPilot.exe` 即可(Windows 10/11 x64,免安装、无需 Python)。
|
||||||
> - **要改代码/重新打包**:见 §8、§9。
|
> - **要改代码/重新打包**:见 §8、§9。
|
||||||
>
|
>
|
||||||
> 更新:2026-09-11
|
> 更新:2026-09-24
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
| EDID 逐字节解析 | "EDID 原始数据"框右上"逐字节解析"按钮:按偏移逐字段展开基础块与 CTA-861 扩展块,每字段附原始字节 hex;命令行等价 `--edid-fields` |
|
| EDID 逐字节解析 | "EDID 原始数据"框右上"逐字节解析"按钮:按偏移逐字段展开基础块与 CTA-861 扩展块,每字段附原始字节 hex;命令行等价 `--edid-fields` |
|
||||||
| 分辨率切换 | "分辨率"下拉列出显卡按该屏 EDID 提供的全部模式;**应用**=临时切换(不写注册表,重启/恢复即还原),**恢复**=回到本次会话切改前的模式 |
|
| 分辨率切换 | "分辨率"下拉列出显卡按该屏 EDID 提供的全部模式;**应用**=临时切换(不写注册表,重启/恢复即还原),**恢复**=回到本次会话切改前的模式 |
|
||||||
| 测试图案投屏 | 全屏投到所选显示器,测试卡区域可选 `640x360 / 800x600 / full 铺满`;内置 纯红/纯绿/纯蓝/黑白棋盘格/网格线 + R/G/B 三行 55/AA/FF 纯色值按钮 + 3 个自定义图片栏位 |
|
| 测试图案投屏 | 全屏投到所选显示器,测试卡区域可选 `640x360 / 800x600 / full 铺满`;内置 纯红/纯绿/纯蓝/黑白棋盘格/网格线 + R/G/B 三行 55/AA/FF 纯色值按钮 + 3 个自定义图片栏位 |
|
||||||
| 界面 | CustomTkinter 深色双栏仪表盘(左列 HDMI 源端 / 右列 光机控制),顶栏可切换 Dark/Light/System |
|
| 界面 | PySide6-Fluent-Widgets 双栏仪表盘(左列 HDMI 源端 / 右列 光机控制),顶栏可切换 Dark/Light/System |
|
||||||
| 光机控制 | RS485 → 板载 GD32E230 网关 → DLPC3421:开关光机(可定时)、设光强、查电流/温度/版本、TEC 控制、软件重启;光强/定时提供快捷滑条;收发日志带协议译码(见 §5) |
|
| 光机控制 | RS485 → 板载 GD32E230 网关 → DLPC3421:开关光机(可定时)、设光强、查电流/温度/版本、TEC 控制、软件重启;光强/定时提供快捷滑条;收发日志带协议译码(见 §5) |
|
||||||
| 智能显示拓扑 | 仅当检测到转接板(EDID 厂商 "XLS")接入但未进入桌面(Windows 卡在"仅电脑屏幕")时才强制扩展把它拉回;你主动选的"仅第二屏幕"等拓扑不会被改动 |
|
| 智能显示拓扑 | 仅当检测到转接板(EDID 厂商 "XLS")接入但未进入桌面(Windows 卡在"仅电脑屏幕")时才强制扩展把它拉回;你主动选的"仅第二屏幕"等拓扑不会被改动 |
|
||||||
| 命令行模式 | 全部功能可脚本化调用,供自动化测试(见 §6、§7) |
|
| 命令行模式 | 全部功能可脚本化调用,供自动化测试(见 §6、§7) |
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
## 2. 下载与安装
|
## 2. 下载与安装
|
||||||
|
|
||||||
1. 打开 [Releases 页面](https://gitea.hulk.wang/hulk/LT8619C_Debug_Tools/releases),取最新的
|
1. 打开 [Releases 页面](https://gitea.hulk.wang/hulk/HW-Debug-Tools/releases),取最新的
|
||||||
`DLPilot-vX.Y.Z-win64.zip`;
|
`DLPilot-vX.Y.Z-win64.zip`;
|
||||||
2. 解压到**任意可写目录**(自定义图片与栏位配置会写到 exe 旁边);
|
2. 解压到**任意可写目录**(自定义图片与栏位配置会写到 exe 旁边);
|
||||||
3. 双击 `DLPilot.exe`。首次启动比脚本慢一两秒(onefile 解压),属正常现象。
|
3. 双击 `DLPilot.exe`。首次启动比脚本慢一两秒(onefile 解压),属正常现象。
|
||||||
@@ -52,16 +52,18 @@ DLPilot/
|
|||||||
```
|
```
|
||||||
左列(HDMI 源端) 右列(光机控制 RS485)
|
左列(HDMI 源端) 右列(光机控制 RS485)
|
||||||
┌ 显示器选择区域 [刷新] ┐ ┌ 串口选择 + 波特率/8-N-1 参数/连接 ┐
|
┌ 显示器选择区域 [刷新] ┐ ┌ 串口选择 + 波特率/8-N-1 参数/连接 ┐
|
||||||
├ 支持的模式: 分辨率[应用][恢复] + 明细 ┐ ├ 串口数据 — 收发日志(译码+hex) ┤
|
├ 支持的模式: 分辨率[应用][恢复] + 明细 ┐ ├ 电源检查 — PD自检/FPDO挡位/功率读数 ┤
|
||||||
├ EDID 信息(表格) ┘ ├ 光机命令 — 快捷按钮+TEC │
|
├ EDID 信息 ┘ ├ 串口数据 — 收发日志(译码+hex) ┤
|
||||||
├ 测试图案 / 纯色 / 自定义 / 测试卡区域 │ 预设下拉 / 自定义 / 温度读取 │
|
├ 测试图案 / 纯色 / 校准图案 / 测试卡区域 │ ├ 光机命令 — 快捷按钮+TEC │
|
||||||
├ EDID 原始数据 [逐字节解析] ┘ └ 快捷滑条 — 光强/定时/TEC温度 ┘
|
├ EDID 原始数据 [逐字节解析] ┘ │ 预设下拉 / 温度电流读取 / 自定义 │
|
||||||
|
└─────────────────────────────┘ └ 快捷滑条 — 光强/定时/TEC温度 ┘
|
||||||
```
|
```
|
||||||
|
|
||||||
1. 左上显示器下拉选择目标屏(多屏时注意别选成主屏),"刷新"重新枚举;
|
1. 左上显示器下拉选择目标屏(多屏时注意别选成主屏),"刷新"重新枚举;
|
||||||
2. **切分辨率**:"支持的模式"卡片里选模式 → "应用";测完点"恢复";
|
2. **切分辨率**:"支持的模式"卡片里选模式 → "应用";测完点"恢复";
|
||||||
3. **投测试图**:"测试图案"卡片先选**测试卡区域**(640x360 / 800x600 / full)→
|
3. **投测试图**:"测试图案"卡片先选**测试卡区域**(640x360 / 800x600 / full)→
|
||||||
点图案按钮全屏投放,按 **ESC** 或点击退出;R/G/B 纯色按钮(55/AA/FF,按通道着色)
|
点图案按钮全屏投放(新图案自动替换旧图案),按 **ESC** 或点"停止测试图像"退出;
|
||||||
|
R/G/B 纯色按钮(55/AA/FF,按通道着色)
|
||||||
用于 RGB 位交换类测试;自定义图片点齿轮按钮配置(图片自动复制到 exe 旁),
|
用于 RGB 位交换类测试;自定义图片点齿轮按钮配置(图片自动复制到 exe 旁),
|
||||||
"校准图案"一排为 3D 光固化测试/校准图预留槽位;
|
"校准图案"一排为 3D 光固化测试/校准图预留槽位;
|
||||||
4. **光机控制**:右列选串口与参数(波特率/数据位/校验/停止位,默认 115200 8-N-1)→ 连接 →
|
4. **光机控制**:右列选串口与参数(波特率/数据位/校验/停止位,默认 115200 8-N-1)→ 连接 →
|
||||||
@@ -98,6 +100,12 @@ GUI"光机控制"区:选串口 → 连接 → 点快捷按钮或命令下拉/
|
|||||||
多口描述相同时自动附物理位置消歧。日志区实时显示 `→ 命令` / `← 译码结果 (原始 hex)`,
|
多口描述相同时自动附物理位置消歧。日志区实时显示 `→ 命令` / `← 译码结果 (原始 hex)`,
|
||||||
错误自动附释义(如 `err:3(I2C NACK)`)。
|
错误自动附释义(如 `err:3(I2C NACK)`)。
|
||||||
|
|
||||||
|
"电源检查"卡:**电源自检**依序发 M301(协议)→M302(挡位最大电流)→M303(实测母线电压),
|
||||||
|
按实测电压就近判定 PD 固定挡(5/9/12/15/20/28V,容差 ±5%):**12V 挡且 ≥3A 绿底
|
||||||
|
"FPDO: 12V@3A"**;挡位不符(如 9V 挡)**红底**显示实际挡位;不落在任何标准挡显示
|
||||||
|
**ERR**(CH224Q 电压配置寄存器只写不可读,挡位只能靠实测判定)。**功率检测**依序发
|
||||||
|
M303+M304+M305,读数框显示 电压(V) / 电流(mA) / 功率(W,mW 换算两位小数)。
|
||||||
|
|
||||||
| 命令 | 功能 | 响应示例 |
|
| 命令 | 功能 | 响应示例 |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `M730S0` / `M730S1` | 开 / 关光机 | `ok` |
|
| `M730S0` / `M730S1` | 开 / 关光机 | `ok` |
|
||||||
@@ -105,6 +113,11 @@ GUI"光机控制"区:选串口 → 连接 → 点快捷按钮或命令下拉/
|
|||||||
| `M731S100` | 设光强 54-800(RGB 同值,写后读回复核) | `ok` / `err:R..G..B..` |
|
| `M731S100` | 设光强 54-800(RGB 同值,写后读回复核) | `ok` / `err:R..G..B..` |
|
||||||
| `M732` | 查三路电流设置值(0-65535) | `okR110G110B110` |
|
| `M732` | 查三路电流设置值(0-65535) | `okR110G110B110` |
|
||||||
| `M201` / `M202` | 查 DMD / LAMP 温度(0.1°C) | `okTL:246` = 24.6°C |
|
| `M201` / `M202` | 查 DMD / LAMP 温度(0.1°C) | `okTL:246` = 24.6°C |
|
||||||
|
| `M301` | 查电源协议(CH224Q 握手结果) | ASCII:`PD` / `QC3.0` / `EPR` … |
|
||||||
|
| `M302` | 查 PD 挡位最大电流(u16 大端 **mA**,50mA/LSB 固件已换算) | 0x0BB8 = 3000 mA = 3 A |
|
||||||
|
| `M303` | 查母线电压(SQ52205 实测,**2 字节大端二进制载荷**) | 0x2EF4 = 12020 mV = 12.02 V(12V 轨窗口 11400~12600) |
|
||||||
|
| `M304` | 查负载电流(SQ52205 实测,**2 字节大端二进制载荷**) | s16 补码 mA:0x0034=+52;FF 06=−250(正=正向) |
|
||||||
|
| `M305` | 查负载功率(SQ52205 实测,**4 字节大端二进制载荷** u32) | mW→显示 W 两位小数:0x00008CA0=36000 mW=36.00 W(量程 0~295000 mW) |
|
||||||
| `M999` | 查固件版本 | `okv20.0.0.1` |
|
| `M999` | 查固件版本 | `okv20.0.0.1` |
|
||||||
| `M737` | 查投光是否结束(投光中延迟应答) | `ok` |
|
| `M737` | 查投光是否结束(投光中延迟应答) | `ok` |
|
||||||
| `M7S0` / `M7S1` | TEC 自动控温开 / 关(注意 S0=开) | `ok` |
|
| `M7S0` / `M7S1` | TEC 自动控温开 / 关(注意 S0=开) | `ok` |
|
||||||
@@ -185,7 +198,8 @@ python la_wave_analyzer3.py <capture.csv> # 3 通道(RGB 三组同拍, ch8/
|
|||||||
DLPilot/
|
DLPilot/
|
||||||
├── src/ # 源代码(人工维护区)
|
├── src/ # 源代码(人工维护区)
|
||||||
│ ├── hdmi_gui.py # 入口与命令行模式(argparse 分发)
|
│ ├── hdmi_gui.py # 入口与命令行模式(argparse 分发)
|
||||||
│ ├── app_gui.py # CustomTkinter 主界面(双栏仪表盘)
|
│ ├── app_fluent.py # PySide6-Fluent-Widgets 主界面(双栏仪表盘)
|
||||||
|
│ ├── app_gui.py # 历史 CustomTkinter 界面(保留,不由入口加载)
|
||||||
│ ├── display_win.py # Win32 显示器枚举/分辨率/智能拓扑(纯标准库)
|
│ ├── display_win.py # Win32 显示器枚举/分辨率/智能拓扑(纯标准库)
|
||||||
│ ├── edid_parse.py # EDID 1.4/CEA-861 解析(纯标准库)
|
│ ├── edid_parse.py # EDID 1.4/CEA-861 解析(纯标准库)
|
||||||
│ ├── patterns.py # 测试图案全屏投屏窗口
|
│ ├── patterns.py # 测试图案全屏投屏窗口
|
||||||
@@ -210,11 +224,11 @@ DLPilot/
|
|||||||
│ └── *.zip # 发布包(不入库, 上传 Gitea Release)
|
│ └── *.zip # 发布包(不入库, 上传 Gitea Release)
|
||||||
├── README.md # 本说明
|
├── README.md # 本说明
|
||||||
├── AGENTS.md # 面向 AI/Agent 的工程档案(结构/约定/构建规程)
|
├── AGENTS.md # 面向 AI/Agent 的工程档案(结构/约定/构建规程)
|
||||||
└── UI参考布局.svg/.png # 界面布局设计稿(app_gui.py 按此实现)
|
└── UI参考布局.svg/.png # 界面布局设计稿(app_fluent.py 双栏布局参考)
|
||||||
```
|
```
|
||||||
|
|
||||||
从源码运行:`python src/hdmi_gui.py`,需 Python ≥3.10;EDID/命令行纯标准库;
|
从源码运行:`python src/hdmi_gui.py`,需 Python ≥3.10;EDID/命令行纯标准库;
|
||||||
GUI 需 customtkinter(`py -m pip install customtkinter`);光机控制需 pyserial;
|
GUI 需 PySide6-Fluent-Widgets(`py -m pip install PySide6-Fluent-Widgets`);光机控制需 pyserial;
|
||||||
自定义图片要 JPG/BMP/WebP 需可选 Pillow。
|
自定义图片要 JPG/BMP/WebP 需可选 Pillow。
|
||||||
|
|
||||||
## 9. 构建与发布
|
## 9. 构建与发布
|
||||||
@@ -223,7 +237,7 @@ GUI 需 customtkinter(`py -m pip install customtkinter`);光机控制需 p
|
|||||||
cd src
|
cd src
|
||||||
python selftest_rs485.py # 光机协议回归(改 dlpc_rs485.py 后必跑)
|
python selftest_rs485.py # 光机协议回归(改 dlpc_rs485.py 后必跑)
|
||||||
python build_exe.py # 打包 → ../release/DLPilot.exe(自动装 PyInstaller;
|
python build_exe.py # 打包 → ../release/DLPilot.exe(自动装 PyInstaller;
|
||||||
# 内置 pyserial/customtkinter, CTk 主题数据自动收集)
|
# 内置 pyserial/PySide6-Fluent-Widgets, Fluent 主题资源自动收集)
|
||||||
python build_exe.py --debug # 额外出一个带控制台的调试变体(--dump 可见输出)
|
python build_exe.py --debug # 额外出一个带控制台的调试变体(--dump 可见输出)
|
||||||
python package_release.py 0.2.0 # 组装 release/DLPilot-v0.2.0-win64.zip
|
python package_release.py 0.2.0 # 组装 release/DLPilot-v0.2.0-win64.zip
|
||||||
python publish_gitea.py DLPilot-v0.2.0-win64.zip --insecure # 上传 Gitea Release(需 GITEA_TOKEN)
|
python publish_gitea.py DLPilot-v0.2.0-win64.zip --insecure # 上传 Gitea Release(需 GITEA_TOKEN)
|
||||||
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"area": "640x360",
|
||||||
|
"slots": [
|
||||||
|
{
|
||||||
|
"name": "西门子星",
|
||||||
|
"file": "bw_star.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "black",
|
||||||
|
"file": "CeramixNano-black.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BW_TEST",
|
||||||
|
"file": "bw_testcard.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "calipoint",
|
||||||
|
"file": "CeramixNano-caliPoint.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "自定义5",
|
||||||
|
"file": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "circle_640P",
|
||||||
|
"file": "CeramixNano-circle_640p.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "自定义7",
|
||||||
|
"file": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contrast",
|
||||||
|
"file": "CeramixNano-contrast.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "white",
|
||||||
|
"file": "CeramixNano-White.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sharpness",
|
||||||
|
"file": "CeramixNano-Sharpness_XY_3.png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"serial": {
|
||||||
|
"port": "COM15",
|
||||||
|
"baud": 115200,
|
||||||
|
"bytesize": 8,
|
||||||
|
"parity": "N",
|
||||||
|
"stopbits": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,901 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""DLPilot Fluent UI.
|
||||||
|
|
||||||
|
The device, EDID and RS485 modules deliberately remain unchanged. This file
|
||||||
|
is the presentation layer for the current desktop application and uses
|
||||||
|
PySide6-Fluent-Widgets for the cards, controls and dialogs.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import ctypes
|
||||||
|
import os
|
||||||
|
import queue
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
# PyInstaller keeps Shiboken's ABI DLLs in a sibling directory. Register both
|
||||||
|
# Qt and Shiboken before importing QtCore; this is required by one-file builds
|
||||||
|
# on Windows/Python 3.14 where the normal package import hook is unavailable.
|
||||||
|
if getattr(sys, "frozen", False) and os.name == "nt":
|
||||||
|
_frozen_dll_dirs = []
|
||||||
|
for _dll_dir in (os.path.join(getattr(sys, "_MEIPASS", ""), "PySide6"),
|
||||||
|
os.path.join(getattr(sys, "_MEIPASS", ""), "shiboken6")):
|
||||||
|
if os.path.isdir(_dll_dir):
|
||||||
|
_frozen_dll_dirs.append(_dll_dir)
|
||||||
|
try:
|
||||||
|
os.add_dll_directory(_dll_dir)
|
||||||
|
except (AttributeError, OSError):
|
||||||
|
pass
|
||||||
|
# Python 3.14 extension loading may ignore AddDllDirectory for a pyd's
|
||||||
|
# transitive dependencies; PATH keeps QtCore.pyd compatible with both
|
||||||
|
# Python 3.11-3.14 and PyInstaller one-file extraction.
|
||||||
|
if _frozen_dll_dirs:
|
||||||
|
os.environ["PATH"] = os.pathsep.join(_frozen_dll_dirs + [os.environ.get("PATH", "")])
|
||||||
|
# Preload the two libraries used by QtCore.pyd. This also covers Windows
|
||||||
|
# loader configurations that do not apply PATH/AddDllDirectory to a pyd's
|
||||||
|
# transitive dependencies after PyInstaller extraction.
|
||||||
|
try:
|
||||||
|
ctypes.WinDLL(os.path.join(getattr(sys, "_MEIPASS", ""), "shiboken6",
|
||||||
|
"shiboken6.abi3.dll"))
|
||||||
|
ctypes.WinDLL(os.path.join(getattr(sys, "_MEIPASS", ""), "PySide6",
|
||||||
|
"Qt6Core.dll"))
|
||||||
|
except (AttributeError, OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
from PySide6.QtCore import QPoint, QRect, Qt, QTimer
|
||||||
|
from PySide6.QtGui import QColor, QFont, QIcon, QImage, QPainter, QPen, QPalette
|
||||||
|
from PySide6.QtWidgets import (
|
||||||
|
QApplication, QDialog, QFileDialog, QFormLayout, QGridLayout, QHBoxLayout,
|
||||||
|
QLabel, QMainWindow, QMessageBox, QPlainTextEdit, QScrollArea, QSplitter,
|
||||||
|
QToolButton, QVBoxLayout, QWidget,
|
||||||
|
)
|
||||||
|
from qfluentwidgets import (
|
||||||
|
BodyLabel, CardWidget, ComboBox, LineEdit, PlainTextEdit,
|
||||||
|
PrimaryPushButton, PushButton, Slider, StrongBodyLabel, Theme,
|
||||||
|
setCustomStyleSheet, setTheme,
|
||||||
|
)
|
||||||
|
|
||||||
|
import config
|
||||||
|
import display_win
|
||||||
|
import dlpc_rs485
|
||||||
|
import edid_parse
|
||||||
|
import patterns
|
||||||
|
|
||||||
|
APP_NAME = "DLPilot"
|
||||||
|
APP_VERSION = "0.4.3"
|
||||||
|
REPO_URL = "https://gitea.hulk.wang/hulk/HW-Debug-Tools"
|
||||||
|
MONO = QFont("Consolas", 10)
|
||||||
|
CHIP_IDLE = "#666666"
|
||||||
|
CHIP_OK = "#2FA574"
|
||||||
|
CHIP_ERR = "#D9534F"
|
||||||
|
|
||||||
|
_QT_PATTERNS = set()
|
||||||
|
|
||||||
|
|
||||||
|
def close_qt_patterns():
|
||||||
|
for window in list(_QT_PATTERNS):
|
||||||
|
window.close()
|
||||||
|
_QT_PATTERNS.clear()
|
||||||
|
patterns.close_all()
|
||||||
|
|
||||||
|
|
||||||
|
def _area_box(spec, width, height):
|
||||||
|
if spec == "full":
|
||||||
|
return 0, 0, width, height
|
||||||
|
try:
|
||||||
|
aw, ah = (int(v) for v in spec.lower().split("x", 1))
|
||||||
|
except Exception:
|
||||||
|
aw, ah = config.PAT_W, config.PAT_H
|
||||||
|
return (width - aw) // 2, (height - ah) // 2, aw, ah
|
||||||
|
|
||||||
|
|
||||||
|
class PatternWindow(QWidget):
|
||||||
|
"""Borderless Qt equivalent of the old tkinter test-pattern window."""
|
||||||
|
|
||||||
|
def __init__(self, rect, kind, area, image_path=None, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.kind = kind
|
||||||
|
self.area = area
|
||||||
|
self.image = QImage(image_path) if image_path else None
|
||||||
|
x, y, width, height = rect
|
||||||
|
self.setGeometry(x, y, width, height)
|
||||||
|
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint |
|
||||||
|
Qt.Tool)
|
||||||
|
self.setAttribute(Qt.WA_DeleteOnClose)
|
||||||
|
_QT_PATTERNS.add(self)
|
||||||
|
self.show()
|
||||||
|
self.activateWindow()
|
||||||
|
self.setFocus()
|
||||||
|
|
||||||
|
def keyPressEvent(self, event):
|
||||||
|
if event.key() == Qt.Key_Escape:
|
||||||
|
self.close()
|
||||||
|
else:
|
||||||
|
super().keyPressEvent(event)
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
_QT_PATTERNS.discard(self)
|
||||||
|
super().closeEvent(event)
|
||||||
|
|
||||||
|
def paintEvent(self, _event):
|
||||||
|
painter = QPainter(self)
|
||||||
|
painter.fillRect(self.rect(), Qt.black)
|
||||||
|
x0, y0, aw, ah = _area_box(self.area, self.width(), self.height())
|
||||||
|
if self.image and not self.image.isNull():
|
||||||
|
painter.drawImage(QPoint(x0 + (aw - self.image.width()) // 2,
|
||||||
|
y0 + (ah - self.image.height()) // 2),
|
||||||
|
self.image)
|
||||||
|
return
|
||||||
|
if self.kind.startswith("#"):
|
||||||
|
painter.fillRect(x0, y0, aw, ah, QColor(self.kind))
|
||||||
|
elif self.kind in {"Red", "Green", "Blue"}:
|
||||||
|
painter.fillRect(x0, y0, aw, ah,
|
||||||
|
QColor({"Red": "#ff0000", "Green": "#00ff00",
|
||||||
|
"Blue": "#0000ff"}[self.kind]))
|
||||||
|
elif self.kind == "Checker":
|
||||||
|
for gy in range((ah + 39) // 40):
|
||||||
|
for gx in range((aw + 39) // 40):
|
||||||
|
if (gx + gy) % 2 == 0:
|
||||||
|
painter.fillRect(x0 + gx * 40, y0 + gy * 40, 40, 40,
|
||||||
|
Qt.white)
|
||||||
|
elif self.kind == "Grid":
|
||||||
|
painter.setPen(QPen(Qt.white, 1))
|
||||||
|
for x in range(0, aw + 1, 20):
|
||||||
|
painter.drawLine(x0 + x, y0, x0 + x, y0 + ah)
|
||||||
|
for y in range(0, ah + 1, 20):
|
||||||
|
painter.drawLine(x0, y0 + y, x0 + aw, y0 + y)
|
||||||
|
|
||||||
|
|
||||||
|
def _single_instance():
|
||||||
|
if os.name != "nt":
|
||||||
|
return True
|
||||||
|
try:
|
||||||
|
ctypes.windll.kernel32.CreateMutexW(None, False, "hulk.DLPilot.single")
|
||||||
|
return ctypes.windll.kernel32.GetLastError() != 183
|
||||||
|
except Exception:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class App(QMainWindow):
|
||||||
|
def __init__(self, auto_close=0):
|
||||||
|
super().__init__()
|
||||||
|
app = QApplication.instance()
|
||||||
|
self._system_palette = app.palette() if app else QPalette()
|
||||||
|
self._system_style = app.styleSheet() if app else ""
|
||||||
|
self.setWindowTitle(f"{APP_NAME} v{APP_VERSION} — 3D 光固化光机调试台")
|
||||||
|
icon_path = self._icon_path()
|
||||||
|
if icon_path:
|
||||||
|
self.setWindowIcon(QIcon(icon_path))
|
||||||
|
self.resize(1440, 960)
|
||||||
|
self.setMinimumSize(1180, 760)
|
||||||
|
self.displays = []
|
||||||
|
self._disp_labels = []
|
||||||
|
self._modes = {}
|
||||||
|
self._orig_modes = {}
|
||||||
|
self._cur_label = ""
|
||||||
|
self.slots, self.area = config.load_slots()
|
||||||
|
self._dlpc_log_q = queue.Queue()
|
||||||
|
self.dlpc = dlpc_rs485.DLPC485(self._dlpc_on_event, self._dlpc_on_status,
|
||||||
|
on_frame=self._dlpc_on_frame)
|
||||||
|
self._dlpc_connected = False
|
||||||
|
self._tl_order = []
|
||||||
|
self._pd_seq = []
|
||||||
|
self._pd_values = {}
|
||||||
|
self._pd_timer = None
|
||||||
|
self._pwr_seq = []
|
||||||
|
self._pwr_values = {}
|
||||||
|
self._pwr_timer = None
|
||||||
|
self._build()
|
||||||
|
self._load_displays()
|
||||||
|
self._timer = QTimer(self)
|
||||||
|
self._timer.timeout.connect(self._poll_dlpc)
|
||||||
|
if dlpc_rs485.HAS_SERIAL:
|
||||||
|
self._timer.start(80)
|
||||||
|
if auto_close > 0:
|
||||||
|
QTimer.singleShot(auto_close * 1000, self.close)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _icon_path():
|
||||||
|
base = getattr(sys, "_MEIPASS", os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
path = os.path.join(base, "logo_dlpilot.ico")
|
||||||
|
if os.path.exists(path):
|
||||||
|
return path
|
||||||
|
path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||||
|
"logos", "logo_dlpilot.ico")
|
||||||
|
return path if os.path.exists(path) else None
|
||||||
|
|
||||||
|
def _button(self, text, callback, primary=False):
|
||||||
|
button = PrimaryPushButton(text) if primary else PushButton(text)
|
||||||
|
button.clicked.connect(callback)
|
||||||
|
return button
|
||||||
|
|
||||||
|
def _card(self, title, parent, trailing=None):
|
||||||
|
card = CardWidget(parent)
|
||||||
|
layout = QVBoxLayout(card)
|
||||||
|
layout.setContentsMargins(14, 12, 14, 14)
|
||||||
|
layout.setSpacing(8)
|
||||||
|
row = QHBoxLayout()
|
||||||
|
row.addWidget(StrongBodyLabel(title, card))
|
||||||
|
row.addStretch(1)
|
||||||
|
if trailing is not None:
|
||||||
|
row.addWidget(trailing)
|
||||||
|
layout.addLayout(row)
|
||||||
|
return card, layout
|
||||||
|
|
||||||
|
def _collapsible_card(self, title, parent, expanded=False):
|
||||||
|
"""Card whose body starts collapsed to keep the dashboard compact."""
|
||||||
|
card = CardWidget(parent)
|
||||||
|
layout = QVBoxLayout(card)
|
||||||
|
layout.setContentsMargins(8, 6, 8, 8)
|
||||||
|
layout.setSpacing(4)
|
||||||
|
header = QToolButton(card)
|
||||||
|
header.setText(title)
|
||||||
|
header.setCheckable(True)
|
||||||
|
header.setChecked(expanded)
|
||||||
|
header.setAutoRaise(True)
|
||||||
|
header.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
|
||||||
|
header.setArrowType(Qt.DownArrow if expanded else Qt.RightArrow)
|
||||||
|
header.setStyleSheet("QToolButton { text-align: left; font-weight: 700; padding: 6px; }")
|
||||||
|
layout.addWidget(header)
|
||||||
|
body = QWidget(card)
|
||||||
|
body_layout = QVBoxLayout(body)
|
||||||
|
body_layout.setContentsMargins(6, 0, 6, 4)
|
||||||
|
body_layout.setSpacing(8)
|
||||||
|
body.setVisible(expanded)
|
||||||
|
layout.addWidget(body)
|
||||||
|
|
||||||
|
def toggle(checked):
|
||||||
|
body.setVisible(checked)
|
||||||
|
header.setArrowType(Qt.DownArrow if checked else Qt.RightArrow)
|
||||||
|
card.adjustSize()
|
||||||
|
|
||||||
|
header.clicked.connect(toggle)
|
||||||
|
return card, body_layout
|
||||||
|
|
||||||
|
def _text(self, read_only=True, mono=True):
|
||||||
|
text = PlainTextEdit(self)
|
||||||
|
text.setReadOnly(read_only)
|
||||||
|
if mono:
|
||||||
|
text.setFont(MONO)
|
||||||
|
text.setLineWrapMode(QPlainTextEdit.NoWrap)
|
||||||
|
return text
|
||||||
|
|
||||||
|
def _build(self):
|
||||||
|
root = QWidget(self)
|
||||||
|
root.setObjectName("root")
|
||||||
|
outer = QVBoxLayout(root)
|
||||||
|
outer.setContentsMargins(18, 14, 18, 18)
|
||||||
|
outer.setSpacing(12)
|
||||||
|
header = QHBoxLayout()
|
||||||
|
title = StrongBodyLabel("DLPilot", root)
|
||||||
|
# 标题字号走 QFont:FluentLabelBase 在每次主题切换时会用自带的颜色规则
|
||||||
|
# 重写自定义 qss 槽,setStyleSheet/setCustomStyleSheet 写的字号都会被冲掉
|
||||||
|
title_font = title.font()
|
||||||
|
title_font.setPixelSize(24)
|
||||||
|
title_font.setBold(True)
|
||||||
|
title.setFont(title_font)
|
||||||
|
header.addWidget(title)
|
||||||
|
header.addWidget(BodyLabel("EDID · 测试图案 · RS485 光机控制", root))
|
||||||
|
header.addStretch(1)
|
||||||
|
self.theme = ComboBox(root)
|
||||||
|
self.theme.addItems(["Dark", "Light", "System"])
|
||||||
|
self.theme.setCurrentText("System")
|
||||||
|
self.theme.currentTextChanged.connect(self._set_theme)
|
||||||
|
header.addWidget(self.theme)
|
||||||
|
header.addWidget(self._button("关于", self._show_about))
|
||||||
|
outer.addLayout(header)
|
||||||
|
|
||||||
|
split = QSplitter(Qt.Horizontal, root)
|
||||||
|
split.setChildrenCollapsible(False)
|
||||||
|
split.addWidget(self._scroll_column(self._build_left))
|
||||||
|
split.addWidget(self._scroll_column(self._build_right))
|
||||||
|
split.setStretchFactor(0, 1)
|
||||||
|
split.setStretchFactor(1, 1)
|
||||||
|
outer.addWidget(split, 1)
|
||||||
|
self.setCentralWidget(root)
|
||||||
|
|
||||||
|
def _scroll_column(self, builder):
|
||||||
|
host = QWidget()
|
||||||
|
layout = QVBoxLayout(host)
|
||||||
|
layout.setContentsMargins(2, 2, 8, 2)
|
||||||
|
layout.setSpacing(10)
|
||||||
|
builder(layout)
|
||||||
|
layout.addStretch(1)
|
||||||
|
scroll = QScrollArea()
|
||||||
|
scroll.setWidgetResizable(True)
|
||||||
|
scroll.setFrameShape(QScrollArea.NoFrame)
|
||||||
|
scroll.setWidget(host)
|
||||||
|
if builder.__name__ == '_build_left':
|
||||||
|
self.left_scroll = scroll
|
||||||
|
else:
|
||||||
|
self.right_scroll = scroll
|
||||||
|
return scroll
|
||||||
|
|
||||||
|
def _build_left(self, layout):
|
||||||
|
card, body = self._card("显示器选择", self)
|
||||||
|
row = QHBoxLayout()
|
||||||
|
self.cbo_display = ComboBox(card)
|
||||||
|
self.cbo_display.currentTextChanged.connect(self._on_select)
|
||||||
|
self.lbl_cur = BodyLabel("当前输出: —", card)
|
||||||
|
row.addWidget(self.cbo_display, 1)
|
||||||
|
row.addWidget(self._button("刷新", self._load_displays))
|
||||||
|
body.addLayout(row)
|
||||||
|
body.addWidget(self.lbl_cur)
|
||||||
|
layout.addWidget(card)
|
||||||
|
|
||||||
|
card, body = self._collapsible_card("支持的模式(EDID 解算)", self)
|
||||||
|
row = QHBoxLayout()
|
||||||
|
self.cbo_mode = ComboBox(card)
|
||||||
|
row.addWidget(BodyLabel("分辨率:", card))
|
||||||
|
row.addWidget(self.cbo_mode, 1)
|
||||||
|
row.addWidget(self._button("应用", self._apply_mode, True))
|
||||||
|
row.addWidget(self._button("恢复", self._restore_mode))
|
||||||
|
body.addLayout(row)
|
||||||
|
self.txt_modes = self._text()
|
||||||
|
self.txt_modes.setMinimumHeight(135)
|
||||||
|
body.addWidget(self.txt_modes)
|
||||||
|
layout.addWidget(card)
|
||||||
|
|
||||||
|
card, body = self._collapsible_card("EDID 信息", self)
|
||||||
|
self.txt_edid = self._text()
|
||||||
|
self.txt_edid.setMinimumHeight(150)
|
||||||
|
body.addWidget(self.txt_edid)
|
||||||
|
layout.addWidget(card)
|
||||||
|
|
||||||
|
card, body = self._card("测试图案", self)
|
||||||
|
row = QHBoxLayout()
|
||||||
|
for key, name in patterns.PATTERN_NAMES.items():
|
||||||
|
row.addWidget(self._button(name, lambda checked=False, k=key: self._show_pattern(k)))
|
||||||
|
row.addWidget(self._button("停止", close_qt_patterns))
|
||||||
|
body.addLayout(row)
|
||||||
|
area_row = QHBoxLayout()
|
||||||
|
area_row.addWidget(BodyLabel("测试卡区域:", card))
|
||||||
|
self.cbo_area = ComboBox(card)
|
||||||
|
self.cbo_area.addItems(list(config.AREA_OPTIONS))
|
||||||
|
self.cbo_area.setCurrentText(self.area)
|
||||||
|
self.cbo_area.currentTextChanged.connect(self._save_area)
|
||||||
|
area_row.addWidget(self.cbo_area)
|
||||||
|
area_row.addStretch(1)
|
||||||
|
body.addLayout(area_row)
|
||||||
|
for channel, items in patterns.SOLID_ROWS:
|
||||||
|
row = QHBoxLayout()
|
||||||
|
row.addWidget(BodyLabel(f"{channel}: 0x", card))
|
||||||
|
for label, color in items:
|
||||||
|
button = PushButton(label, card)
|
||||||
|
# fluent 控件的样式须走 setCustomStyleSheet:直接 setStyleSheet 的内容
|
||||||
|
# 会在 setTheme 时被库重刷的自带 qss 冲掉;且须覆盖 hover/pressed 态,
|
||||||
|
# 否则悬停瞬间底色仍会被自带态样式盖回
|
||||||
|
fg = 'black' if color == '#00FF00' else 'white'
|
||||||
|
qss = ("PushButton, PushButton:hover, PushButton:pressed, "
|
||||||
|
f"PushButton:disabled {{ background-color: {color}; color: {fg}; border: none; }}")
|
||||||
|
setCustomStyleSheet(button, qss, qss)
|
||||||
|
button.clicked.connect(lambda checked=False, c=color: self._show_solid(c))
|
||||||
|
row.addWidget(button)
|
||||||
|
row.addStretch(1)
|
||||||
|
body.addLayout(row)
|
||||||
|
self.slot_buttons = []
|
||||||
|
grid = QGridLayout()
|
||||||
|
for i in range(config.SLOT_COUNT):
|
||||||
|
cell = QWidget(card)
|
||||||
|
cell_layout = QHBoxLayout(cell)
|
||||||
|
cell_layout.setContentsMargins(0, 0, 0, 0)
|
||||||
|
button = self._button(self.slots[i]["name"], lambda checked=False, n=i: self._show_custom(n))
|
||||||
|
gear = self._button("⚙", lambda checked=False, n=i: self._configure_slot(n))
|
||||||
|
cell_layout.addWidget(button, 1)
|
||||||
|
cell_layout.addWidget(gear)
|
||||||
|
grid.addWidget(cell, i // 2, i % 2)
|
||||||
|
self.slot_buttons.append(button)
|
||||||
|
body.addLayout(grid)
|
||||||
|
layout.addWidget(card)
|
||||||
|
|
||||||
|
card, body = self._card("EDID 原始数据", self)
|
||||||
|
self.txt_hex = self._text()
|
||||||
|
self.txt_hex.setMinimumHeight(130)
|
||||||
|
body.addWidget(self.txt_hex)
|
||||||
|
body.addWidget(self._button("逐字节解析", self._show_edid_fields))
|
||||||
|
layout.addWidget(card)
|
||||||
|
|
||||||
|
def _build_right(self, layout):
|
||||||
|
if not dlpc_rs485.HAS_SERIAL:
|
||||||
|
card, body = self._card("光机控制不可用", self)
|
||||||
|
body.addWidget(BodyLabel("未安装 pyserial,请执行 py -m pip install pyserial。"))
|
||||||
|
layout.addWidget(card)
|
||||||
|
return
|
||||||
|
card, body = self._card("串口 · RS485 → GD32 网关 → DLPC3421", self)
|
||||||
|
row = QHBoxLayout()
|
||||||
|
self._dlpc_ports = dlpc_rs485.DLPC485.list_ports_info()
|
||||||
|
self.cbo_dlpc = ComboBox(card)
|
||||||
|
self.cbo_dlpc.addItems([label for _device, label in self._dlpc_ports])
|
||||||
|
if config.SERIAL_CFG["port"]:
|
||||||
|
self._dlpc_pick(config.SERIAL_CFG["port"])
|
||||||
|
row.addWidget(self.cbo_dlpc, 1)
|
||||||
|
row.addWidget(self._button("刷新", self._dlpc_refresh))
|
||||||
|
self.btn_dlpc = self._button("连接", self._dlpc_toggle, True)
|
||||||
|
row.addWidget(self.btn_dlpc)
|
||||||
|
body.addLayout(row)
|
||||||
|
params = QHBoxLayout()
|
||||||
|
for caption, attr, values, default in (
|
||||||
|
("波特率", "cbo_baud", ["115200", "57600", "38400", "9600"], str(config.SERIAL_CFG["baud"])),
|
||||||
|
("数据位", "cbo_databits", ["8", "7", "6", "5"], str(config.SERIAL_CFG["bytesize"])),
|
||||||
|
("校验", "cbo_parity", ["N", "E", "O"], str(config.SERIAL_CFG["parity"])),
|
||||||
|
("停止位", "cbo_stopbits", ["1", "2"], str(config.SERIAL_CFG["stopbits"])),
|
||||||
|
):
|
||||||
|
params.addWidget(BodyLabel(caption, card))
|
||||||
|
combo = ComboBox(card)
|
||||||
|
combo.addItems(values)
|
||||||
|
combo.setCurrentText(default)
|
||||||
|
setattr(self, attr, combo)
|
||||||
|
params.addWidget(combo)
|
||||||
|
self.lbl_dlpc_st = BodyLabel("未连接", card)
|
||||||
|
# 状态标签允许换行兜底: 任何长错误串都不得撑大参数行最小宽度(否则窗口拉长,
|
||||||
|
# 刷新/连接按钮被挤出可视区)
|
||||||
|
self.lbl_dlpc_st.setWordWrap(True)
|
||||||
|
params.addWidget(self.lbl_dlpc_st)
|
||||||
|
params.addStretch(1)
|
||||||
|
body.addLayout(params)
|
||||||
|
layout.addWidget(card)
|
||||||
|
|
||||||
|
card, body = self._card("串口数据 · 收发日志(译码 + 原始 hex)", self,
|
||||||
|
trailing=self._button("清空", self._dlpc_clear))
|
||||||
|
self.txt_dlpc = self._text()
|
||||||
|
self.txt_dlpc.setMinimumHeight(230)
|
||||||
|
# 收发日志环形裁剪: 超 500 行自动丢最旧(O(1))。勿改回 textCursor 手工裁剪——
|
||||||
|
# PySide6 6.11 移除实例级枚举访问, cursor.Start 必抛 AttributeError 且异常会
|
||||||
|
# 打断 _poll_dlpc 的队列消费(事件棘轮积压), 回归见 selftest_log.py
|
||||||
|
self.txt_dlpc.document().setMaximumBlockCount(500)
|
||||||
|
body.addWidget(self.txt_dlpc)
|
||||||
|
self._dlpc_log("帧格式: D5 01 LEN <命令> CRC / B5 TYPE LEN <payload> CRC")
|
||||||
|
layout.addWidget(card)
|
||||||
|
|
||||||
|
card, body = self._card("电源检查 · PD 自检 / 功率读数", self)
|
||||||
|
self.chip_pd = QLabel("PD", card)
|
||||||
|
self.chip_fpdo = QLabel("FPDO: —", card)
|
||||||
|
self.var_pwr = "电压: — 电流: — 功率: —"
|
||||||
|
self.box_pwr = QLabel(self.var_pwr, card)
|
||||||
|
for widget in (self.chip_pd, self.chip_fpdo, self.box_pwr):
|
||||||
|
widget.setMinimumHeight(30)
|
||||||
|
widget.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
|
||||||
|
widget.setStyleSheet(f"background: {CHIP_IDLE}; color: white; border-radius: 6px; padding: 4px 8px;")
|
||||||
|
row = QHBoxLayout()
|
||||||
|
row.addWidget(self._button("电源自检", self._pd_selftest))
|
||||||
|
row.addWidget(self.chip_pd)
|
||||||
|
row.addWidget(self.chip_fpdo, 1)
|
||||||
|
body.addLayout(row)
|
||||||
|
row = QHBoxLayout()
|
||||||
|
row.addWidget(self._button("功率检测", self._pwr_query))
|
||||||
|
row.addWidget(self.box_pwr, 1)
|
||||||
|
body.addLayout(row)
|
||||||
|
layout.addWidget(card)
|
||||||
|
|
||||||
|
card, body = self._card("光机命令 · 预设 / 自定义 / 温度", self)
|
||||||
|
row = QHBoxLayout()
|
||||||
|
self.var_current = BodyLabel("电流: —", card)
|
||||||
|
row.addWidget(self.var_current)
|
||||||
|
row.addStretch(1)
|
||||||
|
row.addWidget(self._button("查电流", self._query_current))
|
||||||
|
body.addLayout(row)
|
||||||
|
# 快捷命令行: v0.4.0 重写时从旧版 app_gui.py 丢失, 开关光机等一发命令
|
||||||
|
# 不应只能走预设下拉
|
||||||
|
quick = QHBoxLayout()
|
||||||
|
for name, cmd in (("开光机", "M730S0"), ("关光机", "M730S1"), ("查版本", "M999"),
|
||||||
|
("软件重启", "M888"), ("开TEC", "M7S0"), ("关TEC", "M7S1"),
|
||||||
|
("TEC33.0°C", "M8S330")):
|
||||||
|
quick.addWidget(self._button(name, lambda checked=False, c=cmd: self._dlpc_send(c)))
|
||||||
|
body.addLayout(quick)
|
||||||
|
preset_row = QHBoxLayout()
|
||||||
|
self._dlpc_presets = [(n, cmd) for n, cmd, _ in dlpc_rs485.PRESETS]
|
||||||
|
self.cbo_dlpc_cmd = ComboBox(card)
|
||||||
|
self.cbo_dlpc_cmd.addItems([f"{n} {cmd}" for n, cmd in self._dlpc_presets])
|
||||||
|
preset_row.addWidget(BodyLabel("预设:", card))
|
||||||
|
preset_row.addWidget(self.cbo_dlpc_cmd, 1)
|
||||||
|
preset_row.addWidget(self._button("发送", self._dlpc_send_preset, True))
|
||||||
|
preset_row.addWidget(self._button("查 DMD 温度", self._query_dmd))
|
||||||
|
self.var_dmd = BodyLabel("DMD: —", card)
|
||||||
|
preset_row.addWidget(self.var_dmd)
|
||||||
|
body.addLayout(preset_row)
|
||||||
|
custom_row = QHBoxLayout()
|
||||||
|
self.var_custom_cmd = LineEdit(card)
|
||||||
|
self.var_custom_cmd.setPlaceholderText("如 M730S0T2000")
|
||||||
|
self.var_custom_cmd.returnPressed.connect(self._dlpc_send_custom)
|
||||||
|
custom_row.addWidget(BodyLabel("自定义:", card))
|
||||||
|
custom_row.addWidget(self.var_custom_cmd, 1)
|
||||||
|
custom_row.addWidget(self._button("发送", self._dlpc_send_custom))
|
||||||
|
custom_row.addWidget(self._button("查 LAMP 温度", self._query_lamp))
|
||||||
|
self.var_lamp = BodyLabel("LAMP: —", card)
|
||||||
|
custom_row.addWidget(self.var_lamp)
|
||||||
|
body.addLayout(custom_row)
|
||||||
|
layout.addWidget(card)
|
||||||
|
|
||||||
|
card, body = self._card("快捷滑条 · 光强 / 定时投光 / TEC 温度", self)
|
||||||
|
self.sld_light, self.ent_light = self._slider_row(body, "光强 (54-800)", 54, 800, 100, self._dlpc_send_light, "下发电流值")
|
||||||
|
self.sld_timer, self.ent_timer = self._slider_row(body, "定时投光 (毫秒)", 0, 32700, 2000, self._dlpc_send_timer, "开光机(定时)")
|
||||||
|
self.sld_tec, self.ent_tec = self._slider_row(body, "TEC 凝露点 (0.1°C)", 200, 350, 330, self._dlpc_send_tec, "下发温度值")
|
||||||
|
layout.addWidget(card)
|
||||||
|
|
||||||
|
def _slider_row(self, layout, text, low, high, value, callback, button_text):
|
||||||
|
row = QHBoxLayout()
|
||||||
|
row.addWidget(BodyLabel(text, self))
|
||||||
|
slider = Slider(Qt.Horizontal, self)
|
||||||
|
slider.setRange(low, high)
|
||||||
|
slider.setValue(value)
|
||||||
|
entry = LineEdit(self)
|
||||||
|
entry.setText(str(value))
|
||||||
|
entry.setFixedWidth(65)
|
||||||
|
slider.valueChanged.connect(lambda v: entry.setText(str(v)))
|
||||||
|
entry.returnPressed.connect(lambda: self._sync_slider(slider, entry, low, high))
|
||||||
|
row.addWidget(slider, 1)
|
||||||
|
row.addWidget(entry)
|
||||||
|
row.addWidget(self._button(button_text, callback))
|
||||||
|
layout.addLayout(row)
|
||||||
|
return slider, entry
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _sync_slider(slider, entry, low, high):
|
||||||
|
try:
|
||||||
|
value = int(entry.text())
|
||||||
|
except ValueError:
|
||||||
|
value = slider.value()
|
||||||
|
value = max(low, min(high, value))
|
||||||
|
slider.setValue(value)
|
||||||
|
entry.setText(str(value))
|
||||||
|
|
||||||
|
def _set_theme(self, value):
|
||||||
|
app = QApplication.instance()
|
||||||
|
setTheme({"Dark": Theme.DARK, "Light": Theme.LIGHT, "System": Theme.AUTO}[value])
|
||||||
|
if value == "System":
|
||||||
|
app.setPalette(self._system_palette)
|
||||||
|
app.setStyleSheet(self._system_style)
|
||||||
|
is_dark = app.palette().color(QPalette.Window).value() < 128
|
||||||
|
else:
|
||||||
|
is_dark = value == "Dark"
|
||||||
|
self._apply_palette(is_dark)
|
||||||
|
self._apply_native_titlebar(is_dark)
|
||||||
|
|
||||||
|
def _apply_palette(self, is_dark):
|
||||||
|
"""Keep native Qt widgets and Fluent cards on the same surface colors."""
|
||||||
|
app = QApplication.instance()
|
||||||
|
palette = QPalette()
|
||||||
|
if is_dark:
|
||||||
|
window, base, text, border = "#202020", "#2b2b2b", "#f5f5f5", "#3a3a3a"
|
||||||
|
accent = "#00c8d7"
|
||||||
|
else:
|
||||||
|
window, base, text, border = "#f4f6f8", "#ffffff", "#1f2328", "#d8dee4"
|
||||||
|
accent = "#0f6cbd"
|
||||||
|
for role in (QPalette.Window, QPalette.Base, QPalette.AlternateBase):
|
||||||
|
palette.setColor(role, QColor(window if role == QPalette.Window else base))
|
||||||
|
palette.setColor(QPalette.Text, QColor(text))
|
||||||
|
palette.setColor(QPalette.WindowText, QColor(text))
|
||||||
|
palette.setColor(QPalette.Button, QColor(base))
|
||||||
|
palette.setColor(QPalette.ButtonText, QColor(text))
|
||||||
|
palette.setColor(QPalette.PlaceholderText, QColor("#8b949e" if not is_dark else "#8a8a8a"))
|
||||||
|
palette.setColor(QPalette.Highlight, QColor(accent))
|
||||||
|
palette.setColor(QPalette.HighlightedText, QColor("#ffffff"))
|
||||||
|
palette.setColor(QPalette.ToolTipBase, QColor(base))
|
||||||
|
palette.setColor(QPalette.ToolTipText, QColor(text))
|
||||||
|
app.setPalette(palette)
|
||||||
|
app.setStyleSheet(f"""
|
||||||
|
QMainWindow, QWidget#root {{ background-color: {window}; color: {text}; }}
|
||||||
|
QScrollArea, QScrollArea > QWidget > QWidget {{ background: transparent; border: 0; }}
|
||||||
|
CardWidget {{ background-color: {base}; border: 1px solid {border}; border-radius: 8px; }}
|
||||||
|
QPlainTextEdit, QTextEdit, QLineEdit, QComboBox {{
|
||||||
|
background-color: {base}; color: {text};
|
||||||
|
border: 1px solid {border}; border-radius: 5px;
|
||||||
|
selection-background-color: {accent};
|
||||||
|
}}
|
||||||
|
QToolButton {{ color: {text}; }}
|
||||||
|
""")
|
||||||
|
|
||||||
|
def _apply_native_titlebar(self, is_dark):
|
||||||
|
if os.name != "nt" or not hasattr(ctypes, "windll"):
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
hwnd = int(self.winId())
|
||||||
|
dwm = ctypes.windll.dwmapi
|
||||||
|
dark = ctypes.c_int(1 if is_dark else 0)
|
||||||
|
dwm.DwmSetWindowAttribute(hwnd, 20, ctypes.byref(dark), ctypes.sizeof(dark))
|
||||||
|
color = QColor("#202020" if is_dark else "#f4f6f8")
|
||||||
|
colorref = ctypes.c_int(color.red() | (color.green() << 8) | (color.blue() << 16))
|
||||||
|
text = QColor("#f5f5f5" if is_dark else "#1f2328")
|
||||||
|
textref = ctypes.c_int(text.red() | (text.green() << 8) | (text.blue() << 16))
|
||||||
|
dwm.DwmSetWindowAttribute(hwnd, 35, ctypes.byref(colorref), ctypes.sizeof(colorref))
|
||||||
|
dwm.DwmSetWindowAttribute(hwnd, 36, ctypes.byref(textref), ctypes.sizeof(textref))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _cur_display(self):
|
||||||
|
try:
|
||||||
|
return self.displays[self._disp_labels.index(self.cbo_display.currentText())]
|
||||||
|
except (ValueError, IndexError, AttributeError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _load_displays(self):
|
||||||
|
previous = self._cur_label
|
||||||
|
try:
|
||||||
|
self.displays = display_win.get_displays()
|
||||||
|
except Exception as exc:
|
||||||
|
self.displays = []
|
||||||
|
self.notice("显示器枚举失败", str(exc), error=True)
|
||||||
|
self._disp_labels = [f"{d['device']} {d['adapter']} [{d['mon_name']}]" for d in self.displays]
|
||||||
|
self.cbo_display.blockSignals(True)
|
||||||
|
self.cbo_display.clear()
|
||||||
|
self.cbo_display.addItems(self._disp_labels)
|
||||||
|
if self._disp_labels:
|
||||||
|
self.cbo_display.setCurrentText(previous if previous in self._disp_labels else self._disp_labels[0])
|
||||||
|
self.cbo_display.blockSignals(False)
|
||||||
|
if self._disp_labels:
|
||||||
|
self._cur_label = self.cbo_display.currentText()
|
||||||
|
self._on_select(self._cur_label)
|
||||||
|
self.left_scroll.verticalScrollBar().setValue(0)
|
||||||
|
self.right_scroll.verticalScrollBar().setValue(0)
|
||||||
|
else:
|
||||||
|
self.lbl_cur.setText("未找到活动显示器")
|
||||||
|
self.txt_modes.clear(); self.txt_edid.clear(); self.txt_hex.clear()
|
||||||
|
|
||||||
|
def _on_select(self, _value=None):
|
||||||
|
d = self._cur_display()
|
||||||
|
if d is None:
|
||||||
|
return
|
||||||
|
self._cur_label = self.cbo_display.currentText()
|
||||||
|
self.lbl_cur.setText(f"当前输出: {d['cur_mode']}")
|
||||||
|
keys, self._modes = display_win.enum_modes(d['device'])
|
||||||
|
self.cbo_mode.clear(); self.cbo_mode.addItems(keys)
|
||||||
|
if d['cur_mode'] in self._modes:
|
||||||
|
self.cbo_mode.setCurrentText(d['cur_mode'])
|
||||||
|
if not d['edid']:
|
||||||
|
self.txt_edid.setPlainText("EDID 读取失败(注册表无 EDID 数据)")
|
||||||
|
self.txt_modes.clear(); self.txt_hex.clear(); return
|
||||||
|
parsed = edid_parse.parse_edid(d['edid'])
|
||||||
|
self.txt_edid.setPlainText("\n".join(f"{k:<16}{v}" for k, v in edid_parse.edid_info_lines(parsed)))
|
||||||
|
lines = [f"{t['hact']}x{t['vact']} @{t['refresh']:g}Hz {t['clk_khz'] / 1000:.2f}MHz {'DTD 首选' if i == 0 else 'DTD'}" for i, t in enumerate(parsed['dtds'])]
|
||||||
|
lines += [f"{m} [CEA-VIC]" for m in parsed['cea_video']]
|
||||||
|
lines += [f"{m} [已建立时序]" for m in parsed['est']]
|
||||||
|
lines += [f"{m} [标准时序]" for m in parsed['std']]
|
||||||
|
self.txt_modes.setPlainText("\n".join(lines))
|
||||||
|
self.txt_hex.setPlainText(edid_parse.hex_dump(d['edid']))
|
||||||
|
|
||||||
|
def _apply_mode(self):
|
||||||
|
d = self._cur_display()
|
||||||
|
if d is None or self.cbo_mode.currentText() not in self._modes:
|
||||||
|
return
|
||||||
|
device = d['device']
|
||||||
|
if device not in self._orig_modes:
|
||||||
|
current = display_win.DEVMODEW(); current.dmSize = ctypes.sizeof(current)
|
||||||
|
if display_win.user32.EnumDisplaySettingsW(device, display_win.ENUM_CURRENT_SETTINGS, ctypes.byref(current)):
|
||||||
|
self._orig_modes[device] = current
|
||||||
|
ok, result = display_win.apply_mode(device, self._modes[self.cbo_mode.currentText()])
|
||||||
|
if not ok:
|
||||||
|
self.notice("切换失败", f"ChangeDisplaySettingsEx 返回码 {result}", error=True)
|
||||||
|
return
|
||||||
|
QTimer.singleShot(500, self._load_displays)
|
||||||
|
|
||||||
|
def _restore_mode(self):
|
||||||
|
d = self._cur_display()
|
||||||
|
if d is None: return
|
||||||
|
mode = self._orig_modes.pop(d['device'], None)
|
||||||
|
if mode is None:
|
||||||
|
self.notice("无可恢复", "该显示器没有记录切改前的模式")
|
||||||
|
return
|
||||||
|
display_win.apply_mode(d['device'], mode)
|
||||||
|
QTimer.singleShot(500, self._load_displays)
|
||||||
|
|
||||||
|
def _show_pattern(self, kind):
|
||||||
|
d = self._cur_display()
|
||||||
|
if d and d['rect']:
|
||||||
|
close_qt_patterns(); PatternWindow(d['rect'], kind, self.cbo_area.currentText(), parent=self)
|
||||||
|
|
||||||
|
def _show_solid(self, color):
|
||||||
|
self._show_pattern(color)
|
||||||
|
|
||||||
|
def _save_area(self, value):
|
||||||
|
self.area = value
|
||||||
|
config.save_slots(self.slots, value)
|
||||||
|
|
||||||
|
def _show_custom(self, index):
|
||||||
|
slot = self.slots[index]
|
||||||
|
if not slot['file']:
|
||||||
|
self.notice("未配置图片", f"请先配置“{slot['name']}”的图片")
|
||||||
|
return
|
||||||
|
path = os.path.join(config.BASE_DIR, slot['file'])
|
||||||
|
d = self._cur_display()
|
||||||
|
if not os.path.exists(path):
|
||||||
|
self.notice("图片不存在", path, error=True); return
|
||||||
|
if d and d['rect']:
|
||||||
|
close_qt_patterns(); PatternWindow(d['rect'], "", self.cbo_area.currentText(), path, self)
|
||||||
|
|
||||||
|
def _configure_slot(self, index):
|
||||||
|
dialog = QDialog(self); dialog.setWindowTitle(f"配置自定义栏位 {index + 1}")
|
||||||
|
form = QFormLayout(dialog)
|
||||||
|
name = LineEdit(dialog); name.setText(self.slots[index]['name'])
|
||||||
|
file_label = BodyLabel(self.slots[index]['file'] or "(未设置)", dialog)
|
||||||
|
form.addRow("按钮名称", name); form.addRow("图片文件", file_label)
|
||||||
|
buttons = QHBoxLayout(); choose = PushButton("选择图片...", dialog); clear = PushButton("清除图片", dialog); save = PrimaryPushButton("保存", dialog); cancel = PushButton("取消", dialog)
|
||||||
|
buttons.addWidget(choose); buttons.addWidget(clear); buttons.addStretch(1); buttons.addWidget(save); buttons.addWidget(cancel); form.addRow(buttons)
|
||||||
|
selected = [self.slots[index]['file']]
|
||||||
|
def choose_file():
|
||||||
|
path, _ = QFileDialog.getOpenFileName(dialog, "选择图片", config.BASE_DIR, f"图片文件 ({' '.join('*' + e for e in config.IMG_EXTS)})")
|
||||||
|
if path:
|
||||||
|
try: selected[0] = config.copy_image_into_script_dir(path); file_label.setText(selected[0])
|
||||||
|
except OSError as exc: self.notice("复制图片失败", str(exc), error=True)
|
||||||
|
choose.clicked.connect(choose_file); clear.clicked.connect(lambda: (selected.__setitem__(0, None), file_label.setText("(未设置)")))
|
||||||
|
cancel.clicked.connect(dialog.reject)
|
||||||
|
def save_slot():
|
||||||
|
self.slots[index] = {'name': name.text().strip() or f'自定义{index + 1}', 'file': selected[0]}
|
||||||
|
config.save_slots(self.slots, self.cbo_area.currentText()); self.slot_buttons[index].setText(self.slots[index]['name']); dialog.accept()
|
||||||
|
save.clicked.connect(save_slot); dialog.exec()
|
||||||
|
|
||||||
|
def _show_about(self):
|
||||||
|
QMessageBox.about(self, f"关于 {APP_NAME}", f"{APP_NAME} v{APP_VERSION}\n\nEDID / 测试图案 / RS485 光机控制\nPySide6-Fluent-Widgets UI\n\n{REPO_URL}")
|
||||||
|
|
||||||
|
def _show_edid_fields(self):
|
||||||
|
d = self._cur_display()
|
||||||
|
if d is None or not d['edid']:
|
||||||
|
self.notice("无 EDID", "该显示器没有可解析的 EDID 数据"); return
|
||||||
|
dialog = QDialog(self); dialog.setWindowTitle("EDID 逐字节解析"); dialog.resize(1120, 700)
|
||||||
|
layout = QVBoxLayout(dialog); text = self._text(); text.setLineWrapMode(QPlainTextEdit.WidgetWidth)
|
||||||
|
lines = []
|
||||||
|
for off, hx, meaning, value, note in edid_parse.edid_field_rows(d['edid']):
|
||||||
|
lines.append(f"{off} {meaning} {value}")
|
||||||
|
if hx: lines.append(f" 原始: {hx}")
|
||||||
|
if note: lines.append(f" {note}")
|
||||||
|
text.setPlainText("\n".join(lines)); layout.addWidget(text); layout.addWidget(self._button("关闭", dialog.accept)); dialog.exec()
|
||||||
|
|
||||||
|
# ---------------- RS485 ----------------
|
||||||
|
def _dlpc_on_frame(self, frame):
|
||||||
|
if self._pd_seq: self._dlpc_log_q.put(('pdframe', frame))
|
||||||
|
elif self._pwr_seq: self._dlpc_log_q.put(('pwrframe', frame))
|
||||||
|
|
||||||
|
def _dlpc_on_event(self, line):
|
||||||
|
match = re.search(r'← okTL:(-?\d+)', line)
|
||||||
|
if match and self._tl_order:
|
||||||
|
which = self._tl_order.pop(0); self._dlpc_log_q.put(('temp', f"{which}: {int(match.group(1)) / 10:.1f}°C"))
|
||||||
|
match = re.search(r'← okR(\d+)G(\d+)B(\d+)', line)
|
||||||
|
if match: self._dlpc_log_q.put(('current', f"电流 R:{match.group(1)} G:{match.group(2)} B:{match.group(3)}"))
|
||||||
|
self._dlpc_log_q.put(('event', line))
|
||||||
|
|
||||||
|
def _dlpc_on_status(self, message): self._dlpc_log_q.put(('status', message))
|
||||||
|
def _query_current(self): self._dlpc_send('M732')
|
||||||
|
def _query_dmd(self): self._tl_order.append('DMD'); self._dlpc_send('M201')
|
||||||
|
def _query_lamp(self): self._tl_order.append('LAMP'); self._dlpc_send('M202')
|
||||||
|
|
||||||
|
def _poll_dlpc(self):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
kind, value = self._dlpc_log_q.get_nowait()
|
||||||
|
except queue.Empty:
|
||||||
|
break
|
||||||
|
try:
|
||||||
|
if kind == 'status':
|
||||||
|
self.lbl_dlpc_st.setText(value)
|
||||||
|
if value.startswith(('已断开', '串口丢失')): self._serial_reset_state()
|
||||||
|
elif kind == 'temp': (self.var_dmd if value.startswith('DMD') else self.var_lamp).setText(value)
|
||||||
|
elif kind == 'current': self.var_current.setText(value)
|
||||||
|
elif kind == 'pdframe': self._pd_step_done(value.type_code == 0xF0, value)
|
||||||
|
elif kind == 'pwrframe': self._pwr_step_done(value)
|
||||||
|
else: self._dlpc_log(value)
|
||||||
|
except Exception:
|
||||||
|
# 单条事件处理异常只打栈放弃该条, 不得中断本轮消费——否则积压随事件流
|
||||||
|
# 单调增长(v0.4.3 前日志裁剪异常即此路径, 显示延迟越跑越大)
|
||||||
|
traceback.print_exc()
|
||||||
|
connected = self.dlpc.is_connected()
|
||||||
|
if connected != self._dlpc_connected:
|
||||||
|
self._dlpc_connected = connected; self.btn_dlpc.setText("断开" if connected else "连接")
|
||||||
|
|
||||||
|
def _dlpc_log(self, line):
|
||||||
|
self.txt_dlpc.appendPlainText(time.strftime('%H:%M:%S ') + line)
|
||||||
|
self.txt_dlpc.verticalScrollBar().setValue(self.txt_dlpc.verticalScrollBar().maximum())
|
||||||
|
|
||||||
|
def _dlpc_clear(self): self.txt_dlpc.clear()
|
||||||
|
def _dlpc_refresh(self):
|
||||||
|
self._dlpc_ports = dlpc_rs485.DLPC485.list_ports_info(); self.cbo_dlpc.clear(); self.cbo_dlpc.addItems([label for _d, label in self._dlpc_ports])
|
||||||
|
if self._dlpc_ports: self._dlpc_pick(config.SERIAL_CFG['port'] or self._dlpc_ports[0][0])
|
||||||
|
def _dlpc_pick(self, device):
|
||||||
|
for dev, label in self._dlpc_ports:
|
||||||
|
if dev == device: self.cbo_dlpc.setCurrentText(label); return
|
||||||
|
def _dlpc_selected_port(self):
|
||||||
|
label = self.cbo_dlpc.currentText()
|
||||||
|
for device, shown in self._dlpc_ports:
|
||||||
|
if shown == label: return device
|
||||||
|
return label.strip()
|
||||||
|
def _dlpc_toggle(self):
|
||||||
|
if self.dlpc.is_connected(): self.dlpc.close(); self._serial_reset_state(); return
|
||||||
|
port = self._dlpc_selected_port()
|
||||||
|
if not port: self.lbl_dlpc_st.setText('未选择串口,请先选择或刷新'); return
|
||||||
|
try: baud, bytesize, stopbits = int(self.cbo_baud.currentText()), int(self.cbo_databits.currentText()), int(self.cbo_stopbits.currentText())
|
||||||
|
except ValueError: self.lbl_dlpc_st.setText("串口参数非法"); return
|
||||||
|
parity = self.cbo_parity.currentText()[:1] or 'N'; config.SERIAL_CFG.update(port=port, baud=baud, bytesize=bytesize, parity=parity, stopbits=stopbits); config.save_slots(self.slots, self.cbo_area.currentText()); self.dlpc.open(port, baud, bytesize=bytesize, parity=parity, stopbits=stopbits)
|
||||||
|
def _serial_reset_state(self):
|
||||||
|
self._pd_seq.clear(); self._pwr_seq.clear(); self._tl_order.clear()
|
||||||
|
for timer in (self._pd_timer, self._pwr_timer):
|
||||||
|
if timer: timer.stop()
|
||||||
|
self._pd_timer = self._pwr_timer = None
|
||||||
|
def _dlpc_send(self, command):
|
||||||
|
if not self.dlpc.is_connected(): self.lbl_dlpc_st.setText('未连接串口'); return
|
||||||
|
if self._pd_seq or self._pwr_seq: self._dlpc_log(f'序列进行中, 命令已忽略: {command}'); return
|
||||||
|
self.dlpc.send(command)
|
||||||
|
def _dlpc_send_preset(self):
|
||||||
|
label = self.cbo_dlpc_cmd.currentText()
|
||||||
|
for name, command in self._dlpc_presets:
|
||||||
|
if label.startswith(name + ' '): self._dlpc_send(command); return
|
||||||
|
def _dlpc_send_custom(self):
|
||||||
|
if self.var_custom_cmd.text().strip(): self._dlpc_send(self.var_custom_cmd.text().strip())
|
||||||
|
|
||||||
|
def _pd_selftest(self):
|
||||||
|
if not self.dlpc.is_connected(): self.lbl_dlpc_st.setText('未连接串口'); return
|
||||||
|
if self._pd_seq: return
|
||||||
|
self._pd_seq = [('M301', 'pd'), ('M302', 'fpdo_ma'), ('M303', 'meas_mv')]; self._pd_values = {}; self._pd_chip_reset(); self._dlpc_log('电源自检: 开始'); self._pd_step_next()
|
||||||
|
def _pd_chip_reset(self):
|
||||||
|
self.chip_pd.setText('PD'); self.chip_pd.setStyleSheet(f'background: {CHIP_IDLE}; color: white; border-radius: 6px; padding: 4px 8px;'); self.chip_fpdo.setText('FPDO: —'); self.chip_fpdo.setStyleSheet(f'background: {CHIP_IDLE}; color: white; border-radius: 6px; padding: 4px 8px;')
|
||||||
|
def _pd_step_next(self):
|
||||||
|
if not self._pd_seq: self._pd_fpdo_verdict(); self._dlpc_log('电源自检: 完成'); return
|
||||||
|
self.dlpc.send(self._pd_seq[0][0]); self._pd_timer = QTimer(self); self._pd_timer.setSingleShot(True); self._pd_timer.timeout.connect(lambda: self._pd_step_done(False, None)); self._pd_timer.start(3000)
|
||||||
|
def _pd_step_done(self, ok, frame):
|
||||||
|
if not self._pd_seq: return
|
||||||
|
if self._pd_timer: self._pd_timer.stop(); self._pd_timer = None
|
||||||
|
_command, kind = self._pd_seq.pop(0); raw = dlpc_rs485.payload_bytes(frame) if frame is not None else b''
|
||||||
|
if ok and kind == 'pd':
|
||||||
|
proto = raw.decode('ascii', 'replace').strip()
|
||||||
|
good = proto in ('PD', 'EPR')
|
||||||
|
self.chip_pd.setText(proto or 'PD')
|
||||||
|
self.chip_pd.setStyleSheet(
|
||||||
|
f'background: {CHIP_OK if good else CHIP_ERR}; color: white; '
|
||||||
|
'border-radius: 6px; padding: 4px 8px;')
|
||||||
|
elif ok and kind == 'fpdo_ma' and len(raw) == 2: self._pd_values['ma'] = dlpc_rs485.payload_u16_be(raw)
|
||||||
|
elif ok and kind == 'meas_mv' and len(raw) == 2: self._pd_values['mv'] = dlpc_rs485.payload_u16_be(raw)
|
||||||
|
if ok: self._pd_step_next()
|
||||||
|
else: self._pd_seq.clear(); self._pd_chip_error(kind); self._dlpc_log('电源自检: 应答错误/超时, 序列中止')
|
||||||
|
def _pd_chip_error(self, kind):
|
||||||
|
widget = self.chip_pd if kind == 'pd' else self.chip_fpdo
|
||||||
|
if kind == 'pd': widget.setText('ERR')
|
||||||
|
else: widget.setText('FPDO: ERR')
|
||||||
|
widget.setStyleSheet(f'background: {CHIP_ERR}; color: white; border-radius: 6px; padding: 4px 8px;')
|
||||||
|
def _pd_fpdo_verdict(self):
|
||||||
|
mv, ma = self._pd_values.get('mv'), self._pd_values.get('ma')
|
||||||
|
if mv is None or ma is None: self._pd_chip_error('fpdo_ma'); return
|
||||||
|
gear = next((g for g in (5, 9, 12, 15, 20, 28) if abs(mv - g * 1000) <= g * 50), None); text = 'FPDO: ERR' if gear is None else f'FPDO: {gear}V@{ma / 1000:g}A'; self.chip_fpdo.setText(text); good = gear == 12 and ma >= 3000; self.chip_fpdo.setStyleSheet(f'background: {CHIP_OK if good else CHIP_ERR}; color: white; border-radius: 6px; padding: 4px 8px;')
|
||||||
|
|
||||||
|
def _pwr_query(self):
|
||||||
|
if not self.dlpc.is_connected(): self.lbl_dlpc_st.setText('未连接串口'); return
|
||||||
|
if self._pwr_seq: return
|
||||||
|
self._pwr_seq = [('M303', 'mv'), ('M304', 'ma'), ('M305', 'mw')]; self._pwr_values = {}; self._dlpc_log('功率检测: 开始'); self._pwr_step_next()
|
||||||
|
def _pwr_step_next(self):
|
||||||
|
if not self._pwr_seq: self._pwr_update(self._pwr_values.get('mv'), self._pwr_values.get('ma'), self._pwr_values.get('mw')); self._dlpc_log('功率检测: 完成'); return
|
||||||
|
self.dlpc.send(self._pwr_seq[0][0]); self._pwr_timer = QTimer(self); self._pwr_timer.setSingleShot(True); self._pwr_timer.timeout.connect(lambda: self._pwr_step_done(None)); self._pwr_timer.start(3000)
|
||||||
|
def _pwr_step_done(self, frame):
|
||||||
|
if not self._pwr_seq: return
|
||||||
|
if self._pwr_timer: self._pwr_timer.stop(); self._pwr_timer = None
|
||||||
|
_command, kind = self._pwr_seq.pop(0); raw = dlpc_rs485.payload_bytes(frame) if frame is not None else b''; want = {'mv': 2, 'ma': 2, 'mw': 4}[kind]
|
||||||
|
if frame is None or frame.type_code != 0xF0 or len(raw) != want: self._pwr_seq.clear(); self.box_pwr.setText('电压: ERR 电流: — 功率: —'); return
|
||||||
|
self._pwr_values[kind] = {'mv': dlpc_rs485.payload_u16_be, 'ma': dlpc_rs485.payload_s16_be, 'mw': dlpc_rs485.payload_u32_be}[kind](raw); self._pwr_step_next()
|
||||||
|
def _pwr_update(self, mv, ma, mw):
|
||||||
|
voltage = f'{mv / 1000:.2f} V' if mv is not None else '—'
|
||||||
|
current = f'{ma} mA' if ma is not None else '—'
|
||||||
|
power = f'{mw / 1000:.2f} W' if mw is not None else '—'
|
||||||
|
self.box_pwr.setText(f'电压: {voltage} 电流: {current} 功率: {power}')
|
||||||
|
def _dlpc_send_light(self): self._sync_slider(self.sld_light, self.ent_light, 54, 800); self._dlpc_send(f'M731S{self.sld_light.value()}')
|
||||||
|
def _dlpc_send_timer(self): self._sync_slider(self.sld_timer, self.ent_timer, 0, 32700); self._dlpc_send('M730S0' if self.sld_timer.value() <= 0 else f'M730S0T{self.sld_timer.value()}')
|
||||||
|
def _dlpc_send_tec(self): self._sync_slider(self.sld_tec, self.ent_tec, 200, 350); self._dlpc_send(f'M8S{self.sld_tec.value()}')
|
||||||
|
|
||||||
|
def notice(self, title, text, error=False):
|
||||||
|
box = QMessageBox(self); box.setWindowTitle(title); box.setText(text); box.setIcon(QMessageBox.Critical if error else QMessageBox.Information); box.exec()
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
close_qt_patterns()
|
||||||
|
self._serial_reset_state()
|
||||||
|
try: self.dlpc.close()
|
||||||
|
except Exception: pass
|
||||||
|
super().closeEvent(event)
|
||||||
|
|
||||||
|
|
||||||
|
def run_gui(auto_close=0):
|
||||||
|
if not _single_instance():
|
||||||
|
app = QApplication.instance() or QApplication(sys.argv)
|
||||||
|
QMessageBox.information(None, "DLPilot 已在运行", "检测到另一个 DLPilot 实例正在运行。")
|
||||||
|
return
|
||||||
|
app = QApplication.instance() or QApplication(sys.argv)
|
||||||
|
app.setApplicationName(APP_NAME)
|
||||||
|
setTheme(Theme.AUTO)
|
||||||
|
window = App(auto_close)
|
||||||
|
window.show()
|
||||||
|
app.exec()
|
||||||
@@ -33,9 +33,15 @@ MONO = ('Consolas', 12)
|
|||||||
BOLD = ('Microsoft YaHei UI', 13, 'bold')
|
BOLD = ('Microsoft YaHei UI', 13, 'bold')
|
||||||
TITLE_FONT = ('Microsoft YaHei UI', 18, 'bold')
|
TITLE_FONT = ('Microsoft YaHei UI', 18, 'bold')
|
||||||
|
|
||||||
|
# 电源自检状态位配色: 灰=未检测, 绿=正常回包, 红=错误/超时
|
||||||
|
CHIP_IDLE = ('gray78', 'gray34')
|
||||||
|
CHIP_IDLE_TEXT = ('#333333', '#E8E8E8')
|
||||||
|
CHIP_OK = '#2FA574'
|
||||||
|
CHIP_ERR = '#D9534F'
|
||||||
|
|
||||||
APP_NAME = 'DLPilot'
|
APP_NAME = 'DLPilot'
|
||||||
APP_VERSION = '0.3.0'
|
APP_VERSION = '0.3.6'
|
||||||
REPO_URL = 'https://gitea.hulk.wang/hulk/LT8619C_Debug_Tools'
|
REPO_URL = 'https://gitea.hulk.wang/hulk/HW-Debug-Tools'
|
||||||
|
|
||||||
|
|
||||||
def get_icon_path():
|
def get_icon_path():
|
||||||
@@ -57,23 +63,44 @@ def _apply_dropdown_theme():
|
|||||||
ctk.ThemeManager.theme['DropdownMenu']['text_color'] = ('#1A1A1A', '#DADADA')
|
ctk.ThemeManager.theme['DropdownMenu']['text_color'] = ('#1A1A1A', '#DADADA')
|
||||||
|
|
||||||
|
|
||||||
|
def _ensure_single_instance():
|
||||||
|
"""单实例锁(Windows 命名互斥体): 已有实例在运行时返回 False。
|
||||||
|
|
||||||
|
双击 exe 开多个实例时, 只有先启动的能连串口, 后续实例连接报"拒绝访问",
|
||||||
|
且用户往往只看到后开的窗口 —— 表现为"连不上/断不开"。互斥体句柄随
|
||||||
|
进程存活, 进程退出自动释放。"""
|
||||||
|
ERROR_ALREADY_EXISTS = 183
|
||||||
|
ctypes.windll.kernel32.CreateMutexW(None, False, 'hulk.DLPilot.single')
|
||||||
|
return ctypes.windll.kernel32.GetLastError() != ERROR_ALREADY_EXISTS
|
||||||
|
|
||||||
|
|
||||||
def run_gui(auto_close=0):
|
def run_gui(auto_close=0):
|
||||||
"""入口: 配置外观并启动主窗口"""
|
"""入口: 配置外观并启动主窗口"""
|
||||||
ctk.set_appearance_mode('System')
|
ctk.set_appearance_mode('System')
|
||||||
_apply_dropdown_theme()
|
_apply_dropdown_theme()
|
||||||
|
if not _ensure_single_instance():
|
||||||
|
from tkinter import messagebox
|
||||||
|
import tkinter as tk
|
||||||
|
r = tk.Tk()
|
||||||
|
r.withdraw()
|
||||||
|
messagebox.showinfo('DLPilot 已在运行',
|
||||||
|
'检测到另一个 DLPilot 实例正在运行。\n'
|
||||||
|
'请使用已打开的窗口(串口同时只能被一个实例占用)。')
|
||||||
|
return
|
||||||
App(auto_close).mainloop()
|
App(auto_close).mainloop()
|
||||||
|
|
||||||
|
|
||||||
class App(ctk.CTk):
|
class App(ctk.CTk):
|
||||||
def __init__(self, auto_close=0):
|
def __init__(self, auto_close=0):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.title('DLPilot — 3D 光固化光机调试台 (EDID · 测试图案 · RS485 光机控制)')
|
self.title(f'DLPilot v{APP_VERSION} — 3D 光固化光机调试台 '
|
||||||
|
f'(EDID · 测试图案 · RS485 光机控制)')
|
||||||
try: # 任务栏独立分组
|
try: # 任务栏独立分组
|
||||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('hulk.DLPilot')
|
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('hulk.DLPilot')
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self.geometry('1440x920')
|
self.geometry('1440x1010') # 右列新增电源检查卡, 窗口加高
|
||||||
self.minsize(1180, 800)
|
self.minsize(1180, 860)
|
||||||
ic = get_icon_path()
|
ic = get_icon_path()
|
||||||
if ic:
|
if ic:
|
||||||
try:
|
try:
|
||||||
@@ -88,12 +115,21 @@ class App(ctk.CTk):
|
|||||||
self._orig_modes = {} # device -> 切改前的原始 DEVMODEW
|
self._orig_modes = {} # device -> 切改前的原始 DEVMODEW
|
||||||
# 光机控制链路: 回调发生在串口线程, 经队列投递回 GUI 主线程轮询
|
# 光机控制链路: 回调发生在串口线程, 经队列投递回 GUI 主线程轮询
|
||||||
self._dlpc_log_q = queue.Queue()
|
self._dlpc_log_q = queue.Queue()
|
||||||
self.dlpc = dlpc_rs485.DLPC485(self._dlpc_on_event, self._dlpc_on_status)
|
self.dlpc = dlpc_rs485.DLPC485(self._dlpc_on_event, self._dlpc_on_status,
|
||||||
|
on_frame=self._dlpc_on_frame)
|
||||||
self._dlpc_connected = False
|
self._dlpc_connected = False
|
||||||
self._poll_job = None
|
self._poll_job = None
|
||||||
self._tl_order = [] # 温度查询应答顺序: 'DMD'/'LAMP' 先到先得
|
self._tl_order = [] # 温度查询应答顺序: 'DMD'/'LAMP' 先到先得
|
||||||
|
self._pd_seq = [] # 电源自检待执行步骤: [(命令, kind), ...]
|
||||||
|
self._pd_values = {} # 自检采集值: {'ma': 挡位电流, 'mv': 实测电压}
|
||||||
|
self._pd_timer = None # 自检单步超时定时器
|
||||||
|
self._pwr_seq = [] # 功率检测待执行步骤
|
||||||
|
self._pwr_values = {} # 功率检测采集值: {'mv', 'ma'}
|
||||||
|
self._pwr_timer = None
|
||||||
self._build()
|
self._build()
|
||||||
self._load_displays()
|
self._load_displays()
|
||||||
|
# 主窗口按 ESC 也能关闭所有投屏(投屏窗口失焦时的兜底出口)
|
||||||
|
self.bind('<Escape>', lambda _e: patterns.close_all())
|
||||||
if dlpc_rs485.HAS_SERIAL:
|
if dlpc_rs485.HAS_SERIAL:
|
||||||
self._poll_dlpc()
|
self._poll_dlpc()
|
||||||
if auto_close > 0:
|
if auto_close > 0:
|
||||||
@@ -202,13 +238,17 @@ class App(ctk.CTk):
|
|||||||
self.txt_modes.configure(state='disabled')
|
self.txt_modes.configure(state='disabled')
|
||||||
|
|
||||||
# -- EDID 信息 --
|
# -- EDID 信息 --
|
||||||
|
# CTkTextbox 而非 CTkScrollableFrame+逐行 Label: 后者 40+ 个画布控件,
|
||||||
|
# 窗口最大化时逐个重绘是卡顿主因; 文本框整体重排, 开销低一个量级
|
||||||
card, c = self._card(col, 'EDID 信息')
|
card, c = self._card(col, 'EDID 信息')
|
||||||
card.grid(row=2, column=0, sticky='nsew', pady=(10, 0))
|
card.grid(row=2, column=0, sticky='nsew', pady=(10, 0))
|
||||||
self.edid_scroll = ctk.CTkScrollableFrame(c, height=150)
|
self.txt_edid = ctk.CTkTextbox(c, font=MONO, wrap='none')
|
||||||
self.edid_scroll.pack(fill='both', expand=True)
|
self.txt_edid.pack(fill='both', expand=True)
|
||||||
|
self.txt_edid.configure(state='disabled')
|
||||||
|
|
||||||
# -- 测试图案 --
|
# -- 测试图案 --
|
||||||
card, c = self._card(col,'测试图案 — 黑底 1:1 居中, 按 ESC 退出')
|
card, c = self._card(col,'测试图案 — 黑底 1:1 居中, 投屏按 ESC 或"停止测试图像"退出',
|
||||||
|
button='停止测试图像', command=patterns.close_all)
|
||||||
card.grid(row=3, column=0, sticky='ew', pady=(10, 0))
|
card.grid(row=3, column=0, sticky='ew', pady=(10, 0))
|
||||||
row1 = ctk.CTkFrame(c, fg_color='transparent')
|
row1 = ctk.CTkFrame(c, fg_color='transparent')
|
||||||
row1.pack(fill='x')
|
row1.pack(fill='x')
|
||||||
@@ -315,6 +355,39 @@ class App(ctk.CTk):
|
|||||||
self._dlpc_log('帧格式: D5 01 LEN <命令> CRC / B5 TYPE LEN <payload> CRC, '
|
self._dlpc_log('帧格式: D5 01 LEN <命令> CRC / B5 TYPE LEN <payload> CRC, '
|
||||||
'累加和校验; 全部命令见 README"光机控制"')
|
'累加和校验; 全部命令见 README"光机控制"')
|
||||||
|
|
||||||
|
# -- 电源检查 --
|
||||||
|
# 网格对齐两行: col2 为读数框列(weight=1) -> FPDO 色框与功率黑框
|
||||||
|
# 起止位置完全一致(等长), 且随窗口拉伸自适应
|
||||||
|
card, c = self._card(col, '电源检查 — PD 自检 / 功率读数')
|
||||||
|
card.grid(row=2, column=0, sticky='ew', pady=(10, 0))
|
||||||
|
pwr_grid = ctk.CTkFrame(c, fg_color='transparent')
|
||||||
|
pwr_grid.pack(fill='x')
|
||||||
|
pwr_grid.grid_columnconfigure(2, weight=1)
|
||||||
|
ctk.CTkButton(pwr_grid, text='电源自检', width=90,
|
||||||
|
command=self._pd_selftest).grid(row=0, column=0, sticky='w')
|
||||||
|
proto_cell = ctk.CTkFrame(pwr_grid, fg_color='transparent')
|
||||||
|
proto_cell.grid(row=0, column=1, sticky='w', padx=(10, 0))
|
||||||
|
ctk.CTkLabel(proto_cell, text='协议:').pack(side='left', padx=(0, 4))
|
||||||
|
self.chip_pd = ctk.CTkLabel(proto_cell, text='PD', width=60, height=26,
|
||||||
|
corner_radius=6, fg_color=CHIP_IDLE,
|
||||||
|
text_color=CHIP_IDLE_TEXT)
|
||||||
|
self.chip_pd.pack(side='left')
|
||||||
|
self.var_fpdo = tk.StringVar(value='FPDO: —')
|
||||||
|
self.chip_fpdo = ctk.CTkLabel(pwr_grid, textvariable=self.var_fpdo,
|
||||||
|
height=26, corner_radius=6,
|
||||||
|
fg_color=CHIP_IDLE,
|
||||||
|
text_color=CHIP_IDLE_TEXT, anchor='w', padx=8)
|
||||||
|
self.chip_fpdo.grid(row=0, column=2, sticky='ew', padx=(12, 0))
|
||||||
|
ctk.CTkButton(pwr_grid, text='功率检测', width=90,
|
||||||
|
command=self._pwr_query).grid(row=1, column=0,
|
||||||
|
sticky='w', pady=(6, 0))
|
||||||
|
self.var_pwr = tk.StringVar(value='电压: — 电流: — 功率: —')
|
||||||
|
self.box_pwr = ctk.CTkLabel(pwr_grid, textvariable=self.var_pwr,
|
||||||
|
height=26, corner_radius=6,
|
||||||
|
fg_color=('#F2F2F2', '#181818'),
|
||||||
|
anchor='w', padx=8)
|
||||||
|
self.box_pwr.grid(row=1, column=2, sticky='ew', padx=(8, 0), pady=(6, 0))
|
||||||
|
|
||||||
# -- 光机命令 --
|
# -- 光机命令 --
|
||||||
# 标题行右侧: 电流实时读数 + 查电流按钮(okR..G..B.. 应答解析)
|
# 标题行右侧: 电流实时读数 + 查电流按钮(okR..G..B.. 应答解析)
|
||||||
cur_frame = ctk.CTkFrame(self, fg_color='transparent')
|
cur_frame = ctk.CTkFrame(self, fg_color='transparent')
|
||||||
@@ -325,7 +398,7 @@ class App(ctk.CTk):
|
|||||||
command=self._query_current).pack(side='left', padx=(6, 0))
|
command=self._query_current).pack(side='left', padx=(6, 0))
|
||||||
card, c = self._card(col,'光机命令 — 预设 / 自定义 / TEC',
|
card, c = self._card(col,'光机命令 — 预设 / 自定义 / TEC',
|
||||||
right_widget=cur_frame)
|
right_widget=cur_frame)
|
||||||
card.grid(row=2, column=0, sticky='ew', pady=(10, 0))
|
card.grid(row=3, column=0, sticky='ew', pady=(10, 0))
|
||||||
row1 = ctk.CTkFrame(c, fg_color='transparent')
|
row1 = ctk.CTkFrame(c, fg_color='transparent')
|
||||||
row1.pack(fill='x')
|
row1.pack(fill='x')
|
||||||
for name, cmd in (('开光机', 'M730S0'), ('关光机', 'M730S1'),
|
for name, cmd in (('开光机', 'M730S0'), ('关光机', 'M730S1'),
|
||||||
@@ -382,7 +455,7 @@ class App(ctk.CTk):
|
|||||||
|
|
||||||
# -- 快捷滑条 --
|
# -- 快捷滑条 --
|
||||||
card, c = self._card(col,'快捷滑条 — 光强 / 定时投光 / TEC 温度')
|
card, c = self._card(col,'快捷滑条 — 光强 / 定时投光 / TEC 温度')
|
||||||
card.grid(row=3, column=0, sticky='ew', pady=(10, 0))
|
card.grid(row=4, column=0, sticky='ew', pady=(10, 0))
|
||||||
rowa = ctk.CTkFrame(c, fg_color='transparent')
|
rowa = ctk.CTkFrame(c, fg_color='transparent')
|
||||||
rowa.pack(fill='x')
|
rowa.pack(fill='x')
|
||||||
ctk.CTkLabel(rowa, text='光强(54-800):').pack(side='left')
|
ctk.CTkLabel(rowa, text='光强(54-800):').pack(side='left')
|
||||||
@@ -499,16 +572,13 @@ class App(ctk.CTk):
|
|||||||
self._set_text(self.txt_hex, edid_parse.hex_dump(d['edid']))
|
self._set_text(self.txt_hex, edid_parse.hex_dump(d['edid']))
|
||||||
|
|
||||||
def _clear_edid_rows(self):
|
def _clear_edid_rows(self):
|
||||||
for w in self.edid_scroll.winfo_children():
|
self._set_text(self.txt_edid, '')
|
||||||
w.destroy()
|
|
||||||
|
|
||||||
def _add_edid_row(self, k, v):
|
def _add_edid_row(self, k, v):
|
||||||
row = ctk.CTkFrame(self.edid_scroll, fg_color='transparent')
|
self.txt_edid.configure(state='normal')
|
||||||
row.pack(fill='x', pady=1)
|
self.txt_edid.insert('end', f'{k:<16}{v}\n')
|
||||||
ctk.CTkLabel(row, text=k, width=132, anchor='w',
|
self.txt_edid.see('end')
|
||||||
text_color='gray60').pack(side='left')
|
self.txt_edid.configure(state='disabled')
|
||||||
ctk.CTkLabel(row, text=v, anchor='w').pack(side='left',
|
|
||||||
fill='x', expand=True)
|
|
||||||
|
|
||||||
def _apply_mode(self):
|
def _apply_mode(self):
|
||||||
d = self._cur_display()
|
d = self._cur_display()
|
||||||
@@ -676,6 +746,13 @@ class App(ctk.CTk):
|
|||||||
# ============================================================
|
# ============================================================
|
||||||
# 光机控制(RS485)
|
# 光机控制(RS485)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
def _dlpc_on_frame(self, fr):
|
||||||
|
"""结构化应答帧(串口线程): 电源自检/功率检测序列进行中时路由给状态机"""
|
||||||
|
if self._pd_seq:
|
||||||
|
self._dlpc_log_q.put(('pdframe', fr))
|
||||||
|
elif self._pwr_seq:
|
||||||
|
self._dlpc_log_q.put(('pwrframe', fr))
|
||||||
|
|
||||||
def _dlpc_on_event(self, line):
|
def _dlpc_on_event(self, line):
|
||||||
# 温度查询应答: okTL:<0.1°C>, 依发送顺序归入 DMD/LAMP 实时显示框
|
# 温度查询应答: okTL:<0.1°C>, 依发送顺序归入 DMD/LAMP 实时显示框
|
||||||
m = re.search(r'← okTL:(-?\d+)', line)
|
m = re.search(r'← okTL:(-?\d+)', line)
|
||||||
@@ -721,6 +798,8 @@ class App(ctk.CTk):
|
|||||||
else:
|
else:
|
||||||
color = 'gray60'
|
color = 'gray60'
|
||||||
self.lbl_dlpc_st.configure(text=text, text_color=color)
|
self.lbl_dlpc_st.configure(text=text, text_color=color)
|
||||||
|
if text.startswith(('已断开', '串口丢失')):
|
||||||
|
self._serial_reset_state()
|
||||||
elif kind == 'temp':
|
elif kind == 'temp':
|
||||||
if text.startswith('DMD'):
|
if text.startswith('DMD'):
|
||||||
self.var_dmd.set(text)
|
self.var_dmd.set(text)
|
||||||
@@ -728,7 +807,12 @@ class App(ctk.CTk):
|
|||||||
self.var_lamp.set(text)
|
self.var_lamp.set(text)
|
||||||
elif kind == 'current':
|
elif kind == 'current':
|
||||||
self.var_current.set(text)
|
self.var_current.set(text)
|
||||||
self._dlpc_log(text)
|
elif kind == 'pdframe':
|
||||||
|
self._pd_step_done(text.type_code == 0xF0, text)
|
||||||
|
elif kind == 'pwrframe':
|
||||||
|
self._pwr_step_done(text)
|
||||||
|
else:
|
||||||
|
self._dlpc_log(text)
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
pass
|
pass
|
||||||
connected = self.dlpc.is_connected()
|
connected = self.dlpc.is_connected()
|
||||||
@@ -774,6 +858,7 @@ class App(ctk.CTk):
|
|||||||
def _dlpc_toggle(self):
|
def _dlpc_toggle(self):
|
||||||
if self.dlpc.is_connected():
|
if self.dlpc.is_connected():
|
||||||
self.dlpc.close()
|
self.dlpc.close()
|
||||||
|
self._serial_reset_state() # 断开时清序列/定时器/应答归位, 防旧账错配
|
||||||
return
|
return
|
||||||
port = self._dlpc_selected_port()
|
port = self._dlpc_selected_port()
|
||||||
if not port:
|
if not port:
|
||||||
@@ -792,10 +877,28 @@ class App(ctk.CTk):
|
|||||||
config.save_slots(self.slots, self.area_var.get()) # 记住本次串口
|
config.save_slots(self.slots, self.area_var.get()) # 记住本次串口
|
||||||
self.dlpc.open(port, baud, bytesize=bytesize, parity=parity, stopbits=stopbits)
|
self.dlpc.open(port, baud, bytesize=bytesize, parity=parity, stopbits=stopbits)
|
||||||
|
|
||||||
|
def _serial_reset_state(self):
|
||||||
|
"""断开/失连时清理进行中的序列与应答归位队列(不碰串口线程本身)"""
|
||||||
|
self._pd_seq.clear()
|
||||||
|
self._pwr_seq.clear()
|
||||||
|
for t in (self._pd_timer, self._pwr_timer):
|
||||||
|
if t:
|
||||||
|
try:
|
||||||
|
self.after_cancel(t)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
self._pd_timer = self._pwr_timer = None
|
||||||
|
self._tl_order.clear()
|
||||||
|
|
||||||
def _dlpc_send(self, cmd):
|
def _dlpc_send(self, cmd):
|
||||||
if not self.dlpc.is_connected():
|
if not self.dlpc.is_connected():
|
||||||
self.lbl_dlpc_st.configure(text='未连接串口', text_color='#E07A3F')
|
self.lbl_dlpc_st.configure(text='未连接串口', text_color='#E07A3F')
|
||||||
return
|
return
|
||||||
|
if self._pd_seq or self._pwr_seq:
|
||||||
|
# 序列进行中: 手动命令的应答帧会被序列错认领(它不区分应答属于哪条
|
||||||
|
# 命令, 来一帧消费一步), 值会错位 —— 拒绝并提示, 序列结束再发
|
||||||
|
self._dlpc_log(f'序列进行中, 命令已忽略: {cmd}')
|
||||||
|
return
|
||||||
self.dlpc.send(cmd)
|
self.dlpc.send(cmd)
|
||||||
|
|
||||||
def _dlpc_send_preset(self):
|
def _dlpc_send_preset(self):
|
||||||
@@ -810,6 +913,141 @@ class App(ctk.CTk):
|
|||||||
if cmd:
|
if cmd:
|
||||||
self._dlpc_send(cmd)
|
self._dlpc_send(cmd)
|
||||||
|
|
||||||
|
# -- 电源检查: 自检序列 + 功率读数 --
|
||||||
|
|
||||||
|
def _pd_selftest(self):
|
||||||
|
"""电源自检: 依序 M301(协议) → M302(挡位最大电流) → M303(实测母线电压),
|
||||||
|
应答帧驱动序列前进(成功=TYPE 0xF0), 结束后按 _pd_fpdo_verdict 判定 FPDO"""
|
||||||
|
if not self.dlpc.is_connected():
|
||||||
|
self.lbl_dlpc_st.configure(text='未连接串口', text_color='#E07A3F')
|
||||||
|
return
|
||||||
|
if self._pd_seq:
|
||||||
|
return # 进行中, 忽略重复触发
|
||||||
|
self._pd_seq = [('M301', 'pd'), ('M302', 'fpdo_ma'), ('M303', 'meas_mv')]
|
||||||
|
self._pd_values = {}
|
||||||
|
self._pd_chip_reset()
|
||||||
|
self._dlpc_log('电源自检: 开始')
|
||||||
|
self._pd_step_next()
|
||||||
|
|
||||||
|
def _pd_chip_reset(self):
|
||||||
|
self.chip_pd.configure(fg_color=CHIP_IDLE,
|
||||||
|
text_color=CHIP_IDLE_TEXT, text='PD')
|
||||||
|
self.chip_fpdo.configure(fg_color=CHIP_IDLE, text_color=CHIP_IDLE_TEXT)
|
||||||
|
self.var_fpdo.set('FPDO: —')
|
||||||
|
|
||||||
|
def _pd_step_next(self):
|
||||||
|
if not self._pd_seq:
|
||||||
|
self._pd_fpdo_verdict()
|
||||||
|
self._dlpc_log('电源自检: 完成')
|
||||||
|
return
|
||||||
|
self.dlpc.send(self._pd_seq[0][0])
|
||||||
|
self._pd_timer = self.after(3000, lambda: self._pd_step_done(False, None))
|
||||||
|
|
||||||
|
def _pd_step_done(self, ok, fr):
|
||||||
|
if not self._pd_seq:
|
||||||
|
return
|
||||||
|
if self._pd_timer:
|
||||||
|
self.after_cancel(self._pd_timer)
|
||||||
|
self._pd_timer = None
|
||||||
|
cmd, kind = self._pd_seq.pop(0)
|
||||||
|
raw = dlpc_rs485.payload_bytes(fr) if fr is not None else b''
|
||||||
|
if ok and kind == 'pd':
|
||||||
|
proto = raw.decode('ascii', 'replace').strip()
|
||||||
|
good = proto in ('PD', 'EPR')
|
||||||
|
self.chip_pd.configure(fg_color=CHIP_OK if good else CHIP_ERR,
|
||||||
|
text_color='#FFFFFF', text=proto or 'PD')
|
||||||
|
elif ok and kind == 'fpdo_ma' and len(raw) == 2:
|
||||||
|
self._pd_values['ma'] = dlpc_rs485.payload_u16_be(raw)
|
||||||
|
elif ok and kind == 'meas_mv' and len(raw) == 2:
|
||||||
|
self._pd_values['mv'] = dlpc_rs485.payload_u16_be(raw)
|
||||||
|
if ok:
|
||||||
|
self._pd_step_next()
|
||||||
|
else: # 出错即中止
|
||||||
|
self._pd_seq.clear()
|
||||||
|
if kind == 'pd':
|
||||||
|
self.chip_pd.configure(fg_color=CHIP_ERR, text_color='#FFFFFF',
|
||||||
|
text='ERR')
|
||||||
|
elif kind == 'fpdo_ma':
|
||||||
|
self.chip_fpdo.configure(fg_color=CHIP_ERR, text_color='#FFFFFF')
|
||||||
|
self.var_fpdo.set('FPDO: ERR')
|
||||||
|
self._dlpc_log('电源自检: 应答错误/超时, 序列中止')
|
||||||
|
|
||||||
|
def _pd_fpdo_verdict(self):
|
||||||
|
"""FPDO 判定: 电压挡位由 M303 实测母线电压就近判定(标准 PD 固定挡
|
||||||
|
5/9/12/15/20/28V, 容差 ±5%; CH224Q 0x0A 只写不可读, 挡位只能实测判定),
|
||||||
|
电流为 M302 挡位最大电流。默认挡 12V 且 ≥3A -> 绿底;
|
||||||
|
挡位不符(如 9V 挡) -> 红底; 实测电压不落在任何标准挡 -> ERR"""
|
||||||
|
mv = self._pd_values.get('mv')
|
||||||
|
ma = self._pd_values.get('ma')
|
||||||
|
if mv is None or ma is None:
|
||||||
|
self.chip_fpdo.configure(fg_color=CHIP_ERR, text_color='#FFFFFF')
|
||||||
|
self.var_fpdo.set('FPDO: ERR')
|
||||||
|
return
|
||||||
|
gear = next((g for g in (5, 9, 12, 15, 20, 28)
|
||||||
|
if abs(mv - g * 1000) <= g * 50), None) # ±5% = g*50 mV
|
||||||
|
a_txt = f'{ma / 1000:g}'
|
||||||
|
if gear is None:
|
||||||
|
self.chip_fpdo.configure(fg_color=CHIP_ERR, text_color='#FFFFFF')
|
||||||
|
self.var_fpdo.set('FPDO: ERR')
|
||||||
|
elif gear == 12 and ma >= 3000:
|
||||||
|
self.chip_fpdo.configure(fg_color=CHIP_OK, text_color='#FFFFFF')
|
||||||
|
self.var_fpdo.set(f'FPDO: 12V@{a_txt}A')
|
||||||
|
else:
|
||||||
|
self.chip_fpdo.configure(fg_color=CHIP_ERR, text_color='#FFFFFF')
|
||||||
|
self.var_fpdo.set(f'FPDO: {gear}V@{a_txt}A')
|
||||||
|
|
||||||
|
def _pwr_query(self):
|
||||||
|
"""功率检测: M303 电压 + M304 电流(按有符号) + M305 功率(u32 mW)"""
|
||||||
|
if not self.dlpc.is_connected():
|
||||||
|
self.lbl_dlpc_st.configure(text='未连接串口', text_color='#E07A3F')
|
||||||
|
return
|
||||||
|
if self._pwr_seq:
|
||||||
|
return
|
||||||
|
self._pwr_seq = [('M303', 'mv'), ('M304', 'ma'), ('M305', 'mw')]
|
||||||
|
self._pwr_values = {}
|
||||||
|
self._dlpc_log('功率检测: 开始')
|
||||||
|
self._pwr_step_next()
|
||||||
|
|
||||||
|
def _pwr_step_next(self):
|
||||||
|
if not self._pwr_seq:
|
||||||
|
self._pwr_update(self._pwr_values.get('mv'),
|
||||||
|
self._pwr_values.get('ma'),
|
||||||
|
self._pwr_values.get('mw'))
|
||||||
|
self._dlpc_log('功率检测: 完成')
|
||||||
|
return
|
||||||
|
self.dlpc.send(self._pwr_seq[0][0])
|
||||||
|
self._pwr_timer = self.after(3000, lambda: self._pwr_step_done(None))
|
||||||
|
|
||||||
|
def _pwr_step_done(self, fr):
|
||||||
|
if not self._pwr_seq:
|
||||||
|
return
|
||||||
|
if self._pwr_timer:
|
||||||
|
self.after_cancel(self._pwr_timer)
|
||||||
|
self._pwr_timer = None
|
||||||
|
cmd, kind = self._pwr_seq.pop(0)
|
||||||
|
# 各步载荷长度: 电压/电流 2 字节, 功率 4 字节(u32)
|
||||||
|
want_len = {'mv': 2, 'ma': 2, 'mw': 4}[kind]
|
||||||
|
raw = dlpc_rs485.payload_bytes(fr) if fr is not None else b''
|
||||||
|
if fr is None or fr.type_code != 0xF0 or len(raw) != want_len:
|
||||||
|
self._pwr_seq.clear()
|
||||||
|
self.var_pwr.set('电压: ERR 电流: — 功率: —')
|
||||||
|
self._dlpc_log('功率检测: 应答错误/超时, 中止')
|
||||||
|
return
|
||||||
|
if kind == 'mv':
|
||||||
|
self._pwr_values['mv'] = dlpc_rs485.payload_u16_be(raw)
|
||||||
|
elif kind == 'ma':
|
||||||
|
self._pwr_values['ma'] = dlpc_rs485.payload_s16_be(raw)
|
||||||
|
elif kind == 'mw':
|
||||||
|
self._pwr_values['mw'] = dlpc_rs485.payload_u32_be(raw)
|
||||||
|
self._pwr_step_next()
|
||||||
|
|
||||||
|
def _pwr_update(self, v_mv, ma, mw):
|
||||||
|
"""功率读数框更新: 电压 V / 电流 mA / 功率 W(mW 换算, 两位小数; 缺项显示 —)"""
|
||||||
|
v = f'{v_mv / 1000:.2f} V' if v_mv is not None else '—'
|
||||||
|
a = f'{ma} mA' if ma is not None else '—'
|
||||||
|
w = f'{mw / 1000:.2f} W' if mw is not None else '—'
|
||||||
|
self.var_pwr.set(f'电压: {v} 电流: {a} 功率: {w}')
|
||||||
|
|
||||||
def _light_entry_apply(self, _evt=None):
|
def _light_entry_apply(self, _evt=None):
|
||||||
"""滑条数值输入框回车: 校验并限幅 54-800, 同步回滑条"""
|
"""滑条数值输入框回车: 校验并限幅 54-800, 同步回滑条"""
|
||||||
try:
|
try:
|
||||||
@@ -875,9 +1113,13 @@ class App(ctk.CTk):
|
|||||||
self._dlpc_send(f'M8S{v}')
|
self._dlpc_send(f'M8S{v}')
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
try: # 取消待触发的轮询回调, 避免销毁后 Tcl 报错
|
try: # 取消待触发的轮询/自检/功率超时回调, 避免销毁后 Tcl 报错
|
||||||
if self._poll_job:
|
if self._poll_job:
|
||||||
self.after_cancel(self._poll_job)
|
self.after_cancel(self._poll_job)
|
||||||
|
if self._pd_timer:
|
||||||
|
self.after_cancel(self._pd_timer)
|
||||||
|
if self._pwr_timer:
|
||||||
|
self.after_cancel(self._pwr_timer)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
try: # 两种退出路径(关窗/--seconds 自动关)都收掉串口线程
|
try: # 两种退出路径(关窗/--seconds 自动关)都收掉串口线程
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
"""
|
"""
|
||||||
把 hdmi_gui.py 打包成单文件 exe(工具名: DLPilot)
|
把 hdmi_gui.py 打包成单文件 exe(工具名: DLPilot)
|
||||||
================================
|
================================
|
||||||
使用 PyInstaller --onefile --noconsole: Python 解释器 + 标准库 + tkinter
|
使用 PyInstaller --onefile --noconsole: Python 解释器、PySide6 和
|
||||||
全部打进一个 exe, 目标机器无需安装任何依赖。
|
PySide6-Fluent-Widgets 全部打进一个 exe, 目标机器无需安装依赖。
|
||||||
|
|
||||||
用法:
|
用法:
|
||||||
python build_exe.py 自动安装 PyInstaller(如缺)并打包
|
python build_exe.py 自动安装 PyInstaller(如缺)并打包
|
||||||
@@ -35,13 +35,22 @@ def ensure_pyinstaller():
|
|||||||
|
|
||||||
|
|
||||||
def extra_collect_args():
|
def extra_collect_args():
|
||||||
"""CustomTkinter 的主题/字体等数据文件必须显式收集, 否则打包后 GUI 启动报错"""
|
"""Fluent Widgets 的主题资源必须收集; PyInstaller 自带 Qt hooks 会处理 PySide6。"""
|
||||||
try:
|
try:
|
||||||
import customtkinter # noqa: F401
|
import qfluentwidgets # noqa: F401
|
||||||
return ['--collect-all', 'customtkinter']
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print('警告: 未安装 customtkinter, 打包产物将无法启动 GUI!')
|
print('警告: 未安装 PySide6-Fluent-Widgets, 请先执行 pip install PySide6-Fluent-Widgets')
|
||||||
return []
|
return []
|
||||||
|
return ['--collect-all', 'qfluentwidgets']
|
||||||
|
|
||||||
|
|
||||||
|
def qt_icu_args():
|
||||||
|
"""Qt6Core imports the unversioned Windows ICU API. PyInstaller can
|
||||||
|
otherwise pick Poppler's ICU 78 from PATH, whose suffixed exports make
|
||||||
|
QtCore.pyd fail with WinError 127 on startup."""
|
||||||
|
if os.name == 'nt' and os.path.exists(r'C:\Windows\System32\icuuc.dll'):
|
||||||
|
return ['--add-binary', r'C:\Windows\System32\icuuc.dll;.']
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
def remove_stale(exe_path):
|
def remove_stale(exe_path):
|
||||||
@@ -68,7 +77,7 @@ def build(name, extra_args):
|
|||||||
cmd = [sys.executable, '-m', 'PyInstaller',
|
cmd = [sys.executable, '-m', 'PyInstaller',
|
||||||
'--onefile', '--clean', '--name', name,
|
'--onefile', '--clean', '--name', name,
|
||||||
'--distpath', dist, '--workpath', work, '--specpath', work,
|
'--distpath', dist, '--workpath', work, '--specpath', work,
|
||||||
] + extra_args + extra_collect_args() + [os.path.join(SRC, 'hdmi_gui.py')]
|
] + extra_args + extra_collect_args() + qt_icu_args() + [os.path.join(SRC, 'hdmi_gui.py')]
|
||||||
if os.path.exists(ICO):
|
if os.path.exists(ICO):
|
||||||
# exe 文件图标 + 运行时窗口图标资源(从 _MEIPASS 读取)
|
# exe 文件图标 + 运行时窗口图标资源(从 _MEIPASS 读取)
|
||||||
cmd += ['--icon', ICO, '--add-data', f'{ICO};.']
|
cmd += ['--icon', ICO, '--add-data', f'{ICO};.']
|
||||||
@@ -7,7 +7,9 @@ DLPC3421 光机 RS485 控制链路(板上 GD32E230 作 RS485→I2C 网关)
|
|||||||
响应语义/错误码/就绪门禁与实测帧示例):
|
响应语义/错误码/就绪门禁与实测帧示例):
|
||||||
物理层 RS485 半双工 115200 8N1(PC 经 USB-RS485 转换器接板, DE 由 MCU 硬件换向)
|
物理层 RS485 半双工 115200 8N1(PC 经 USB-RS485 转换器接板, DE 由 MCU 硬件换向)
|
||||||
命令帧 D5 01 LEN <ASCII命令> CRC 01=板类型, LEN=命令字节数
|
命令帧 D5 01 LEN <ASCII命令> CRC 01=板类型, LEN=命令字节数
|
||||||
响应帧 B5 TYPE LEN <payload> CRC payload 为 ASCII(ok / err:OL / okTL:246 ...)
|
响应帧 B5 TYPE LEN <payload> CRC payload 为 ASCII(ok / err:OL / okTL:246 ...),
|
||||||
|
例外: M303/M304/M305 载荷为大端二进制
|
||||||
|
(SQ52205 电源实测, 见 POWER_COMMANDS)
|
||||||
CRC 帧内第 2 字节(板类型)起累加到最后一个 payload 字节, 取低 8 位
|
CRC 帧内第 2 字节(板类型)起累加到最后一个 payload 字节, 取低 8 位
|
||||||
帧长 最小 6 字节, 最大 32 字节
|
帧长 最小 6 字节, 最大 32 字节
|
||||||
就绪门禁: DLPC3421 启动完成前 M730/M731/M732 被拒(回 0xFF), 属预期。
|
就绪门禁: DLPC3421 启动完成前 M730/M731/M732 被拒(回 0xFF), 属预期。
|
||||||
@@ -81,6 +83,53 @@ PRESETS = (
|
|||||||
Frame = collections.namedtuple('Frame', 'type_code payload raw')
|
Frame = collections.namedtuple('Frame', 'type_code payload raw')
|
||||||
|
|
||||||
|
|
||||||
|
# --- M303/M304/M305(SQ52205 电源实测值查询): 成功载荷为原始二进制(非 ASCII) ---
|
||||||
|
# M303 母线电压: u16 大端, 单位 mV; 12V 轨正常窗口 11400~12600(标称 ±5%)
|
||||||
|
# M304 负载电流: s16 大端补码, 单位 mA; 正=正向, 负=反向(固件原样上总线,
|
||||||
|
# 上位机必须按有符号解析)。例: 载荷 FF 06 = -250 mA
|
||||||
|
# M305 负载功率: u32 大端(LEN=4, 勿复用双字节解析), 单位 mW, 恒非负;
|
||||||
|
# 量程约 0~295000 mW; 能量方向看 M304 符号
|
||||||
|
# 错误时 TYPE=0xFF, 载荷为错误信息字节串(走通用译码路径)
|
||||||
|
POWER_COMMANDS = ('M303', 'M304', 'M305')
|
||||||
|
|
||||||
|
|
||||||
|
def payload_bytes(fr):
|
||||||
|
"""响应帧的原始载荷字节(Frame.payload 是 ASCII 解码视图, 二进制载荷请用本函数)"""
|
||||||
|
return fr.raw[3:-1]
|
||||||
|
|
||||||
|
|
||||||
|
def payload_u16_be(raw):
|
||||||
|
return (raw[0] << 8) | raw[1]
|
||||||
|
|
||||||
|
|
||||||
|
def payload_s16_be(raw):
|
||||||
|
v = payload_u16_be(raw)
|
||||||
|
return v - 0x10000 if v & 0x8000 else v
|
||||||
|
|
||||||
|
|
||||||
|
def payload_u32_be(raw):
|
||||||
|
return (raw[0] << 24) | (raw[1] << 16) | (raw[2] << 8) | raw[3]
|
||||||
|
|
||||||
|
|
||||||
|
def format_power(cmd, fr):
|
||||||
|
"""电源实测命令成功应答 -> 人读文本; 非电源命令/失败/载荷异常返回 None"""
|
||||||
|
if cmd not in POWER_COMMANDS:
|
||||||
|
return None
|
||||||
|
raw = payload_bytes(fr)
|
||||||
|
if cmd == 'M305':
|
||||||
|
if fr.type_code != 0xF0 or len(raw) != 4:
|
||||||
|
return None
|
||||||
|
mw = payload_u32_be(raw)
|
||||||
|
return f'{mw} mW ({mw / 1000:.2f} W)'
|
||||||
|
if fr.type_code != 0xF0 or len(raw) != 2:
|
||||||
|
return None
|
||||||
|
if cmd == 'M303':
|
||||||
|
mv = payload_u16_be(raw)
|
||||||
|
return f'{mv} mV ({mv / 1000:.2f} V)'
|
||||||
|
ma = payload_s16_be(raw)
|
||||||
|
return f'{ma:+d} mA'
|
||||||
|
|
||||||
|
|
||||||
def sum_crc(data):
|
def sum_crc(data):
|
||||||
"""帧内第 2 字节(板类型)起累加到末 payload 字节, 取低 8 位(不含包头与 CRC)"""
|
"""帧内第 2 字节(板类型)起累加到末 payload 字节, 取低 8 位(不含包头与 CRC)"""
|
||||||
return sum(data) & 0xFF
|
return sum(data) & 0xFF
|
||||||
@@ -136,15 +185,29 @@ class FrameParser:
|
|||||||
del self._buf[:1]
|
del self._buf[:1]
|
||||||
|
|
||||||
|
|
||||||
|
def _clean(s):
|
||||||
|
"""控制字符 -> '·': 二进制载荷按 ASCII 解出的 NUL 等会污染日志行,
|
||||||
|
且 Windows 剪贴板遇 NUL 直接截断复制内容"""
|
||||||
|
return ''.join(c if ord(c) >= 0x20 and ord(c) != 0x7F else '·' for c in s)
|
||||||
|
|
||||||
|
|
||||||
def describe(fr):
|
def describe(fr):
|
||||||
"""响应帧 -> 人读文本: TYPE 译码 + payload, err:N 追加 DLPC 错误释义"""
|
"""响应帧 -> 人读文本: TYPE 译码 + payload, err:N 追加 DLPC 错误释义。
|
||||||
|
|
||||||
|
二进制载荷(M303/M304/M305 电源实测)不以 ASCII 展示 —— 改显 hex,
|
||||||
|
避免乱码与 NUL 截断剪贴板(值由 GUI 读数框/CLI format_power 译码)。"""
|
||||||
|
pl = fr.payload
|
||||||
|
if any(ord(c) < 0x20 or ord(c) == 0x7F for c in pl):
|
||||||
|
pl = f'[二进制载荷 {fr.raw[3:-1].hex(" ").upper()}]'
|
||||||
|
else:
|
||||||
|
pl = _clean(pl)
|
||||||
if fr.type_code == 0xF0:
|
if fr.type_code == 0xF0:
|
||||||
text = fr.payload or 'ok'
|
text = pl or 'ok'
|
||||||
else:
|
else:
|
||||||
text = TYPE_NAMES.get(fr.type_code, f'TYPE=0x{fr.type_code:02X}')
|
text = TYPE_NAMES.get(fr.type_code, f'TYPE=0x{fr.type_code:02X}')
|
||||||
if fr.payload:
|
if pl:
|
||||||
text += f' {fr.payload}'
|
text += f' {pl}'
|
||||||
m = re.search(r'err:(\d+)', fr.payload)
|
m = re.search(r'err:(\d+)', pl)
|
||||||
if m:
|
if m:
|
||||||
text += f'({DLPC_ERR_NAMES.get(int(m.group(1)), "未知错误码")})'
|
text += f'({DLPC_ERR_NAMES.get(int(m.group(1)), "未知错误码")})'
|
||||||
return text
|
return text
|
||||||
@@ -158,8 +221,8 @@ class DLPC485:
|
|||||||
回调在后台线程触发, GUI 侧需自行投递回主线程(见 hdmi_gui 的轮询队列)。
|
回调在后台线程触发, GUI 侧需自行投递回主线程(见 hdmi_gui 的轮询队列)。
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, on_event, on_status):
|
def __init__(self, on_event, on_status, on_frame=None):
|
||||||
self.on_event, self.on_status = on_event, on_status
|
self.on_event, self.on_status, self.on_frame = on_event, on_status, on_frame
|
||||||
self.q = queue.Queue()
|
self.q = queue.Queue()
|
||||||
self._target = None # 想态 (port, baud, bytesize, parity, stopbits)
|
self._target = None # 想态 (port, baud, bytesize, parity, stopbits)
|
||||||
self._open_key = None # 当前已打开串口的参数元组
|
self._open_key = None # 当前已打开串口的参数元组
|
||||||
@@ -252,7 +315,9 @@ class DLPC485:
|
|||||||
port, baud, bytesize=bytesizes.get(dbsize, serial.EIGHTBITS),
|
port, baud, bytesize=bytesizes.get(dbsize, serial.EIGHTBITS),
|
||||||
parity=parities.get(parity, serial.PARITY_NONE),
|
parity=parities.get(parity, serial.PARITY_NONE),
|
||||||
stopbits=stopbits.get(sbits, serial.STOPBITS_ONE),
|
stopbits=stopbits.get(sbits, serial.STOPBITS_ONE),
|
||||||
timeout=0.15)
|
timeout=0.15,
|
||||||
|
write_timeout=1.0) # 写超时: 转换器停滞时 write 会
|
||||||
|
# 永久阻塞并卡死线程, 必须设上限
|
||||||
self.parser = FrameParser()
|
self.parser = FrameParser()
|
||||||
self._open_key = target
|
self._open_key = target
|
||||||
self.on_status(f'已连接 {port} @ {baud} '
|
self.on_status(f'已连接 {port} @ {baud} '
|
||||||
@@ -261,7 +326,19 @@ class DLPC485:
|
|||||||
self.ser = None
|
self.ser = None
|
||||||
with self._lock:
|
with self._lock:
|
||||||
self._target = None
|
self._target = None
|
||||||
self.on_status(f'连接失败: {e}')
|
blob = str(e) + repr(e)
|
||||||
|
if 'PermissionError' in blob or '拒绝访问' in blob \
|
||||||
|
or 'Access is denied' in blob:
|
||||||
|
hint = '串口被占用(串口助手/另一实例?)'
|
||||||
|
elif 'FileNotFoundError' in blob or '找不到指定的' in blob \
|
||||||
|
or 'No such file' in blob:
|
||||||
|
hint = '串口不存在,请刷新后重选'
|
||||||
|
else:
|
||||||
|
hint = '无法打开,详情见日志'
|
||||||
|
# 状态标签只放短提示(长异常串会撑爆参数行把窗口拉长),
|
||||||
|
# 完整异常走 on_event 进收发日志
|
||||||
|
self.on_status(f'连接失败: {hint}')
|
||||||
|
self.on_event(f'连接失败: {e!r}')
|
||||||
if self.ser is not None:
|
if self.ser is not None:
|
||||||
try:
|
try:
|
||||||
item = None
|
item = None
|
||||||
@@ -276,10 +353,17 @@ class DLPC485:
|
|||||||
data = self.ser.read(256)
|
data = self.ser.read(256)
|
||||||
if data:
|
if data:
|
||||||
for fr in self.parser.feed(data):
|
for fr in self.parser.feed(data):
|
||||||
|
if self.on_frame is not None:
|
||||||
|
self.on_frame(fr) # 结构化帧(二进制载荷场景用)
|
||||||
self.on_event(f'← {describe(fr)} '
|
self.on_event(f'← {describe(fr)} '
|
||||||
f'[{fr.raw.hex(" ").upper()}]')
|
f'[{fr.raw.hex(" ").upper()}]')
|
||||||
except OSError:
|
except OSError:
|
||||||
|
try:
|
||||||
|
self.ser.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
self.ser = None
|
self.ser = None
|
||||||
|
self._open_key = None # 必须同步清除, 否则同参数重连被当作已打开而跳过
|
||||||
with self._lock:
|
with self._lock:
|
||||||
self._target = None
|
self._target = None
|
||||||
self.on_status('串口丢失(设备拔出?), 请重新连接')
|
self.on_status('串口丢失(设备拔出?), 请重新连接')
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
================================================================
|
================================================================
|
||||||
配合 demo 板当前 EDID 首选时序 800x600@60, 全屏纯色输出。
|
配合 demo 板当前 EDID 首选时序 800x600@60, 全屏纯色输出。
|
||||||
用法: python gen_solid_colors.py → 输出到 ../assets/solid_*.png
|
用法: python gen_solid_colors.py → 输出到 ../assets/solid_*.png
|
||||||
在 HDMI-Tool 中通过自定义栏位(⚙ 换图)加载, 发布包随附。
|
在 DLPilot 中通过自定义栏位(⚙ 换图)加载, 发布包随附。
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@@ -6,7 +6,7 @@ HDMI EDID 查看器 + 测试图案投屏 + 光机控制 — 入口与命令行
|
|||||||
配合 LT8619C(HDMI 转 RGB888)→ DLPC3421 转接板调试使用。
|
配合 LT8619C(HDMI 转 RGB888)→ DLPC3421 转接板调试使用。
|
||||||
|
|
||||||
模块划分(重构自原单文件):
|
模块划分(重构自原单文件):
|
||||||
app_gui.py CustomTkinter 主界面(双栏仪表盘)
|
app_fluent.py PySide6-Fluent-Widgets 主界面(双栏仪表盘)
|
||||||
display_win.py Win32 显示器枚举/分辨率/拓扑
|
display_win.py Win32 显示器枚举/分辨率/拓扑
|
||||||
edid_parse.py EDID 1.4 / CEA-861 解析
|
edid_parse.py EDID 1.4 / CEA-861 解析
|
||||||
patterns.py 测试图案全屏投屏窗口
|
patterns.py 测试图案全屏投屏窗口
|
||||||
@@ -45,9 +45,9 @@ from patterns import PATTERN_NAMES, show_pattern, show_pattern_image
|
|||||||
|
|
||||||
|
|
||||||
def run_gui(auto_close=0):
|
def run_gui(auto_close=0):
|
||||||
"""启动 CustomTkinter 主界面(实现在 app_gui.py)"""
|
"""启动 PySide6-Fluent-Widgets 主界面(实现在 app_fluent.py)"""
|
||||||
import app_gui
|
import app_fluent
|
||||||
app_gui.run_gui(auto_close)
|
app_fluent.run_gui(auto_close)
|
||||||
|
|
||||||
|
|
||||||
def run_dump(edid_fields=False):
|
def run_dump(edid_fields=False):
|
||||||
@@ -121,7 +121,8 @@ def run_dlpc(port, baud, cmds):
|
|||||||
print('← (35s 超时无响应)')
|
print('← (35s 超时无响应)')
|
||||||
rc = 1
|
rc = 1
|
||||||
else:
|
else:
|
||||||
print(f'← {dlpc_rs485.describe(got)} [{got.raw.hex(" ").upper()}]')
|
nice = dlpc_rs485.format_power(cmd, got) # 电源命令二进制载荷译码
|
||||||
|
print(f'← {nice or dlpc_rs485.describe(got)} [{got.raw.hex(" ").upper()}]')
|
||||||
if got.type_code != 0xF0:
|
if got.type_code != 0xF0:
|
||||||
rc = 1
|
rc = 1
|
||||||
ser.close()
|
ser.close()
|
||||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
@@ -31,7 +31,8 @@ BASE = os.path.dirname(SRC)
|
|||||||
RELEASE = os.path.join(BASE, 'release')
|
RELEASE = os.path.join(BASE, 'release')
|
||||||
ASSETS = os.path.join(BASE, 'assets')
|
ASSETS = os.path.join(BASE, 'assets')
|
||||||
|
|
||||||
PATTERN_GLOBS = ('bw_*.png', 'solid_*.png')
|
# CeramixNano*.png: 校准图案素材(用户提供, 二进制直存 assets/, 无生成脚本)
|
||||||
|
PATTERN_GLOBS = ('bw_*.png', 'solid_*.png', 'CeramixNano*.png')
|
||||||
|
|
||||||
|
|
||||||
def detect_version():
|
def detect_version():
|
||||||
@@ -9,6 +9,19 @@
|
|||||||
|
|
||||||
from config import DEFAULT_AREA, HAS_PIL, Image, ImageTk, PAT_W, PAT_H
|
from config import DEFAULT_AREA, HAS_PIL, Image, ImageTk, PAT_W, PAT_H
|
||||||
|
|
||||||
|
# 当前打开的投屏窗口集合: 支持"新图案替换旧图案"与 close_all() 一键恢复桌面
|
||||||
|
_OPEN = set()
|
||||||
|
|
||||||
|
|
||||||
|
def close_all():
|
||||||
|
"""关闭所有打开的投屏窗口, 恢复桌面"""
|
||||||
|
for top in list(_OPEN):
|
||||||
|
try:
|
||||||
|
top.destroy()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
_OPEN.clear()
|
||||||
|
|
||||||
|
|
||||||
PATTERN_NAMES = {'Red': '纯红', 'Green': '纯绿', 'Blue': '纯蓝',
|
PATTERN_NAMES = {'Red': '纯红', 'Green': '纯绿', 'Blue': '纯蓝',
|
||||||
'Checker': '黑白棋盘格', 'Grid': '网格线'}
|
'Checker': '黑白棋盘格', 'Grid': '网格线'}
|
||||||
@@ -43,8 +56,9 @@ def _area_box(spec, w, h):
|
|||||||
def _open_fullscreen(parent, rect, auto_close=0):
|
def _open_fullscreen(parent, rect, auto_close=0):
|
||||||
"""创建覆盖 rect(x,y,w,h) 的无边框全屏黑底窗口, 返回 (top, cv)
|
"""创建覆盖 rect(x,y,w,h) 的无边框全屏黑底窗口, 返回 (top, cv)
|
||||||
|
|
||||||
只支持 ESC 退出: overrideredirect 窗口必须 focus_force 强取键盘焦点,
|
ESC 退出(需窗口持有键盘焦点); overrideredirect 窗口必须 focus_force
|
||||||
否则收不到按键(Windows 上该组合有效)。
|
强取键盘焦点, 否则收不到按键(Windows 上该组合有效)。
|
||||||
|
窗口登记进 _OPEN: 打开新投屏前会关旧的(替换语义), close_all() 一键全关。
|
||||||
"""
|
"""
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
rx, ry, rw, rh = rect
|
rx, ry, rw, rh = rect
|
||||||
@@ -58,9 +72,16 @@ def _open_fullscreen(parent, rect, auto_close=0):
|
|||||||
cv.pack(fill='both', expand=True)
|
cv.pack(fill='both', expand=True)
|
||||||
|
|
||||||
def close(_evt=None):
|
def close(_evt=None):
|
||||||
|
_OPEN.discard(top)
|
||||||
top.destroy()
|
top.destroy()
|
||||||
|
|
||||||
|
def _on_destroy(e):
|
||||||
|
if e.widget is top: # 子控件销毁也冒泡到此, 只认窗口本身
|
||||||
|
_OPEN.discard(top)
|
||||||
|
|
||||||
top.bind('<Escape>', close)
|
top.bind('<Escape>', close)
|
||||||
|
top.bind('<Destroy>', _on_destroy)
|
||||||
|
_OPEN.add(top)
|
||||||
if auto_close > 0:
|
if auto_close > 0:
|
||||||
top.after(auto_close * 1000, close)
|
top.after(auto_close * 1000, close)
|
||||||
top.focus_force()
|
top.focus_force()
|
||||||
@@ -68,7 +89,9 @@ def _open_fullscreen(parent, rect, auto_close=0):
|
|||||||
|
|
||||||
|
|
||||||
def show_pattern(parent, rect, kind, auto_close=0, area=DEFAULT_AREA):
|
def show_pattern(parent, rect, kind, auto_close=0, area=DEFAULT_AREA):
|
||||||
"""在 rect 指定的屏幕上全屏出居中测试卡(无任何 OSD 修饰), 区域由 area 指定"""
|
"""在 rect 指定的屏幕上全屏出居中测试卡(无任何 OSD 修饰), 区域由 area 指定。
|
||||||
|
打开前先关闭已有投屏窗口(替换语义, 不会多层叠罗汉)。"""
|
||||||
|
close_all()
|
||||||
top, cv = _open_fullscreen(parent, rect, auto_close)
|
top, cv = _open_fullscreen(parent, rect, auto_close)
|
||||||
|
|
||||||
def draw(_evt=None):
|
def draw(_evt=None):
|
||||||
@@ -107,7 +130,9 @@ def show_pattern(parent, rect, kind, auto_close=0, area=DEFAULT_AREA):
|
|||||||
def show_pattern_image(parent, rect, path, auto_close=0, area=DEFAULT_AREA):
|
def show_pattern_image(parent, rect, path, auto_close=0, area=DEFAULT_AREA):
|
||||||
"""全屏黑底, 图片 1:1 居中于 area 指定的测试卡区域:
|
"""全屏黑底, 图片 1:1 居中于 area 指定的测试卡区域:
|
||||||
小于区域 -> 真实像素居中, 四周黑边;
|
小于区域 -> 真实像素居中, 四周黑边;
|
||||||
大于区域 -> 等效从中心截取(区域外用黑矩形遮挡)"""
|
大于区域 -> 等效从中心截取(区域外用黑矩形遮挡)。
|
||||||
|
打开前先关闭已有投屏窗口(替换语义)。"""
|
||||||
|
close_all()
|
||||||
top, cv = _open_fullscreen(parent, rect, auto_close)
|
top, cv = _open_fullscreen(parent, rect, auto_close)
|
||||||
|
|
||||||
def draw(_evt=None):
|
def draw(_evt=None):
|
||||||
@@ -23,6 +23,7 @@ import re
|
|||||||
import ssl
|
import ssl
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import urllib.error
|
import urllib.error
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import uuid
|
import uuid
|
||||||
@@ -59,15 +60,22 @@ class Api:
|
|||||||
self.headers = {'Authorization': f'token {token}'}
|
self.headers = {'Authorization': f'token {token}'}
|
||||||
self.ctx = ssl._create_unverified_context() if insecure else None
|
self.ctx = ssl._create_unverified_context() if insecure else None
|
||||||
|
|
||||||
def request(self, method, path, data=None, headers=None):
|
def request(self, method, path, data=None, headers=None, retries=4):
|
||||||
req = urllib.request.Request(self.api + path, data=data, method=method,
|
"""发请求; 实例 TLS 间歇性抽风(SSL UNEXPECTED_EOF), 连接级错误自动重试"""
|
||||||
headers={**self.headers, **(headers or {})})
|
last = None
|
||||||
try:
|
for attempt in range(retries):
|
||||||
with urllib.request.urlopen(req, context=self.ctx) as resp:
|
req = urllib.request.Request(self.api + path, data=data, method=method,
|
||||||
body = resp.read()
|
headers={**self.headers, **(headers or {})})
|
||||||
return resp.status, json.loads(body) if body else None
|
try:
|
||||||
except urllib.error.HTTPError as e:
|
with urllib.request.urlopen(req, context=self.ctx) as resp:
|
||||||
return e.code, json.loads(e.read() or b'{}')
|
body = resp.read()
|
||||||
|
return resp.status, json.loads(body) if body else None
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
return e.code, json.loads(e.read() or b'{}')
|
||||||
|
except (urllib.error.URLError, ssl.SSLError, OSError) as e:
|
||||||
|
last = e
|
||||||
|
time.sleep(1.0 + attempt)
|
||||||
|
raise RuntimeError(f'Gitea 请求连续 {retries} 次失败: {last}')
|
||||||
|
|
||||||
def get_json(self, path):
|
def get_json(self, path):
|
||||||
status, data = self.request('GET', path)
|
status, data = self.request('GET', path)
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
"""收发日志上限与队列消费回归自检(无窗口, 离屏渲染)。
|
||||||
|
|
||||||
|
背景: v0.4.3 之前收发日志用 textCursor 手工裁剪, 其中 `cursor.Start` /
|
||||||
|
`cursor.BlockUnderCursor` 是实例级枚举访问 —— PySide6 6.11 移除了该形式,
|
||||||
|
日志一旦超过 500 行, 每次 _dlpc_log 追加后必抛 AttributeError; 且异常会
|
||||||
|
逃出 _poll_dlpc 的 drain 循环(旧 try 只捕获 queue.Empty), 每 tick 最多
|
||||||
|
消费到第一条 event, `_dlpc_log_q` 棘轮积压、日志裁剪与自动滚动全部失效,
|
||||||
|
电源自检/功率检测序列还会被异常打断在启动处(之后所有命令被"序列进行中"
|
||||||
|
拦截)。v0.4.3 改为 setMaximumBlockCount 环形裁剪 + 逐事件异常兜底。
|
||||||
|
|
||||||
|
本测试保证:
|
||||||
|
1. 连续追加 600 行日志不抛异常, document().blockCount() 环形封顶 500, 末行在;
|
||||||
|
2. 单条异常事件(模拟未来引入的坏数据)不中断 _poll_dlpc 本轮队列消费
|
||||||
|
—— 其后的事件仍全部入日志、队列清空。
|
||||||
|
|
||||||
|
运行: python selftest_log.py (依赖 PySide6-Fluent-Widgets 与 pyserial ——
|
||||||
|
串口卡构建后 txt_dlpc 才存在)
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
from PySide6.QtWidgets import QApplication
|
||||||
|
from qfluentwidgets import Theme, setTheme
|
||||||
|
|
||||||
|
import app_fluent
|
||||||
|
import dlpc_rs485
|
||||||
|
|
||||||
|
|
||||||
|
def check_cap(win):
|
||||||
|
for i in range(600):
|
||||||
|
win._dlpc_log(f"cap-line-{i}")
|
||||||
|
blocks = win.txt_dlpc.document().blockCount()
|
||||||
|
has_last = "cap-line-599" in win.txt_dlpc.toPlainText()
|
||||||
|
print(f" 追加 600 行: blockCount={blocks}(封顶 500), 末行在: {has_last}")
|
||||||
|
return blocks <= 500 and has_last
|
||||||
|
|
||||||
|
|
||||||
|
def check_drain_resilience(win):
|
||||||
|
win._timer.stop() # 排除 80ms 轮询定时器干扰
|
||||||
|
win._dlpc_log_q.put(("pdframe", "poison-not-a-frame")) # 该条分发必抛异常
|
||||||
|
win._dlpc_log_q.put(("event", "after-poison-1"))
|
||||||
|
win._dlpc_log_q.put(("event", "after-poison-2"))
|
||||||
|
win._poll_dlpc() # 单次手动驱动(不进事件循环)
|
||||||
|
left = win._dlpc_log_q.qsize()
|
||||||
|
text = win.txt_dlpc.toPlainText()
|
||||||
|
drained = left == 0 and "after-poison-1" in text and "after-poison-2" in text
|
||||||
|
print(f" 坏条目后消费不中断: 残留队列={left}, 后续事件全部写入: {drained}")
|
||||||
|
return drained
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if not dlpc_rs485.HAS_SERIAL:
|
||||||
|
print("FAILED 缺少 pyserial: 串口卡未构建, txt_dlpc 不存在")
|
||||||
|
return 1
|
||||||
|
app = QApplication.instance() or QApplication(sys.argv)
|
||||||
|
setTheme(Theme.AUTO)
|
||||||
|
win = app_fluent.App(0)
|
||||||
|
passed = check_cap(win)
|
||||||
|
passed &= check_drain_resilience(win)
|
||||||
|
win.close()
|
||||||
|
print("ALL PASS" if passed else "FAILED")
|
||||||
|
return 0 if passed else 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -73,5 +73,35 @@ for _name, cmd, _note in d.PRESETS:
|
|||||||
d.build_frame(cmd)
|
d.build_frame(cmd)
|
||||||
print(f'预设 {len(d.PRESETS)} 条全部可组帧: PASS')
|
print(f'预设 {len(d.PRESETS)} 条全部可组帧: PASS')
|
||||||
|
|
||||||
|
# 8) M303/M304(SQ52205 电源实测)回归向量: 上游真机抓取帧
|
||||||
|
check('build_frame(M303)', d.build_frame('M303').hex(' ').upper(),
|
||||||
|
'D5 01 04 4D 33 30 33 E8')
|
||||||
|
check('build_frame(M304)', d.build_frame('M304').hex(' ').upper(),
|
||||||
|
'D5 01 04 4D 33 30 34 E9')
|
||||||
|
frames = d.FrameParser().feed(bytes.fromhex('B5 F0 02 2E F4 14'))
|
||||||
|
check('M303 应答帧', len(frames), 1)
|
||||||
|
check('M303 电压(0x2EF4=12020mV)', d.format_power('M303', frames[0]),
|
||||||
|
'12020 mV (12.02 V)')
|
||||||
|
frames = d.FrameParser().feed(bytes.fromhex('B5 F0 02 00 34 26'))
|
||||||
|
check('M304 应答帧', len(frames), 1)
|
||||||
|
check('M304 电流(0x0034=+52mA)', d.format_power('M304', frames[0]), '+52 mA')
|
||||||
|
check('M304 负值(FF06=-250mA 补码)', d.payload_s16_be(bytes.fromhex('FF 06')), -250)
|
||||||
|
|
||||||
|
# 9) M305(SQ52205 实测功率)回归向量: u32 大端 mW(LEN=4, 算法推演帧)
|
||||||
|
check('build_frame(M305)', d.build_frame('M305').hex(' ').upper(),
|
||||||
|
'D5 01 04 4D 33 30 35 EA')
|
||||||
|
frames = d.FrameParser().feed(bytes.fromhex('B5 F0 04 00 00 8C A0 20'))
|
||||||
|
check('M305 应答帧', len(frames), 1)
|
||||||
|
check('M305 功率(0x8CA0=36000mW)', d.format_power('M305', frames[0]),
|
||||||
|
'36000 mW (36.00 W)')
|
||||||
|
check('M305 拒绝双字节载荷', d.format_power(
|
||||||
|
'M305', d.FrameParser().feed(bytes.fromhex('B5 F0 02 8C A0 1E'))[0]), None)
|
||||||
|
|
||||||
|
# 10) 二进制载荷的日志行安全: 无控制字符(NUL 会截断 Windows 剪贴板), 以 hex 展示
|
||||||
|
frames = d.FrameParser().feed(bytes.fromhex('B5 F0 02 00 34 26')) # M304 应答(含 NUL)
|
||||||
|
desc = d.describe(frames[0])
|
||||||
|
check('二进制载荷 hex 展示', desc, '[二进制载荷 00 34]')
|
||||||
|
check('日志行无控制字符', any(ord(c) < 0x20 for c in desc), False)
|
||||||
|
|
||||||
print('RESULT:', 'FAIL:' + ','.join(fails) if fails else 'ALL PASS')
|
print('RESULT:', 'FAIL:' + ','.join(fails) if fails else 'ALL PASS')
|
||||||
sys.exit(1 if fails else 0)
|
sys.exit(1 if fails else 0)
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
"""主题切换回归自检(无窗口, 离屏渲染)。
|
||||||
|
|
||||||
|
背景: fluent 控件直接 setStyleSheet 的样式会在 setTheme 时被库重刷的自带 qss 冲掉
|
||||||
|
(v0.4.0 RGB swatch 按钮切主题丢底色的根因)。swatch 改走 setCustomStyleSheet、
|
||||||
|
标题字号走 QFont 后,本测试保证:
|
||||||
|
1. Dark -> Light -> Dark -> Light 往返后 9 个 swatch 按钮样式表仍带底色;
|
||||||
|
2. Light 下实际渲染出的按钮中心像素 = swatch 色值(不只样式表字符串存在);
|
||||||
|
3. 标题 24px 加粗(QFont)在往返后不变。
|
||||||
|
|
||||||
|
运行: python selftest_theme.py (依赖 PySide6-Fluent-Widgets)
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
from PySide6.QtGui import QColor
|
||||||
|
from PySide6.QtWidgets import QApplication
|
||||||
|
from qfluentwidgets import PushButton, StrongBodyLabel, Theme, setTheme
|
||||||
|
|
||||||
|
import app_fluent
|
||||||
|
import patterns
|
||||||
|
|
||||||
|
|
||||||
|
def check_style_sheet(win, app):
|
||||||
|
swatches = [b for b in win.findChildren(PushButton) if b.text() in {"55", "AA", "FF"}]
|
||||||
|
assert len(swatches) == 9, f"expect 9 swatch buttons, got {len(swatches)}"
|
||||||
|
title = [l for l in win.findChildren(StrongBodyLabel) if l.text() == "DLPilot"]
|
||||||
|
assert len(title) == 1, "title label not found"
|
||||||
|
colored = sum(1 for b in swatches if "background-color: #" in b.styleSheet())
|
||||||
|
f = title[0].font()
|
||||||
|
print(f" swatch 样式表带底色: {colored}/9, 标题 24px 粗体: "
|
||||||
|
f"{f.pixelSize() == 24 and f.bold()}")
|
||||||
|
return colored == 9 and f.pixelSize() == 24 and f.bold()
|
||||||
|
|
||||||
|
|
||||||
|
def check_rendered_pixel(win, app):
|
||||||
|
"""Light 主题下逐个渲染 swatch,与目标色一致的像素须占明显多数(背景为主,
|
||||||
|
中心处是文字字形,不能只采单点)。"""
|
||||||
|
ok = True
|
||||||
|
for channel, items in patterns.SOLID_ROWS:
|
||||||
|
for label, color in items:
|
||||||
|
button = next(b for b in win.findChildren(PushButton)
|
||||||
|
if b.text() == label and f"background-color: {color}" in b.styleSheet())
|
||||||
|
image = button.grab().toImage()
|
||||||
|
target = QColor(color)
|
||||||
|
total, matched = image.width() * image.height(), 0
|
||||||
|
for y in range(image.height()):
|
||||||
|
for x in range(image.width()):
|
||||||
|
if image.pixelColor(x, y) == target:
|
||||||
|
matched += 1
|
||||||
|
ratio = matched / total
|
||||||
|
same = ratio >= 0.2
|
||||||
|
ok &= same
|
||||||
|
if not same:
|
||||||
|
print(f" 渲染不符: {channel}/{label} 期望 {color} 仅占 {ratio:.0%}")
|
||||||
|
print(f" Light 下渲染像素比对: {'一致' if ok else '存在偏差'}")
|
||||||
|
return ok
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
app = QApplication.instance() or QApplication(sys.argv)
|
||||||
|
setTheme(Theme.AUTO)
|
||||||
|
win = app_fluent.App(0)
|
||||||
|
passed = True
|
||||||
|
for step, theme in (("初始 Dark", Theme.DARK), ("切 Light", Theme.LIGHT),
|
||||||
|
("切回 Dark", Theme.DARK), ("再切 Light", Theme.LIGHT)):
|
||||||
|
setTheme(theme)
|
||||||
|
app.processEvents()
|
||||||
|
print(f"[{step}]")
|
||||||
|
passed &= check_style_sheet(win, app)
|
||||||
|
if theme == Theme.LIGHT:
|
||||||
|
passed &= check_rendered_pixel(win, app)
|
||||||
|
win.close()
|
||||||
|
print("ALL PASS" if passed else "FAILED")
|
||||||
|
return 0 if passed else 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -0,0 +1,393 @@
|
|||||||
|
# DLPilot 使用说明
|
||||||
|
|
||||||
|
**HDMI 源端调试 + 光机控制工具**
|
||||||
|
|
||||||
|
| 项目 | 说明 |
|
||||||
|
|---|---|
|
||||||
|
| 适用版本 | v0.4.3(2026-10-13 发布) |
|
||||||
|
| 适用系统 | Windows 10 / 11 x64,免安装、无需 Python |
|
||||||
|
| 适用对象 | LT8619C(HDMI→RGB888)→ DLPC3421 投影转接板的调试、测试与校准人员 |
|
||||||
|
| 文档日期 | 2026-10-14 |
|
||||||
|
|
||||||
|
DLPilot 是配套投影转接板调试的 PC 端工具,一台电脑同时完成两件事:
|
||||||
|
|
||||||
|
- **HDMI 源端**:查看板卡上报的 EDID、切换输出分辨率、向板卡全屏投放测试图案
|
||||||
|
(纯色、黑白测试图、自定义校准图);
|
||||||
|
- **光机控制**:通过 USB-RS485 控制光机——开关光机、设光强、查温度/电流、
|
||||||
|
PD 电源自检与功率读数、TEC 温控。
|
||||||
|
|
||||||
|
界面上左右两列分别对应这两个功能域,互不干扰,可以只用其中一列。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
[TOC]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. 安装(从压缩包开始)
|
||||||
|
|
||||||
|
### 1.1 拿到安装包
|
||||||
|
|
||||||
|
安装包为 `DLPilot-v0.4.3-win64.zip`(约 67 MB),由我方对接工程师提供。
|
||||||
|
收到后请先核对文件名中的版本号,本文档对应 **v0.4.3**;若版本更新,以随包说明为准。
|
||||||
|
|
||||||
|
### 1.2 解压
|
||||||
|
|
||||||
|
1. 在电脑上选择一个**可写**的本地目录,例如 `D:\Tools\`(不要解压到只读目录、
|
||||||
|
网络共享盘或需要管理员权限才能写入的系统目录,原因见 1.5 节);
|
||||||
|
2. 右键压缩包 →「全部解压」→ 目标路径填 `D:\Tools\`,确认后完成解压;
|
||||||
|
3. 解压后得到一个 `DLPilot` 文件夹。
|
||||||
|
|
||||||
|
> **注意:不要在压缩包预览窗口里直接双击运行 exe。**
|
||||||
|
> 直接从压缩包内运行时程序被解压到临时目录,你配置的自定义图片和串口参数
|
||||||
|
> 会写到临时目录并随其清空而丢失。务必先完整解压,再运行解压后的 exe。
|
||||||
|
|
||||||
|
解压后的文件夹内容如下:
|
||||||
|
|
||||||
|
| 文件 | 作用 |
|
||||||
|
|---|---|
|
||||||
|
| `DLPilot.exe` | 主程序,双击运行(单文件自包含,光机控制所需串口库已内置) |
|
||||||
|
| `pattern_slots.json` | 运行配置:自定义图案栏位、测试卡区域、串口参数记忆。**删除它会丢失你的全部本地配置** |
|
||||||
|
| `bw_*.png`(5 张) | 640×360 黑白测试图:西门子星、频率扫描条纹、渐变棋盘、波带片、综合测试卡 |
|
||||||
|
| `solid_*.png`(10 张) | 800×600 纯色测试图(R/G/B 各 55/AA/FF + 三原色),供自定义栏位加载 |
|
||||||
|
| `CeramixNano-*.png`(如包含) | 光机校准图案(black / white / contrast / circle_640p / caliPoint / sharpness),新版本安装包已预置到自定义栏位 |
|
||||||
|
| `README.md` | 随包说明(与本文档内容同源) |
|
||||||
|
|
||||||
|
### 1.3 首次启动
|
||||||
|
|
||||||
|
双击 `DLPilot.exe`:
|
||||||
|
|
||||||
|
- 首次启动比之后慢一两秒(单文件程序需要先自解压),属正常现象;
|
||||||
|
- 程序没有数字签名,首次运行 Windows SmartScreen 可能弹出
|
||||||
|
「Windows 已保护你的电脑」——点「更多信息」→「仍要运行」即可;
|
||||||
|
- 个别杀毒软件可能对加壳的单文件 exe 误报,如遇拦截请放行或将安装目录加入白名单。
|
||||||
|
|
||||||
|
程序启动后出现双栏主界面(见第 3 节),即安装成功。
|
||||||
|
|
||||||
|
### 1.4 升级新版本
|
||||||
|
|
||||||
|
1. 关闭正在运行的 DLPilot;
|
||||||
|
2. 解压新版本压缩包到**新的空目录**(不要直接覆盖旧目录,避免新旧文件混杂);
|
||||||
|
3. 如需保留旧版的自定义栏位与串口记忆:把旧目录里的 `pattern_slots.json`
|
||||||
|
和你自己添加的图片文件复制到新目录,覆盖同名文件即可;
|
||||||
|
4. 双击新目录的 `DLPilot.exe`。
|
||||||
|
|
||||||
|
### 1.5 为什么必须放在可写目录
|
||||||
|
|
||||||
|
程序的所有本地数据(`pattern_slots.json` 配置、你添加的自定义图片)都保存在
|
||||||
|
**exe 所在目录**,不写注册表、不写用户目录。放在只读目录会导致配置保存失败。
|
||||||
|
两份不同目录的安装(比如两台工位电脑、或同一台电脑解压了两份)各自独立保存配置,互不影响。
|
||||||
|
|
||||||
|
## 2. 硬件连接
|
||||||
|
|
||||||
|
### 2.1 整体链路
|
||||||
|
|
||||||
|
```
|
||||||
|
PC(DLPilot) ──HDMI──→ LT8619C(HDMI→RGB888)──RGB888 视频──→ DLPC3421 光机
|
||||||
|
PC(DLPilot) ──USB-RS485──→ GD32E230 主控 ───I2C 控制(0x1B)──→ DLPC3421 光机
|
||||||
|
```
|
||||||
|
|
||||||
|
HDMI 与 RS485 接的是**同一块转接板**:LT8619C 负责把 HDMI 视频转换为 RGB888;
|
||||||
|
GD32E230 是板上的主控 MCU,负责整板逻辑控制——DLPilot 的 RS485 命令由它解析,
|
||||||
|
再经 I2C 总线控制光机(DLPC3421)。
|
||||||
|
|
||||||
|
### 2.2 HDMI 连接
|
||||||
|
|
||||||
|
1. 用 HDMI 线把电脑显卡输出接到转接板 HDMI 输入;
|
||||||
|
2. 板卡正常上电。板卡 shadow EDID 只声明 640×360@60 一种模式;
|
||||||
|
3. 如果 Windows 没有自动点亮这块"显示器"(显示设置里看不到):
|
||||||
|
启动 DLPilot,工具检测到是本系列板卡(EDID 厂商签名)接入但未进桌面时,
|
||||||
|
会自动把它以扩展屏方式拉回桌面;仍不行时在 Windows「显示设置」里手动改为「扩展这些显示器」。
|
||||||
|
|
||||||
|
### 2.3 RS485 连接(光机控制)
|
||||||
|
|
||||||
|
1. USB-RS485 转换器接电脑 USB,其 A/B 端子对应接转接板的 RS485 A/B 端子;
|
||||||
|
2. 串口参数固定 **115200 波特率、8 数据位、无校验、1 停止位(115200 8N1)**,
|
||||||
|
软件默认值即为此,一般无需修改;
|
||||||
|
3. 板卡供电建议使用满足 **PD 12V / ≥3A** 的电源适配器——软件的"电源自检"
|
||||||
|
就是以该挡位为正常判据(见 5.3 节)。
|
||||||
|
|
||||||
|
### 2.4 上电时序(重要)
|
||||||
|
|
||||||
|
DLPC3421 光机芯片启动需要几秒钟。**上电后立即发开光机/设光强/查电流命令会收到
|
||||||
|
拒绝应答(0xFF),这是正常保护,不是故障**——稍等几秒待光机就绪后再发。
|
||||||
|
|
||||||
|
## 3. 界面总览
|
||||||
|
|
||||||
|
主窗口为双栏仪表盘,顶栏可切换 Dark / Light / System 外观(跟随系统为默认),
|
||||||
|
顶栏右侧「关于」按钮内有软件版本信息:
|
||||||
|
|
||||||
|
| 左列(HDMI 源端) | 右列(光机控制 RS485) |
|
||||||
|
|---|---|
|
||||||
|
| 显示器选择:显示器下拉 + 刷新 | 串口选择:串口下拉 + 波特率等参数 + 连接 |
|
||||||
|
| 支持的模式(默认折叠):分辨率下拉 + 应用 / 恢复 + 时序明细 | 电源检查:电源自检 + 功率检测 |
|
||||||
|
| EDID 信息(默认折叠):解算结果一览 | 串口数据:收发日志(译码 + hex)+ 清空 |
|
||||||
|
| 测试图案:内置图案 / R·G·B 色值 / 自定义与校准栏位 / 测试卡区域选择 | 光机命令:快捷按钮排 + 预设下拉 + 自定义输入 + 温度读取 |
|
||||||
|
| EDID 原始数据:hex 显示 + 逐字节解析 | 快捷滑条:光强 / 定时 / TEC 温度 |
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
*图 1 主界面与快速开始要点*
|
||||||
|
|
||||||
|
红框与编号对应四个上手要点:
|
||||||
|
|
||||||
|
1. **选显示器**:左上「显示器选择」卡的下拉框选中接转接板的显示器
|
||||||
|
(Generic PnP Monitor),下方会显示当前实际输出分辨率/刷新率;
|
||||||
|
多屏或热插拔后点「刷新」重新枚举;
|
||||||
|
2. **投测试图案**:现在的转接板**上电默认打开光机**,无需先连串口——
|
||||||
|
在「测试图案」卡选好测试卡区域后即可直接投放指定图案
|
||||||
|
(点「停止」按钮或按 ESC 退出全屏);
|
||||||
|
3. **连串口**:需要控制光机光强、查温度/电流等才需要串口——USB-RS485
|
||||||
|
转换器接好后,在「串口」卡选口(参数保持默认 115200 8N1)点「连接」;
|
||||||
|
4. **控光机**:常用光机控制都集中在「光机命令」卡(开/关光机、查版本、
|
||||||
|
软件重启、TEC、温度读取、预设下拉与自定义输入),下方「快捷滑条」
|
||||||
|
可便捷调光强、定时投光、TEC 温度。
|
||||||
|
|
||||||
|
「支持的模式」「EDID 信息」两张卡片默认折叠,点卡片标题展开。
|
||||||
|
左列只操作显卡输出(不碰光机),右列只操作光机(不碰显卡)。
|
||||||
|
|
||||||
|
## 4. HDMI 源端操作(左列)
|
||||||
|
|
||||||
|
### 4.1 选择显示器
|
||||||
|
|
||||||
|
1. 左上下拉框列出当前所有显示器,选中**接转接板的那一块**;
|
||||||
|
多屏时注意核对型号/分辨率,不要选成你的主屏;
|
||||||
|
2. 热插拔后列表没刷新时点「刷新」重新枚举;
|
||||||
|
3. 下拉框内容与系统识别一致;如对序号有疑问,可在 Windows「显示设置」中
|
||||||
|
点「识别」核对。
|
||||||
|
|
||||||
|
### 4.2 查看支持的模式 / 切换分辨率
|
||||||
|
|
||||||
|
1. 展开「支持的模式」卡片,下拉框列出显卡按该屏 EDID 提供的全部模式
|
||||||
|
(板卡正常时可见 640×360@60);
|
||||||
|
2. 选中模式后点「应用」即切换。**切换是临时的**:不写注册表,重启电脑或
|
||||||
|
重新插拔即还原,不会永久改动你的桌面设置;
|
||||||
|
3. 测试完成后点「恢复」,回到本次打开软件时的原始模式;
|
||||||
|
4. 卡片同时显示选中模式的时序明细,可核对像素时钟、刷新率等。
|
||||||
|
|
||||||
|
### 4.3 查看 EDID
|
||||||
|
|
||||||
|
- 「EDID 信息」卡片:显示从该显示器读到的 EDID 解算结果——厂商、型号、
|
||||||
|
尺寸、Gamma、输入类型、支持的全部模式、首选时序完整参数、校验和;
|
||||||
|
- 「EDID 原始数据」卡片:显示 128 字节(含扩展块)原始 hex;
|
||||||
|
点右上「逐字节解析」按钮,可按偏移逐字段展开基础块与 CTA-861 扩展块,
|
||||||
|
每个字段附原始字节,适合核对板卡 EDID 是否按规格上报。
|
||||||
|
|
||||||
|
### 4.4 投放测试图案
|
||||||
|
|
||||||
|
1. 先在「测试卡区域」选择投放区域:
|
||||||
|
- `640x360`(默认)——与光机面板原生分辨率 1:1,**链路验证/校准用这个**;
|
||||||
|
- `800x600`——对应 demo 板首选时序;
|
||||||
|
- `full`——铺满所选显示器的整个屏幕;
|
||||||
|
2. 点「测试图案」卡片中的按钮即全屏投放到所选显示器:
|
||||||
|
- 内置图案:纯红、纯绿、纯蓝、黑白棋盘格、网格线(程序直接绘制);
|
||||||
|
- R/G/B 三行 `55 / AA / FF` 色值按钮:按通道着色的纯色,用途见 7.2 节;
|
||||||
|
- 自定义/校准图片栏位:见 4.5 节;
|
||||||
|
3. 投放新图案会自动替换当前旧图案;按 **ESC** 键或点「停止测试图像」退出全屏。
|
||||||
|
|
||||||
|
### 4.5 自定义图片栏位(含校准图案)
|
||||||
|
|
||||||
|
「测试图案」卡片提供 **10 个可配置栏位**,每个栏位一个图案按钮 + 一个齿轮按钮:
|
||||||
|
|
||||||
|
1. 点某个栏位的**齿轮**按钮,弹出配置对话框;
|
||||||
|
2. 填写栏位名称(显示在按钮上),选择图片文件(推荐 PNG;JPG/BMP/WebP
|
||||||
|
依运行环境而定,PNG 最稳妥);
|
||||||
|
3. 保存后图片自动**复制到 exe 所在目录**,栏位按钮即可点按投放。
|
||||||
|
因此不要事后手动移动/删除 exe 旁的图片文件,否则栏位失效;
|
||||||
|
4. 安装包已预置常用栏位(黑白测试图与校准图案,具体以包内为准),
|
||||||
|
可按上述步骤改成你自己的图。
|
||||||
|
|
||||||
|
栏位配置、测试卡区域选择会自动保存在 exe 旁的 `pattern_slots.json`。
|
||||||
|
|
||||||
|
## 5. 光机控制操作(右列)
|
||||||
|
|
||||||
|
### 5.1 连接串口
|
||||||
|
|
||||||
|
1. 「串口选择」卡片:下拉框列出所有串口,显示为 `COMx + 设备描述`。
|
||||||
|
多路 USB 转换器(如 CH344 四路)每一路描述不同(serial-A/B/C/D),
|
||||||
|
据此选口;描述相同时软件自动附物理位置区分;
|
||||||
|
2. 波特率等参数默认 115200 8N1,与板卡固件约定一致,保持默认即可;
|
||||||
|
3. 点「连接」。连接失败会给出简短原因(串口被占用/不存在等),
|
||||||
|
完整错误信息进收发日志;
|
||||||
|
4. 上次使用的串口与参数会被记住,下次启动自动带出(预置配置带的串口如与
|
||||||
|
你现场不符,第一次使用时改成你的实际串口即可)。
|
||||||
|
|
||||||
|
### 5.2 收发日志
|
||||||
|
|
||||||
|
「串口数据 · 收发日志」卡片实时显示:
|
||||||
|
|
||||||
|
- `→` 发出的命令;
|
||||||
|
- `←` 收到的应答:**可读译码 + 原始 hex** 对照显示;
|
||||||
|
- 错误自动附释义,例如 `err:3(I2C NACK)` 表示光机侧 I2C 无应答;
|
||||||
|
- 点「清空」清屏。日志超过 500 行自动滚动淘汰旧条目,长时间联机不会卡顿。
|
||||||
|
|
||||||
|
协议帧格式(判读 hex 时参考):命令帧 `D5 01 LEN <ASCII命令> CRC`,
|
||||||
|
应答帧 `B5 TYPE LEN <payload> CRC`,CRC 为自第 2 字节起的累加和低 8 位。
|
||||||
|
|
||||||
|
### 5.3 电源检查
|
||||||
|
|
||||||
|
「电源检查」卡片有两个按钮:
|
||||||
|
|
||||||
|
- **电源自检**:自动依次查询供电协议(M301)→ PD 挡位最大电流(M302)→
|
||||||
|
实测母线电压(M303),并按实测电压就近判定 PD 固定挡(5/9/12/15/20/28V):
|
||||||
|
|
||||||
|
| 显示 | 含义 |
|
||||||
|
|---|---|
|
||||||
|
| 绿底,如 `FPDO: 12V@3A` | 供电正常:12V 挡且电流 ≥3A |
|
||||||
|
| 红底,如 `FPDO: 9V@3A` | 挡位不符:电源没有协商到 12V 挡,请换符合要求的 PD 电源 |
|
||||||
|
| `ERR` | 实测电压不落在任何标准 PD 挡内,检查供电 |
|
||||||
|
|
||||||
|
说明:取电芯片的电压配置寄存器只写不可读,挡位只能靠实测电压判定,
|
||||||
|
所以以自检结果为准,而不是电源标称。
|
||||||
|
|
||||||
|
- **功率检测**:自动依次读母线电压(M303)/ 负载电流(M304)/ 负载功率(M305),
|
||||||
|
读数框显示 电压(V)、电流(mA)、功率(W)。功率量程 0~295 W。
|
||||||
|
|
||||||
|
### 5.4 光机命令
|
||||||
|
|
||||||
|
「光机命令」卡片从上到下:
|
||||||
|
|
||||||
|
1. **快捷按钮排**(最常用操作一键完成):
|
||||||
|
`开光机`、`关光机`、`查版本`、`软件重启`、`开TEC`、`关TEC`、`TEC33.0°C`;
|
||||||
|
2. **温度读取**:`查DMD温度`、`查LAMP温度`,应答数值(0.1°C 单位换算后)
|
||||||
|
实时填入按钮旁的显示框;
|
||||||
|
3. **预设下拉**:常用命令清单,选中即发送;
|
||||||
|
4. **自定义输入框**:手动输入任意命令(见第 6 节命令表),**回车即发送**。
|
||||||
|
|
||||||
|
### 5.5 快捷滑条
|
||||||
|
|
||||||
|
「快捷滑条」卡片三个滑条,拖到目标值后点对应按钮下发:
|
||||||
|
|
||||||
|
- **光强**:拖动后点「下发电流值」(有效范围 54–800,RGB 三路同值);
|
||||||
|
- **定时**:设定毫秒数后点「开光机(定时)」——开光机并在到时后自动关,
|
||||||
|
0 表示不限时;上限 32700 ms;
|
||||||
|
- **TEC 温度**:滑条/输入框设定凝露点 200–350(对应 20.0–35.0°C),
|
||||||
|
点「下发温度值」。
|
||||||
|
|
||||||
|
滑条旁的数值输入框支持直接键入,回车后自动限制到有效范围并与滑条同步。
|
||||||
|
|
||||||
|
## 6. 光机命令参考
|
||||||
|
|
||||||
|
| 命令 | 功能 | 应答示例 / 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| `M1` | 协议握手 | `ok` |
|
||||||
|
| `M730S0` / `M730S1` | 开 / 关光机 | `ok` |
|
||||||
|
| `M730S0T2000` | 开光机并定时 2000ms 自动关 | `ok`;定时 ≤32700 ms |
|
||||||
|
| `M731S100` | 设光强(54–800,RGB 同值) | `ok`;失败回 `err:R..G..B..` |
|
||||||
|
| `M732` | 查三路电流设置值 | `okR110G110B110` |
|
||||||
|
| `M737` | 查投光是否结束 | 投光进行中会**延迟应答**,属正常 |
|
||||||
|
| `M201` / `M202` | 查 DMD / LAMP 温度 | `okTL:246` = 24.6°C |
|
||||||
|
| `M7S0` / `M7S1` | TEC 自动控温 **开** / 关 | 注意 **S0 是开**,方向与直觉相反 |
|
||||||
|
| `M8S330` | TEC 凝露点 33.0°C | 范围 200–350,超范围回 `err:OL` |
|
||||||
|
| `M301` | 查供电协议(PD/QC3.0/EPR…) | ASCII 文本 |
|
||||||
|
| `M302` | 查 PD 挡位最大电流 | mA(50mA/LSB 已换算) |
|
||||||
|
| `M303` | 查母线电压(实测) | 如 12020 mV = 12.02 V |
|
||||||
|
| `M304` | 查负载电流(实测) | mA,带符号(正=正向) |
|
||||||
|
| `M305` | 查负载功率(实测) | mW,软件换算显示为 W |
|
||||||
|
| `M999` | 查固件版本 | 如 `okv20.0.0.1` |
|
||||||
|
| `M888` | 软件重启 | `ok` 后约 100ms 复位 |
|
||||||
|
|
||||||
|
> **注意:**
|
||||||
|
>
|
||||||
|
> 1. 光机上电后几秒内处于启动期,此时 `M730/M731/M732` 会被就绪门禁拒绝(回 0xFF),
|
||||||
|
> 等几秒再发即可;
|
||||||
|
> 2. USB-RS485 转换器是半双工的:本机发送期间板上回包不会回环显示,属正常现象;
|
||||||
|
> 3. 设光强等带数值的命令,超范围值会被板卡拒绝,请按表中范围下发。
|
||||||
|
|
||||||
|
## 7. 典型操作流程
|
||||||
|
|
||||||
|
### 7.1 首次整链路验证(新板卡点灯)
|
||||||
|
|
||||||
|
```
|
||||||
|
1. HDMI 接转接板,USB-RS485 接板卡 A/B,板卡上电(PD 12V/≥3A),等数秒
|
||||||
|
2. 启动 DLPilot → 「刷新」→ 显示器下拉选中板卡(640x360@60)
|
||||||
|
3. 光机控制:选串口 → 连接 → 点「查版本」(M999)
|
||||||
|
应答 okv... 即 RS485→光机 链路通;无应答见第 9 节排查
|
||||||
|
4. 点「电源自检」:绿底 FPDO: 12V@3A 即供电合格
|
||||||
|
5. 测试卡区域选 640x360(与光机面板原生 1:1);转接板目前上电默认开光机,
|
||||||
|
可直接投图,若光机已被关闭再点「开光机」
|
||||||
|
6. 投放测试图案目视检查 → 设光强/查温度电流(按需)
|
||||||
|
7. 测完:「关光机」→ 分辨率「恢复」→ 停止测试图像
|
||||||
|
```
|
||||||
|
|
||||||
|
### 7.2 RGB 通道与位序检查
|
||||||
|
|
||||||
|
用「测试图案」里的 R/G/B 行色值按钮(`55 / AA / FF` 三档):
|
||||||
|
|
||||||
|
1. **纯红/纯绿/纯蓝**:验证 RGB 三通道映射是否正确
|
||||||
|
(硬件约定 R=D[23:16]、G=D[15:8]、B=D[7:0],投纯红时仅 R 通道应有输出);
|
||||||
|
2. **55 与 AA 配对**:`0x55`(01010101)与 `0xAA`(10101010)互为字节镜像,
|
||||||
|
专用于检出位序颠倒——位交换设置(0x606E)正确时图像应为 50% 灰阶占空比;
|
||||||
|
3. **FF**:全高基准,配合电流读数核对满幅输出。
|
||||||
|
|
||||||
|
### 7.3 校准图案投放
|
||||||
|
|
||||||
|
1. 「测试卡区域」选 `640x360`(校准图按光机原生分辨率制作);
|
||||||
|
2. 安装包已预置校准栏位(black / white / contrast / circle_640p / caliPoint /
|
||||||
|
sharpness,以包内为准);如需换用自己的校准图,按 4.5 节齿轮按钮配置;
|
||||||
|
3. 依次点栏位按钮投放,按校准规程判读(新图案自动替换旧图案,无需先停止);
|
||||||
|
4. 完成后 ESC 退出。
|
||||||
|
|
||||||
|
## 8. 数据判读速查
|
||||||
|
|
||||||
|
| 现象/读数 | 判读 |
|
||||||
|
|---|---|
|
||||||
|
| 开机后发命令回 `0xFF` | 光机启动中,就绪门禁拒绝,等几秒重发 |
|
||||||
|
| 日志出现 `err:3(I2C NACK)` | 光机侧 I2C 无应答:光机未上电/未就绪,或板卡故障 |
|
||||||
|
| 温度应答 `okTL:246` | 24.6°C(0.1°C 单位) |
|
||||||
|
| 电流应答 `okR110G110B110` | R/G/B 三路电流设置值均为 110 |
|
||||||
|
| 电源自检红底 `FPDO: 9V@3A` | PD 只协商到 9V 挡,未到 12V,更换/检查电源与线材 |
|
||||||
|
| 定时投光中 M737 无立即应答 | 正常:投光结束才应答,勿反复重发 |
|
||||||
|
|
||||||
|
## 9. 常见问题(FAQ)
|
||||||
|
|
||||||
|
**Q1:双击 exe 没反应 / 被 Windows 拦截。**
|
||||||
|
SmartScreen 弹窗点「更多信息」→「仍要运行」;杀毒软件误报时放行或加白名单;
|
||||||
|
仍不行则确认解压完整(exe 约 67 MB)。
|
||||||
|
|
||||||
|
**Q2:光机命令发出去没反应。**
|
||||||
|
按顺序排查:① 串口选对没有(115200 8N1)、A/B 线接对没有;② 先点「查版本」
|
||||||
|
(M999)验证链路,M999 都不通就是串口/接线问题;③ M999 通但开光机回 0xFF——
|
||||||
|
光机启动中,等几秒重试;④ 半双工转换器发送期间看不到回环是正常的。
|
||||||
|
|
||||||
|
**Q3:显示器下拉里找不到板卡。**
|
||||||
|
检查 HDMI 线与板卡供电;点「刷新」;启动 DLPilot 会自动把本系列板卡拉回扩展桌面,
|
||||||
|
仍不行到 Windows 显示设置手动改「扩展这些显示器」,然后回软件刷新。
|
||||||
|
|
||||||
|
**Q4:切了分辨率,桌面布局乱了。**
|
||||||
|
软件的切换是临时的:点「恢复」立即还原;重启电脑或重插 HDMI 也会还原。
|
||||||
|
不会永久改动系统设置。
|
||||||
|
|
||||||
|
**Q5:自定义栏位点了没图。**
|
||||||
|
该栏位未配置图片(点齿轮配置);或 exe 旁的图片文件被移动/删除——重新配置一次,
|
||||||
|
图片会重新复制到 exe 旁。
|
||||||
|
|
||||||
|
**Q6:串口下拉里好几个 COM 口,选哪个?**
|
||||||
|
下拉项带设备描述(如 USB-SERIAL CH340 / serial-A~D),选你的 USB-RS485
|
||||||
|
转换器对应的口;描述相同的会附物理位置。拿不准就拔插一次看哪个口出现/消失。
|
||||||
|
|
||||||
|
**Q7:两台电脑/两个目录各解压了一份,配置会串吗?**
|
||||||
|
不会。配置保存在各自 exe 旁的 `pattern_slots.json`,互相独立。
|
||||||
|
|
||||||
|
**Q8:软件用久了变卡。**
|
||||||
|
v0.4.2 及更早版本存在长会话卡顿问题,v0.4.3 已修复;请确认用的是 v0.4.3
|
||||||
|
(顶栏「关于」可查版本),旧版本请升级。
|
||||||
|
|
||||||
|
**Q9:换电脑要带走哪些东西?**
|
||||||
|
整个安装目录打包即可;至少要 `DLPilot.exe` + `pattern_slots.json`(含你的栏位
|
||||||
|
与串口记忆)+ 你添加的自定义图片。
|
||||||
|
|
||||||
|
## 10. 版本沿革
|
||||||
|
|
||||||
|
| 版本 | 日期 | 要点 |
|
||||||
|
|---|---|---|
|
||||||
|
| v0.4.3(当前) | 2026-10-13 | 修复长会话越用越卡、命令点击无响应的问题(收发日志积压);新增日志回归自检 |
|
||||||
|
| v0.4.2 | 2026-09-28 | 收发日志「清空」按钮归位;恢复光机快捷按钮排(开/关光机、查版本、TEC 等) |
|
||||||
|
| v0.4.1 | 2026-09-28 | 修复切换 Light/Dark 主题后色值按钮底色丢失;串口连接失败改为简短提示,不再撑破窗口 |
|
||||||
|
| v0.4.0 | 2026-09-24 | 界面重写为双栏仪表盘(Fluent 风格),功能基线版本 |
|
||||||
|
|
||||||
|
## 附录:技术支持
|
||||||
|
|
||||||
|
遇到本文未覆盖的问题,请联系我方对接工程师反馈:
|
||||||
|
软件版本号(顶栏「关于」)、操作步骤、收发日志截图(含原始 hex),
|
||||||
|
光机问题请同时提供「查版本」(M999)与温度读数。
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# 本机虚拟环境(根 .gitignore 已覆盖 build/ dist/ *.spec __pycache__/)
|
||||||
|
.venv/
|
||||||
|
|
||||||
|
# 构建日志(测试结果由 unittest 实时输出, 不留档)
|
||||||
|
build-log*.txt
|
||||||
|
|
||||||
|
# 验证脚本生成的截图
|
||||||
|
validation/*.png
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
# EDID Viewer — 开发需求与进度
|
||||||
|
|
||||||
|
## 基本环境
|
||||||
|
- 主项目位置:`E:\Hulk-Coding\HW-Debug-Tools\EDID-viewer`;为兼容此前约定,已同步镜像到 `E:\Hulk-Coding\LT8619C\_Debug\_Tools\EDID-viewer`。
|
||||||
|
- Windows 10/11 x64;Python 3.14;PySide6 6.11.2(Qt 官方 Python 绑定);PySide6-Fluent-Widgets 1.11.3。
|
||||||
|
- 使用项目 `.venv`;依赖见 requirements.txt;GUI 入口为 `src/main.py`(版本号在 `src/main.py` 的 `APP_VERSION`)。
|
||||||
|
- 独立工具,不依赖、不修改 LT8619C 固件或 DLPilot 工程。
|
||||||
|
|
||||||
|
## 工程结构与流水线(对齐 DLPilot 三区约定)
|
||||||
|
- 三区目录:`src/` 人写代码(main / edid / windows_edid / theme / test_edid + 打包流水线);`assets/` 图标与生成脚本(可再生);`release/` 交付(`EDID-Viewer.exe` 入库 + README)。
|
||||||
|
- 打包单文件 exe:`python src/build_exe.py`(spec 由脚本生成到 `src/build/`,不入库;原 viewer.spec 的 ICU 排除逻辑已内置其中)。`--debug` 附带带控制台变体。
|
||||||
|
- 发布:`python src/package_release.py <版本>` 组装 `release/EDID-Viewer-v*-win64.zip`(zip 不入库,只上传 Gitea Release);上传用 `python src/publish_gitea.py <zip>`,token 走环境变量 `GITEA_TOKEN`。
|
||||||
|
- 解析测试:`cd src && python -m unittest`(9 项,改 edid.py 后必跑)。
|
||||||
|
|
||||||
|
## 任务目标
|
||||||
|
1. 枚举 Windows 活动显示设备并读取 EDID 原始块。
|
||||||
|
2. 查看厂家代码、产品编号、名称、序列号、生产日期、分辨率和详细时序。
|
||||||
|
3. 展示 CTA 扩展、HDMI、音频、HDR、色彩能力和校验结果。
|
||||||
|
4. 支持离线 BIN/HEX 导入、BIN 和 JSON 报告导出。
|
||||||
|
5. Light / Dark / 跟随系统主题,持久化用户选择并响应系统主题变化。
|
||||||
|
6. 图标参考 DLPilot 黑底、橙色标签、白字,使用 EDID / Viewer 独立标识。
|
||||||
|
- Fluent 主题包含 `dark1`(蓝色)和 `dark2`(青色),两者均为显式深色模式;选中态文字必须保持高对比度。
|
||||||
|
- Fluent Widgets 版本已采用顶部操作区、下方信息卡片和分组页签;后续布局调整需保持信息层级清晰。
|
||||||
|
|
||||||
|
## Fluent Widgets 版本
|
||||||
|
- 界面使用 PySide6-Fluent-Widgets 的 `CardWidget`、`ComboBox`、`PrimaryPushButton`、`PlainTextEdit` 和 `TreeWidget`;顶部操作区、下方信息卡片和分组页签。
|
||||||
|
- Fluent 主题只负责表现层;EDID 解析、Windows WMI 读取、导入导出和线程边界不改变。
|
||||||
|
- 主题切换必须三件套同步(与 DLPilot `app_fluent.py` 同一方案):`setTheme` 之外,QPalette + 应用级 QSS 统一 QMainWindow 背景、原生 QTabWidget/QStatusBar 表面色,DWM 属性 20/35/36 切换原生标题栏深浅。只调 `setTheme` 会导致 Light 模式下窗口背景、页签和标题栏仍是系统深色。
|
||||||
|
- 窗口截图验证可用 `validation\capture-window.ps1`(按进程窗口矩形截屏,注意全屏窗口会遮挡)。
|
||||||
|
|
||||||
|
## 实现与边界
|
||||||
|
- 只读 Windows WMI 显示驱动提供的 EDID;不写 EDID、不更改分辨率或显示拓扑。
|
||||||
|
- Windows/驱动可能缓存或覆盖 EDID;不能声称数据是实时 DDC 总线抓取。
|
||||||
|
- HDMI、DP、内屏均列出,连接类型来自 WmiMonitorConnectionParams,未知则如实标注。
|
||||||
|
- 无法读取的设备、缺失扩展、未知数据块和无效校验必须明确展示,不猜测。
|
||||||
|
- EDID 表示接收端声明能力,不能证明当前链路色深、HDR、HDCP 或真实带宽。
|
||||||
|
- 解析器与 UI、Windows 读取分离;读取在后台线程完成。
|
||||||
|
- 添加解析边界/错误数据测试。打包后验证实际可见窗口、缩放、刷新和导入导出流程。
|
||||||
|
- 第一版不完整解码 DisplayID、HDMI Forum VRR/DSC;保留原始块供分析。
|
||||||
|
|
||||||
|
## 进度记录
|
||||||
|
- **v0.1.0(2026-09-25,已发布)**:目录对齐 DLPilot 三区结构;onefile 打包
|
||||||
|
(`src/build_exe.py` 生成 spec,剔除 PATH 上 Poppler/Conda 的版本化 ICU);Light
|
||||||
|
主题三件套修复(setTheme + QPalette/应用级 QSS + DWM 标题栏);右上角"关于";
|
||||||
|
标签 `EDID-Viewer-v0.1.0` 与 Release 附件已核对(66,483,477 字节)。
|
||||||
|
- 验证明细见 `VALIDATION.md`;实机验收缺口:HDMI 热插拔、多屏、跨屏 DPI、
|
||||||
|
最大化/恢复与导入导出完整交互流程。
|
||||||
|
- 根目录 `agent.md` 为仓库整体的开发需求与进度管理文档。
|
||||||
|
|
||||||
|
## 后续建议
|
||||||
|
- EDID 对比、字节差异与固件数组导出。
|
||||||
|
- HDMI Forum VRR/ALLM/FRL/DSC、DisplayID 与高级色彩数据解析。
|
||||||
|
- 与实际输出时序和桥接芯片寄存器联合诊断。
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
# EDID Viewer
|
||||||
|
|
||||||
|
Windows 10/11 显示器 EDID 查看器。使用 **PySide6 / PySide6-Fluent-Widgets**,只读,不修改显示设置。
|
||||||
|
|
||||||
|
> 只想使用工具:到 [Gitea Releases](https://gitea.hulk.wang/hulk/HW-Debug-Tools/releases)
|
||||||
|
> 下载 `EDID-Viewer-vX.Y.Z-win64.zip`,解压双击 `EDID-Viewer.exe` 即可(Windows 10/11 x64,免安装、无需 Python)。
|
||||||
|
|
||||||
|
## 使用
|
||||||
|
|
||||||
|
- 双击 `release\EDID-Viewer.exe`(单文件,免安装)。
|
||||||
|
- 或双击 `start.cmd` 使用本机 Python 环境运行源码。
|
||||||
|
- 右上角「外观」选择 Light(浅色)、Dark(琥珀深色)、dark1(蓝色深色)、dark2(青色深色)或跟随系统;默认跟随系统,选择自动保存,系统模式响应 Windows 明暗变化。
|
||||||
|
- 图标沿用 DLPilot 的黑底/橙色标签/白字语言,文字为 EDID / Viewer;窗口、任务栏和 EXE 使用同一图标。
|
||||||
|
- 当前布局采用 Fluent Widgets:顶部设备/文件操作卡片、右上角「关于」,下方信息卡片和分组页签;Dark 使用琥珀强调色,dark1 使用蓝色强调色,dark2 使用青色强调色,主题随系统设置持久化。
|
||||||
|
- 点击「刷新设备」,从下拉框选择设备。HDMI、DP 和内屏均显示连接类型。
|
||||||
|
- 「设备与能力」显示身份和音频/HDR/色彩/HDMI 信息;「分辨率与时序」可展开 DTD 查看像素时钟、前后肩、同步宽度和极性。
|
||||||
|
- 「原始 HEX」支持选中复制。「导出 BIN」保持读取到的字节不变;「导出报告」生成含原始数据的 UTF-8 JSON。
|
||||||
|
- 支持 `.bin/.edid` 二进制和 `.hex/.txt` 纯十六进制。HEX 可以使用空格、逗号、`0x` 前缀,不接受带地址/ASCII 栏的 hexdump。
|
||||||
|
|
||||||
|
## 目录结构(对齐 DLPilot)
|
||||||
|
|
||||||
|
- `src/` — 人写代码:界面(main.py)、EDID 解析(edid.py)、Windows 读取(windows_edid.py)、主题(theme.py)、解析测试(test_edid.py)和打包流水线。
|
||||||
|
- `assets/` — 图标与生成脚本(可再生)。
|
||||||
|
- `release/` — 交付物:`EDID-Viewer.exe` 本地保留不入库;发布 zip 只上传 Gitea Release,不入库。
|
||||||
|
- `AGENTS.md` — 工程约定与任务边界(改代码前必读);`VALIDATION.md` — 验证记录。
|
||||||
|
|
||||||
|
## 环境与构建
|
||||||
|
|
||||||
|
本机:Python 3.14、PySide6 6.11.2、PySide6-Fluent-Widgets 1.11.3、PyInstaller 6.22.2。当前 `.venv` 通过 `--system-site-packages` 复用已安装依赖,不修改全局包。新电脑可以创建独立环境:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
python -m venv .venv
|
||||||
|
.\.venv\Scripts\python.exe -m pip install -r requirements.txt
|
||||||
|
.\.venv\Scripts\python.exe src\main.py
|
||||||
|
cd src && python -m unittest # 9 项解析测试
|
||||||
|
python src\build_exe.py # 打包 → release\EDID-Viewer.exe
|
||||||
|
python src\package_release.py 0.1.0 # 组装 release\EDID-Viewer-v0.1.0-win64.zip
|
||||||
|
python src\publish_gitea.py ..\release\EDID-Viewer-v0.1.0-win64.zip --insecure
|
||||||
|
```
|
||||||
|
|
||||||
|
打包为单文件 exe;spec 由 `build_exe.py` 生成到 `src/build/`(不入库),其中剔除 PATH 上其他工具(Poppler/Conda)的版本化 ICU DLL,避免 QtCore 加载失败(WinError 127)。构建前关闭正在运行的 EDID Viewer,以免文件被占用。图标源为 `assets/make_icon.py`,重新生成时需安装 Pillow(仅开发时需要)。主题配置保存在当前用户的 `QSettings: LT8619C-Tools/EDID-Viewer`。
|
||||||
|
|
||||||
|
## 能力范围
|
||||||
|
|
||||||
|
- EDID 1.x 基础身份、生产日期、名称/序列号、物理尺寸、Gamma、色深、色度坐标。
|
||||||
|
- 已建立/标准时序、基础与 CTA 详细时序;常用 CTA VIC(未映射的 VIC 显示编号)。
|
||||||
|
- 多个 CTA 扩展、音频 SAD、HDMI VSDB、CEC 地址、深色、TMDS、HF-VSDB 的 SCDC/TMDS。
|
||||||
|
- HDR EOTF、色彩标准、YCbCr 4:2:0 声明。未知块原样保留。
|
||||||
|
- 每块校验和、扩展计数、截断和数据块越界诊断。
|
||||||
|
|
||||||
|
## 限制
|
||||||
|
|
||||||
|
- 读取 `root/wmi:WmiMonitorDescriptorMethods` 中的活动设备,不保证列出禁用输出/驱动不提供 WMI 的设备。失败会显示原因,可改用离线文件。
|
||||||
|
- 数据来自 Windows/显卡驱动,可能是缓存或覆盖内容,不是实时 DDC 抓取。读取扩展失败时保留已经取得的块并报告缺失。
|
||||||
|
- EDID 能力不等于当前输出模式;不能据此确定 HDCP、线材质量、正在使用的 HDR/色深或 HDMI 版本。
|
||||||
|
- DisplayID 和 HDMI Forum VRR/ALLM/FRL/DSC 尚未详细解码;仅包含 DisplayID 时序的屏幕可能没有可解码的分辨率。范围描述符扩展偏移仅提示,未应用。
|
||||||
|
- 不承诺所有 CTA VIC/扩展标签均已覆盖。厂商首先显示标准 PNP 三字母代码,避免错误猜测品牌。
|
||||||
|
|
||||||
|
## 推荐后续挖掘
|
||||||
|
|
||||||
|
1. **桥接板时序匹配**:像素时钟、H/V 消隐、同步极性和首选模式,排查黑屏、偏色、画面偏移。
|
||||||
|
2. **EDID 差异比较**:对照板卡固件、Windows 读取值、显示器原始值,定位缓存、截断或改写。
|
||||||
|
3. **带宽与色彩**:TMDS/FRL、RGB/YCbCr、深色和 4:2:0,解释分辨率或刷新率受限。
|
||||||
|
4. **HDR 与音频**:PQ/HLG、亮度元数据、PCM 位深/采样率/声道和压缩音频能力。
|
||||||
|
5. **DisplayID / VRR / DSC**:适合高刷新率和高分辨率显示设备,作为下一阶段扩展。
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# 验证记录 — 2026-09-23
|
||||||
|
|
||||||
|
- Python 3.14 / PySide6 6.11.2 / PyInstaller 6.22.2。
|
||||||
|
- 9 个解析测试通过,包括身份字段、标准时序、1080p/1080i DTD、CTA 音频/4K/HDR/CEC、缺失扩展、坏校验、越界、未知扩展;其中包括 1000 份随机畸形数据的无崩溃检查。
|
||||||
|
- BIN → 带 0x 前缀 HEX → BIN 一致性检查通过。
|
||||||
|
- `pip check` 通过。
|
||||||
|
- WMI 实际读取到内屏 SDC / ATNA60HU01-0;取得 256 字节,两个块校验通过;声明 384 字节,读取第三块失败。UI 正确展示读取错误和缺失警告。
|
||||||
|
- 打包 EXE 实际启动通过,QtCore/QtGui/QtWidgets 绑定文件存在。截图检查确认设备信息、中文、校验、警告均可见。
|
||||||
|
- 修复 PATH 中 Poppler ICU 被 PyInstaller 错误收集导致的 QtCore DLL 加载失败;`viewer.spec` 排除冲突 ICU,使用 Windows 系统 ICU。
|
||||||
|
- 修复系统深色主题与浅色内容背景造成的白字不可见问题,使用完整浅色 Qt 调色板。
|
||||||
|
- 当前没有可用于验证的外接 HDMI 设备;HDMI 热插拔、多屏、跨屏 DPI、最大化/恢复和 GUI 文件对话框完整流程尚未完成交互验收。检查期间窗口发生用户输入/位置变化,没有继续抢占窗口操作。
|
||||||
|
- DisplayID、高级 HDMI Forum 字段未完整解析,详见 README。
|
||||||
|
|
||||||
|
`validation/` 保存本机读取样本和合成 HDMI 测试数据,仅作本地验收材料。
|
||||||
|
|
||||||
|
## 主题与图标更新
|
||||||
|
|
||||||
|
- 新 EXE 实际启动通过,窗口展示 EDID / Viewer 黑橙白图标。
|
||||||
|
- 实际通过右上角切换 Light、Dark;截图检查文字、数据树、按钮、选择框的对比度正常。
|
||||||
|
- 跟随系统在当前 Windows 深色设置下正确显示深色。已连接 Qt `colorSchemeChanged`;未修改用户 Windows 设置进行系统热切换测试。
|
||||||
|
- Dark 选择写入 QSettings,关闭 EXE 后重新启动,选择和深色外观均保留。
|
||||||
|
- 最大化后界面正常,随后还原;没有进行跨显示器 DPI 验证。
|
||||||
|
- 9 项解析测试仍通过;三种主题的调色板检查通过。
|
||||||
|
- qt-material 2.17 已在 PySide6 环境加载;Light/Dark/System 三种模式样式表生成检查通过。
|
||||||
|
- Material 版窗口使用左侧设备/离线操作面板和右侧内容卡片,源码启动与解析测试通过;需完成本次打包后的可见 EXE 检查。
|
||||||
|
- 本次打包 EXE 实际启动通过;可见界面已切换为 Material Amber 主题,侧栏、圆角内容卡片、页签、设备数据和警告均正常显示。
|
||||||
|
- 实机操作验证 Light 与 Dark 切换,文字和数据树对比度正常;Material 版保留系统跟随选项。
|
||||||
|
- 修复 Material 选中态对比度:设备/主题下拉框选中项改为深色文字配琥珀色背景;树表格、焦点行、页签和警告提示分别使用可读的深色/浅色组合。源码测试和打包 EXE 均已更新。
|
||||||
|
- 针对截图反馈再次调整页签选中态:深色使用深灰底/琥珀字,浅色使用浅琥珀底/深琥珀字,并保留底部强调线;Light 打包窗口实测“分辨率与时序”页签可读。
|
||||||
|
- 针对 HEX/JSON 截图反馈调整 `QPlainTextEdit`/`QTextEdit` 文本选中态:深色使用蓝灰底/浅字,浅色使用浅蓝灰底/深字,避免 qt-material 的亮黄色底/白字组合。源码样式检查和解析测试通过;本次重新打包后窗口启动验证因物理 Escape 中断,未继续进行 UI 操作。
|
||||||
|
- 主题选择框和下拉列表已加宽至 148/至少 170 px,三种中文选项可完整显示;控件尺寸检查通过,EXE 已重新打包。
|
||||||
|
|
||||||
|
# 验证记录 — 2026-09-24
|
||||||
|
|
||||||
|
- 新增 `dark1`(`dark_blue.xml`,蓝色强调)和 `dark2`(`dark_cyan.xml`,青色强调)两个深色 Material 主题;原有 Light、Dark、跟随系统仍保留。
|
||||||
|
- 9 项解析测试、`pip check` 和 Python 编译检查通过;qt-material 2.17 已确认包含两个新主题资源。
|
||||||
|
- 最新 `dist\EDID-Viewer\EDID-Viewer.exe` 已重新构建并启动,进程响应正常;offscreen 窗口渲染确认两个主题的主题选择框、页签和内容面板均能显示。
|
||||||
|
- 深色主题的下拉选中项、树表格焦点行、页签、警告和 HEX/JSON 文本选择态均使用按主题的高对比配色,避免亮背景配白字。
|
||||||
|
- 当前预览使用无 EDID 样本的启动状态;Windows WMI 实际设备读取结果沿用上一条记录,未把本次 offscreen 渲染当作硬件验收。
|
||||||
|
# Fluent Widgets 重写验证(2026-09-24)
|
||||||
|
|
||||||
|
- `PySide6-Fluent-Widgets 1.11.3` 已替换 qt-material;主界面使用 Fluent 卡片、控件和树视图,主题选择持久化并支持跟随系统。
|
||||||
|
- 9 项 EDID 解析测试、Python 编译检查和离屏窗口启动通过;主题下拉框可切换 system/light/dark/dark1/dark2。
|
||||||
|
- `build.ps1` 打包通过,`dist\\EDID-Viewer\\_internal\\qfluentwidgets` 资源已收集;离线 EDID 样本可渲染并启用 BIN/JSON 导出。
|
||||||
|
|
||||||
|
# 目录重构与 onefile 打包验证(2026-09-24)
|
||||||
|
|
||||||
|
- 目录对齐 DLPilot 三区结构:`src/`(代码 + 流水线)、`assets/`(图标)、`release/`(EDID-Viewer.exe + README);`agent.md` 更名 `AGENTS.md`;`build.ps1`/`viewer.spec` 由 `src/build_exe.py`(生成 spec,ICU 排除逻辑内置)取代。
|
||||||
|
- `src/` 下 9 项解析测试通过;`src/build_exe.py` 单文件打包通过,`release\EDID-Viewer.exe` 启动验证窗口正常、图标与主题(三件套:QPalette + 应用级 QSS + DWM 标题栏)保持上一轮修复效果。
|
||||||
|
- `src/package_release.py` 组装 zip(exe + README);`src/publish_gitea.py` 由 DLPilot 同名脚本适配(tag 前缀 `EDID-Viewer-v*`),本次未实际上传。
|
||||||
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,13 @@
|
|||||||
|
"""Rebuild icon with Pillow (development only); matches the DLPilot brand."""
|
||||||
|
from pathlib import Path
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
|
||||||
|
out = Path(__file__).resolve().parent
|
||||||
|
image = Image.new('RGB', (512,512), 'black')
|
||||||
|
draw = ImageDraw.Draw(image)
|
||||||
|
draw.rounded_rectangle((38,64,474,250),radius=34,fill='#ff9900')
|
||||||
|
font = 'C:/Windows/Fonts/arialbd.ttf'
|
||||||
|
draw.text((256,157),'EDID',font=ImageFont.truetype(font,134),anchor='mm',fill='black')
|
||||||
|
draw.text((256,368),'Viewer',font=ImageFont.truetype(font,116),anchor='mm',fill='white')
|
||||||
|
image.save(out/'edid-viewer.png')
|
||||||
|
image.save(out/'edid-viewer.ico',sizes=[(16,16),(24,24),(32,32),(48,48),(64,64),(128,128),(256,256)])
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
# EDID Viewer
|
||||||
|
|
||||||
|
Windows 10/11 显示器 EDID 查看器。使用 **PySide6 / PySide6-Fluent-Widgets**,只读,不修改显示设置。
|
||||||
|
|
||||||
|
> 只想使用工具:到 [Gitea Releases](https://gitea.hulk.wang/hulk/HW-Debug-Tools/releases)
|
||||||
|
> 下载 `EDID-Viewer-vX.Y.Z-win64.zip`,解压双击 `EDID-Viewer.exe` 即可(Windows 10/11 x64,免安装、无需 Python)。
|
||||||
|
|
||||||
|
## 使用
|
||||||
|
|
||||||
|
- 双击 `release\EDID-Viewer.exe`(单文件,免安装)。
|
||||||
|
- 或双击 `start.cmd` 使用本机 Python 环境运行源码。
|
||||||
|
- 右上角「外观」选择 Light(浅色)、Dark(琥珀深色)、dark1(蓝色深色)、dark2(青色深色)或跟随系统;默认跟随系统,选择自动保存,系统模式响应 Windows 明暗变化。
|
||||||
|
- 图标沿用 DLPilot 的黑底/橙色标签/白字语言,文字为 EDID / Viewer;窗口、任务栏和 EXE 使用同一图标。
|
||||||
|
- 当前布局采用 Fluent Widgets:顶部设备/文件操作卡片、右上角「关于」,下方信息卡片和分组页签;Dark 使用琥珀强调色,dark1 使用蓝色强调色,dark2 使用青色强调色,主题随系统设置持久化。
|
||||||
|
- 点击「刷新设备」,从下拉框选择设备。HDMI、DP 和内屏均显示连接类型。
|
||||||
|
- 「设备与能力」显示身份和音频/HDR/色彩/HDMI 信息;「分辨率与时序」可展开 DTD 查看像素时钟、前后肩、同步宽度和极性。
|
||||||
|
- 「原始 HEX」支持选中复制。「导出 BIN」保持读取到的字节不变;「导出报告」生成含原始数据的 UTF-8 JSON。
|
||||||
|
- 支持 `.bin/.edid` 二进制和 `.hex/.txt` 纯十六进制。HEX 可以使用空格、逗号、`0x` 前缀,不接受带地址/ASCII 栏的 hexdump。
|
||||||
|
|
||||||
|
## 目录结构(对齐 DLPilot)
|
||||||
|
|
||||||
|
- `src/` — 人写代码:界面(main.py)、EDID 解析(edid.py)、Windows 读取(windows_edid.py)、主题(theme.py)、解析测试(test_edid.py)和打包流水线。
|
||||||
|
- `assets/` — 图标与生成脚本(可再生)。
|
||||||
|
- `release/` — 交付物:`EDID-Viewer.exe` 入库;发布 zip 只上传 Gitea Release,不入库。
|
||||||
|
- `AGENTS.md` — 工程约定与任务边界(改代码前必读);`VALIDATION.md` — 验证记录。
|
||||||
|
|
||||||
|
## 环境与构建
|
||||||
|
|
||||||
|
本机:Python 3.14、PySide6 6.11.2、PySide6-Fluent-Widgets 1.11.3、PyInstaller 6.22.2。当前 `.venv` 通过 `--system-site-packages` 复用已安装依赖,不修改全局包。新电脑可以创建独立环境:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
python -m venv .venv
|
||||||
|
.\.venv\Scripts\python.exe -m pip install -r requirements.txt
|
||||||
|
.\.venv\Scripts\python.exe src\main.py
|
||||||
|
cd src && python -m unittest # 9 项解析测试
|
||||||
|
python src\build_exe.py # 打包 → release\EDID-Viewer.exe
|
||||||
|
python src\package_release.py 0.1.0 # 组装 release\EDID-Viewer-v0.1.0-win64.zip
|
||||||
|
python src\publish_gitea.py ..\release\EDID-Viewer-v0.1.0-win64.zip --insecure
|
||||||
|
```
|
||||||
|
|
||||||
|
打包为单文件 exe;spec 由 `build_exe.py` 生成到 `src/build/`(不入库),其中剔除 PATH 上其他工具(Poppler/Conda)的版本化 ICU DLL,避免 QtCore 加载失败(WinError 127)。构建前关闭正在运行的 EDID Viewer,以免文件被占用。图标源为 `assets/make_icon.py`,重新生成时需安装 Pillow(仅开发时需要)。主题配置保存在当前用户的 `QSettings: LT8619C-Tools/EDID-Viewer`。
|
||||||
|
|
||||||
|
## 能力范围
|
||||||
|
|
||||||
|
- EDID 1.x 基础身份、生产日期、名称/序列号、物理尺寸、Gamma、色深、色度坐标。
|
||||||
|
- 已建立/标准时序、基础与 CTA 详细时序;常用 CTA VIC(未映射的 VIC 显示编号)。
|
||||||
|
- 多个 CTA 扩展、音频 SAD、HDMI VSDB、CEC 地址、深色、TMDS、HF-VSDB 的 SCDC/TMDS。
|
||||||
|
- HDR EOTF、色彩标准、YCbCr 4:2:0 声明。未知块原样保留。
|
||||||
|
- 每块校验和、扩展计数、截断和数据块越界诊断。
|
||||||
|
|
||||||
|
## 限制
|
||||||
|
|
||||||
|
- 读取 `root/wmi:WmiMonitorDescriptorMethods` 中的活动设备,不保证列出禁用输出/驱动不提供 WMI 的设备。失败会显示原因,可改用离线文件。
|
||||||
|
- 数据来自 Windows/显卡驱动,可能是缓存或覆盖内容,不是实时 DDC 抓取。读取扩展失败时保留已经取得的块并报告缺失。
|
||||||
|
- EDID 能力不等于当前输出模式;不能据此确定 HDCP、线材质量、正在使用的 HDR/色深或 HDMI 版本。
|
||||||
|
- DisplayID 和 HDMI Forum VRR/ALLM/FRL/DSC 尚未详细解码;仅包含 DisplayID 时序的屏幕可能没有可解码的分辨率。范围描述符扩展偏移仅提示,未应用。
|
||||||
|
- 不承诺所有 CTA VIC/扩展标签均已覆盖。厂商首先显示标准 PNP 三字母代码,避免错误猜测品牌。
|
||||||
|
|
||||||
|
## 推荐后续挖掘
|
||||||
|
|
||||||
|
1. **桥接板时序匹配**:像素时钟、H/V 消隐、同步极性和首选模式,排查黑屏、偏色、画面偏移。
|
||||||
|
2. **EDID 差异比较**:对照板卡固件、Windows 读取值、显示器原始值,定位缓存、截断或改写。
|
||||||
|
3. **带宽与色彩**:TMDS/FRL、RGB/YCbCr、深色和 4:2:0,解释分辨率或刷新率受限。
|
||||||
|
4. **HDR 与音频**:PQ/HLG、亮度元数据、PCM 位深/采样率/声道和压缩音频能力。
|
||||||
|
5. **DisplayID / VRR / DSC**:适合高刷新率和高分辨率显示设备,作为下一阶段扩展。
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
PySide6==6.11.2
|
||||||
|
PySide6-Fluent-Widgets==1.11.3
|
||||||
|
pyinstaller==6.22.2
|
||||||
|
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
把 src/main.py 打包成单文件 exe(工具名: EDID-Viewer)
|
||||||
|
================================================
|
||||||
|
与 DLPilot/src/build_exe.py 同一套路: onefile + --noconsole, Python 解释器、
|
||||||
|
PySide6 和 PySide6-Fluent-Widgets 全部打进一个 exe, 目标机器无需安装依赖。
|
||||||
|
|
||||||
|
用法:
|
||||||
|
python build_exe.py 自动安装 PyInstaller(如缺)并打包
|
||||||
|
python build_exe.py --debug 额外打一个带控制台的变体
|
||||||
|
|
||||||
|
产物: release/EDID-Viewer.exe
|
||||||
|
spec 由本脚本生成到 src/build/(不入库), 调整打包逻辑直接改这里的模板。
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# 本脚本位于 src/, 打包产物输出到工具根的 release/
|
||||||
|
SRC = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
BASE = os.path.dirname(SRC)
|
||||||
|
RELEASE = os.path.join(BASE, 'release')
|
||||||
|
WORK = os.path.join(SRC, 'build')
|
||||||
|
ICO = os.path.join(BASE, 'assets', 'edid-viewer.ico')
|
||||||
|
|
||||||
|
SPEC_TEMPLATE = """\
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# 由 build_exe.py 生成, 不要手改; 调整打包逻辑请改 src/build_exe.py。
|
||||||
|
from PyInstaller.utils.hooks import collect_all
|
||||||
|
|
||||||
|
qfluent_datas, qfluent_binaries, qfluent_hidden = collect_all('qfluentwidgets')
|
||||||
|
a = Analysis(
|
||||||
|
[r'{entry}'], pathex=[r'{src}'], binaries=qfluent_binaries,
|
||||||
|
datas=qfluent_datas + {icon_datas}, hiddenimports=qfluent_hidden,
|
||||||
|
noarchive=False)
|
||||||
|
# Qt 6.11 使用 Windows 非版本化 ICU 导出; PATH 上 Poppler/Conda 的版本化
|
||||||
|
# ICU(icuuc.dll/icudt78.dll)会被 PyInstaller 误收, 令 QtCore.pyd 启动报
|
||||||
|
# WinError 127 —— 打包时剔除, 运行时用系统自带 ICU。
|
||||||
|
a.binaries = [b for b in a.binaries if b[0].lower() not in ('icuuc.dll', 'icudt78.dll')]
|
||||||
|
pyz = PYZ(a.pure)
|
||||||
|
exe = EXE(pyz, a.scripts, a.binaries, a.datas, [], name='{name}',
|
||||||
|
debug=False, strip=False, upx=False, console={console}{icon_clause})
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_pyinstaller():
|
||||||
|
try:
|
||||||
|
import PyInstaller # noqa: F401
|
||||||
|
return
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
print('PyInstaller 未安装, 正在安装...')
|
||||||
|
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'pyinstaller'])
|
||||||
|
|
||||||
|
|
||||||
|
def remove_stale(exe_path):
|
||||||
|
"""删除旧 exe; 若被占用(上次验证的进程还在), 先结束同名进程再重试"""
|
||||||
|
if not os.path.exists(exe_path):
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
os.remove(exe_path)
|
||||||
|
return
|
||||||
|
except PermissionError:
|
||||||
|
pass
|
||||||
|
import time
|
||||||
|
print(f'{exe_path} 被占用, 结束残留进程后重试...')
|
||||||
|
subprocess.run(['taskkill', '/F', '/IM', os.path.basename(exe_path)],
|
||||||
|
capture_output=True)
|
||||||
|
time.sleep(1.0)
|
||||||
|
os.remove(exe_path)
|
||||||
|
|
||||||
|
|
||||||
|
def build(name, console):
|
||||||
|
remove_stale(os.path.join(RELEASE, name + '.exe'))
|
||||||
|
if os.path.exists(ICO):
|
||||||
|
icon_datas = f"[(r'{ICO}', 'assets')]"
|
||||||
|
icon_clause = f", icon=r'{ICO}'"
|
||||||
|
else:
|
||||||
|
print('警告: 未找到 assets/edid-viewer.ico(先运行 assets/make_icon.py), 本次打包不带图标')
|
||||||
|
icon_datas, icon_clause = '[]', ''
|
||||||
|
spec = SPEC_TEMPLATE.format(entry=os.path.join(SRC, 'main.py'), src=SRC,
|
||||||
|
icon_datas=icon_datas, name=name,
|
||||||
|
console=console, icon_clause=icon_clause)
|
||||||
|
os.makedirs(WORK, exist_ok=True)
|
||||||
|
spec_path = os.path.join(WORK, name + '.spec')
|
||||||
|
with open(spec_path, 'w', encoding='utf-8') as f:
|
||||||
|
f.write(spec)
|
||||||
|
cmd = [sys.executable, '-m', 'PyInstaller', '--noconfirm', '--clean',
|
||||||
|
'--distpath', RELEASE, '--workpath', WORK, spec_path]
|
||||||
|
print('\n>>', ' '.join(cmd))
|
||||||
|
subprocess.check_call(cmd)
|
||||||
|
out = os.path.join(RELEASE, name + '.exe')
|
||||||
|
print(f'完成: {out} ({os.path.getsize(out) / 1024 / 1024:.1f} MB)')
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
build_console = '--debug' in sys.argv
|
||||||
|
ensure_pyinstaller()
|
||||||
|
# 常规版: 双击即用, 无黑框
|
||||||
|
build('EDID-Viewer', 'False')
|
||||||
|
if build_console:
|
||||||
|
# 调试版: 带控制台, 异常栈可见
|
||||||
|
build('EDID-Viewer-console', 'True')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
"""Bounds-checked EDID 1.x / CTA parser. Unknown fields retain their bytes."""
|
||||||
|
import hashlib
|
||||||
|
import re
|
||||||
|
|
||||||
|
VICS = {1:'640×480p 60 Hz',2:'720×480p 60 Hz 4:3',3:'720×480p 60 Hz 16:9',
|
||||||
|
4:'1280×720p 60 Hz',5:'1920×1080i 60 Hz',16:'1920×1080p 60 Hz',
|
||||||
|
17:'720×576p 50 Hz 4:3',18:'720×576p 50 Hz 16:9',19:'1280×720p 50 Hz',
|
||||||
|
20:'1920×1080i 50 Hz',31:'1920×1080p 50 Hz',32:'1920×1080p 24 Hz',
|
||||||
|
33:'1920×1080p 25 Hz',34:'1920×1080p 30 Hz',60:'1280×720p 24 Hz',
|
||||||
|
61:'1280×720p 25 Hz',62:'1280×720p 30 Hz',63:'1920×1080p 120 Hz',64:'1920×1080p 100 Hz',
|
||||||
|
93:'3840×2160p 24 Hz',94:'3840×2160p 25 Hz',95:'3840×2160p 30 Hz',
|
||||||
|
96:'3840×2160p 50 Hz',97:'3840×2160p 60 Hz',98:'4096×2160p 24 Hz',
|
||||||
|
99:'4096×2160p 25 Hz',100:'4096×2160p 30 Hz',101:'4096×2160p 50 Hz',102:'4096×2160p 60 Hz',
|
||||||
|
117:'3840×2160p 100 Hz',118:'3840×2160p 120 Hz'}
|
||||||
|
EST = ['720×400 70 Hz','720×400 88 Hz','640×480 60 Hz','640×480 67 Hz','640×480 72 Hz',
|
||||||
|
'640×480 75 Hz','800×600 56 Hz','800×600 60 Hz','800×600 72 Hz','800×600 75 Hz',
|
||||||
|
'832×624 75 Hz','1024×768i 87 Hz','1024×768 60 Hz','1024×768 70 Hz','1024×768 75 Hz',
|
||||||
|
'1280×1024 75 Hz','1152×870 75 Hz']
|
||||||
|
|
||||||
|
def read_file(path):
|
||||||
|
from pathlib import Path
|
||||||
|
data = Path(path).read_bytes()
|
||||||
|
if len(data) > 32768 * 4:
|
||||||
|
raise ValueError('文件过大:最大 128 KiB')
|
||||||
|
if Path(path).suffix.lower() in ('.hex', '.txt'):
|
||||||
|
s = data.decode('utf-8-sig').strip()
|
||||||
|
s = re.sub(r'0[xX]([0-9a-fA-F]{2})', r'\1', s)
|
||||||
|
s = re.sub(r'[\s,{};]', '', s)
|
||||||
|
if not re.fullmatch(r'(?:[0-9a-fA-F]{2})+', s):
|
||||||
|
raise ValueError('HEX 文件仅接受十六进制字节,不接受偏移地址或 ASCII 栏')
|
||||||
|
return bytes.fromhex(s)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def hex_dump(raw):
|
||||||
|
return '\n'.join(f'{i:04X} ' + ' '.join(f'{x:02X}' for x in raw[i:i+16]) +
|
||||||
|
' |' + ''.join(chr(x) if 32 <= x < 127 else '.' for x in raw[i:i+16]) + '|'
|
||||||
|
for i in range(0, len(raw), 16))
|
||||||
|
|
||||||
|
def dtd(b, source):
|
||||||
|
clock = int.from_bytes(b[:2], 'little') * 10000
|
||||||
|
h = b[2] + ((b[4] & 240) << 4); hb = b[3] + ((b[4] & 15) << 8)
|
||||||
|
v = b[5] + ((b[7] & 240) << 4); vb = b[6] + ((b[7] & 15) << 8)
|
||||||
|
hf = b[8] + ((b[11] & 192) << 2); hs = b[9] + ((b[11] & 48) << 4)
|
||||||
|
vf = (b[10] >> 4) + ((b[11] & 12) << 2); vs = (b[10] & 15) + ((b[11] & 3) << 4)
|
||||||
|
interlace = bool(b[17] & 128)
|
||||||
|
total_v = (v + vb) * 2 + 1 if interlace else v + vb
|
||||||
|
rate = clock / ((h + hb) * total_v) if h + hb and total_v else 0
|
||||||
|
sync = (b[17] >> 3) & 3
|
||||||
|
polarity = ('H' + ('+' if b[17] & 2 else '-') + ' V' + ('+' if b[17] & 4 else '-')) if sync == 3 else '非数字分离同步'
|
||||||
|
return {'来源':source, '分辨率':f'{h}×{v*2 if interlace else v}' + ('i' if interlace else 'p'),
|
||||||
|
'刷新率':f'{rate*2 if interlace else rate:.3f} Hz' + ('(场率)' if interlace else ''),
|
||||||
|
'像素时钟 MHz':clock / 1e6, '水平有效/前肩/同步/后肩':[h,hf,hs,hb-hf-hs],
|
||||||
|
'垂直有效/前肩/同步/后肩(隔行按场)':[v,vf,vs,vb-vf-vs], '同步':polarity}
|
||||||
|
|
||||||
|
def parse(raw):
|
||||||
|
if len(raw) < 128:
|
||||||
|
raise ValueError(f'EDID 基础块不足 128 字节,实际 {len(raw)}')
|
||||||
|
r = {'基本信息':{}, '时序':[], '能力':[], '数据块':[], '校验':[], '警告':[]}
|
||||||
|
info, warnings = r['基本信息'], r['警告']
|
||||||
|
if raw[:8] != bytes.fromhex('00 ff ff ff ff ff ff 00'):
|
||||||
|
warnings.append('EDID 文件头无效;以下解析仅供诊断')
|
||||||
|
if raw[18] != 1:
|
||||||
|
warnings.append('非 EDID 1.x:未解析,仅保留原始数据')
|
||||||
|
return r
|
||||||
|
if len(raw) % 128: warnings.append('末尾存在不足 128 字节的数据')
|
||||||
|
expected = (raw[126] + 1) * 128
|
||||||
|
if expected != len(raw): warnings.append(f'声明 {expected} 字节,实际 {len(raw)} 字节')
|
||||||
|
for n in range(len(raw)//128):
|
||||||
|
block = raw[n*128:(n+1)*128]
|
||||||
|
r['校验'].append(f'块 {n}: ' + ('通过' if sum(block)%256 == 0 else '失败'))
|
||||||
|
pnp = int.from_bytes(raw[8:10], 'big')
|
||||||
|
manufacturer = ''.join(chr(((pnp >> s) & 31) + 64) for s in (10,5,0))
|
||||||
|
info.update({'厂家 PNP 代码':manufacturer, '产品编号':f'0x{int.from_bytes(raw[10:12], "little"):04X}',
|
||||||
|
'数字序列号':int.from_bytes(raw[12:16], 'little'), 'EDID 版本':f'{raw[18]}.{raw[19]}',
|
||||||
|
'生产日期':f'{raw[17]+1990} 年 / '+('型号年份' if raw[16]==255 else f'第 {raw[16]} 周' if raw[16] else '周未指定'),
|
||||||
|
'尺寸':f'{raw[21]} × {raw[22]} cm' if raw[21] and raw[22] else '未给出完整物理尺寸(可能编码宽高比)',
|
||||||
|
'Gamma':(raw[23]+100)/100 if raw[23]!=255 else '未定义',
|
||||||
|
'扩展块数':raw[126], 'SHA-256':hashlib.sha256(raw).hexdigest()})
|
||||||
|
if raw[20]&128:
|
||||||
|
info['输入类型'] = '数字'
|
||||||
|
if raw[19]>=4:
|
||||||
|
info['接口声明'] = {0:'未定义',1:'DVI',2:'HDMI-A',3:'HDMI-B',4:'MDDI',5:'DisplayPort'}.get(raw[20]&15,'保留')
|
||||||
|
info['色深 bpc'] = {0:'未定义',1:6,2:8,3:10,4:12,5:14,6:16}.get((raw[20]>>4)&7,'保留')
|
||||||
|
else: info['输入类型'] = '模拟'
|
||||||
|
for idx, mode in enumerate(EST):
|
||||||
|
if raw[35+idx//8] & (128>>(idx%8)): r['时序'].append({'来源':'已建立时序','分辨率':mode})
|
||||||
|
for i in range(38,54,2):
|
||||||
|
a,b = raw[i:i+2]
|
||||||
|
if (a,b) in ((1,1),(0,0)): continue
|
||||||
|
h = (a+31)*8
|
||||||
|
ratio = (1 if raw[19]<3 else 10/16, 3/4, 4/5, 9/16)[b>>6]
|
||||||
|
r['时序'].append({'来源':'标准时序','分辨率':f'{h}×{round(h*ratio)}','刷新率':f'{(b&63)+60} Hz'})
|
||||||
|
for offset in range(54,126,18):
|
||||||
|
b=raw[offset:offset+18]
|
||||||
|
if any(b[:2]):
|
||||||
|
r['时序'].append(dtd(b, '基础 DTD'+('(首选)' if offset==54 and (raw[19]>=4 or raw[24]&2) else '')))
|
||||||
|
elif b[:3]==b'\0\0\0':
|
||||||
|
if b[3] in (252,255,254): info[{252:'显示器名称',255:'文本序列号',254:'描述文本'}[b[3]]] = b[5:18].decode('ascii','replace').strip('\x00\n ')
|
||||||
|
elif b[3]==253:
|
||||||
|
info['频率范围原始值'] = f'垂直 {b[5]}–{b[6]} Hz;水平 {b[7]}–{b[8]} kHz;最大像素时钟 {b[9]*10} MHz'
|
||||||
|
if b[4]: warnings.append('范围描述符有扩展偏移,频率范围显示原始字段,暂未应用偏移')
|
||||||
|
coords=[]
|
||||||
|
low=[(raw[25]>>s)&3 for s in (6,4,2,0)]+[(raw[26]>>s)&3 for s in (6,4,2,0)]
|
||||||
|
for i,name in enumerate(('Rx','Ry','Gx','Gy','Bx','By','Wx','Wy')): coords.append(f'{name}={(raw[27+i]*4+low[i])/1024:.4f}')
|
||||||
|
r['能力'].append('色度坐标:'+', '.join(coords))
|
||||||
|
for n in range(1,min(len(raw)//128,raw[126]+1)):
|
||||||
|
b=raw[n*128:(n+1)*128]
|
||||||
|
r['数据块'].append({'块':n,'类型':{2:'CTA-861',112:'DisplayID(暂未解码)'}.get(b[0],f'未知 0x{b[0]:02X}'),'原始':b.hex(' ')})
|
||||||
|
if b[0]!=2: continue
|
||||||
|
r['能力'].append(f'CTA 块 {n} / revision {b[1]}:'+', '.join(label for bit,label in ((64,'基本音频'),(32,'YCbCr 4:4:4'),(16,'YCbCr 4:2:2')) if b[3]&bit))
|
||||||
|
end=b[2]
|
||||||
|
if end==0: continue
|
||||||
|
if not 4<=end<=127:
|
||||||
|
warnings.append(f'CTA 块 {n} DTD 偏移无效:{end}'); continue
|
||||||
|
p=4
|
||||||
|
while p<end:
|
||||||
|
tag,length=b[p]>>5,b[p]&31
|
||||||
|
if not b[p]: break
|
||||||
|
if p+1+length>end:
|
||||||
|
warnings.append(f'CTA 块 {n} 数据块越界 @{p}'); break
|
||||||
|
x=b[p+1:p+1+length]; p+=length+1
|
||||||
|
entry={'块':n,'tag':tag,'原始':x.hex(' ')}; r['数据块'].append(entry)
|
||||||
|
if tag==2:
|
||||||
|
for svd in x:
|
||||||
|
vic=svd&127 if 129<=svd<=192 else svd
|
||||||
|
r['时序'].append({'来源':f'CTA VIC {vic}'+('(原生)' if 129<=svd<=192 else ''),'分辨率':VICS.get(vic,'尚未映射;查看 VIC 编号')})
|
||||||
|
elif tag==1:
|
||||||
|
if len(x)%3: warnings.append('音频数据块长度不是 3 的倍数')
|
||||||
|
for j in range(0,len(x)-2,3):
|
||||||
|
a,f,c=x[j:j+3]; fmt=(a>>3)&15
|
||||||
|
rates='/'.join(str(v) for k,v in enumerate((32,44.1,48,88.2,96,176.4,192)) if f&(1<<k))
|
||||||
|
bits='/'.join(str(v) for k,v in enumerate((16,20,24)) if c&(1<<k))
|
||||||
|
r['能力'].append(f'音频:'+{1:'LPCM',2:'AC-3',7:'DTS',10:'E-AC-3',11:'DTS-HD',12:'MAT'}.get(fmt,f'格式代码 {fmt}')+f' / {(a&7)+1} 声道 / {rates} kHz'+(f' / {bits} bit' if fmt==1 else f' / 格式字段 0x{c:02X}'))
|
||||||
|
elif tag==3 and len(x)>=3:
|
||||||
|
oui=int.from_bytes(x[:3],'little'); entry['OUI']=f'{oui:06X}'
|
||||||
|
if oui==0x000c03:
|
||||||
|
r['能力'].append('HDMI VSDB')
|
||||||
|
if len(x)>=5: r['能力'].append('CEC 物理地址:'+'.'.join(str(v) for v in (x[3]>>4,x[3]&15,x[4]>>4,x[4]&15)))
|
||||||
|
if len(x)>=6: r['能力'].append('HDMI 深色:'+('/'.join(str(v) for k,v in ((4,10),(5,12),(6,16)) if x[5]&(1<<k)) or '未声明')+' bpc')
|
||||||
|
if len(x)>=7 and x[6]: r['能力'].append(f'最大 TMDS 时钟:{x[6]*5} MHz')
|
||||||
|
elif oui==0xc45dd8:
|
||||||
|
r['能力'].append('HDMI Forum VSDB(VRR/FRL/DSC 字段暂未解码)')
|
||||||
|
if len(x)>=5 and x[4]: r['能力'].append(f'最大 TMDS 字符速率:{x[4]*5} MHz')
|
||||||
|
if len(x)>=6: r['能力'].append('SCDC:'+('支持' if x[5]&128 else '未声明'))
|
||||||
|
elif tag==7 and x:
|
||||||
|
entry['扩展 tag']=x[0]
|
||||||
|
if x[0]==6 and len(x)>=3:
|
||||||
|
r['能力'].append('HDR EOTF:'+', '.join(name for k,name in enumerate(('传统 SDR','传统 HDR','PQ / ST 2084','HLG')) if x[1]&(1<<k)))
|
||||||
|
r['能力'].append(f'HDR 静态元数据类型位图:0x{x[2]:02X}')
|
||||||
|
elif x[0]==14:
|
||||||
|
r['能力'].append('仅 YCbCr 4:2:0 VIC:'+', '.join(f'{v} ({VICS.get(v,"未映射")})' for v in x[1:]))
|
||||||
|
elif x[0]==15: r['能力'].append('YCbCr 4:2:0 能力映射:'+x[1:].hex(' ')+'(按本 CTA SVD 顺序)')
|
||||||
|
elif x[0]==5 and len(x)>=3:
|
||||||
|
r['能力'].append('色彩标准:'+', '.join(name for k,name in enumerate(('xvYCC601','xvYCC709','sYCC601','opYCC601','opRGB','BT.2020 cYCC','BT.2020 YCC','BT.2020 RGB')) if x[1]&(1<<k)))
|
||||||
|
for o in range(end,110,18):
|
||||||
|
if any(b[o:o+2]): r['时序'].append(dtd(b[o:o+18],f'CTA {n} DTD'))
|
||||||
|
return r
|
||||||
@@ -0,0 +1,391 @@
|
|||||||
|
"""Fluent EDID viewer for Windows display devices and offline files."""
|
||||||
|
|
||||||
|
import ctypes
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from PySide6.QtCore import QThread, Qt, QTimer, Signal
|
||||||
|
from PySide6.QtGui import QFont, QFontDatabase, QIcon
|
||||||
|
from PySide6.QtWidgets import (
|
||||||
|
QApplication,
|
||||||
|
QFileDialog,
|
||||||
|
QHBoxLayout,
|
||||||
|
QMainWindow,
|
||||||
|
QMessageBox,
|
||||||
|
QPlainTextEdit,
|
||||||
|
QSizePolicy,
|
||||||
|
QSplitter,
|
||||||
|
QTabWidget,
|
||||||
|
QTreeWidgetItem,
|
||||||
|
QVBoxLayout,
|
||||||
|
QWidget,
|
||||||
|
)
|
||||||
|
from qfluentwidgets import (
|
||||||
|
BodyLabel,
|
||||||
|
CaptionLabel,
|
||||||
|
CardWidget,
|
||||||
|
ComboBox,
|
||||||
|
FluentIcon,
|
||||||
|
PlainTextEdit,
|
||||||
|
PrimaryPushButton,
|
||||||
|
PushButton,
|
||||||
|
StrongBodyLabel,
|
||||||
|
SubtitleLabel,
|
||||||
|
TreeWidget,
|
||||||
|
)
|
||||||
|
|
||||||
|
from edid import hex_dump, parse, read_file
|
||||||
|
from theme import ThemeManager
|
||||||
|
from windows_edid import scan
|
||||||
|
|
||||||
|
APP_NAME = "EDID Viewer"
|
||||||
|
APP_VERSION = "0.1.0"
|
||||||
|
REPO_URL = "https://gitea.hulk.wang/hulk/HW-Debug-Tools"
|
||||||
|
|
||||||
|
|
||||||
|
def icon_path():
|
||||||
|
"""Packaged onefile: icon is extracted under sys._MEIPASS/assets; source: ../assets."""
|
||||||
|
if hasattr(sys, "_MEIPASS"):
|
||||||
|
return Path(sys._MEIPASS) / "assets" / "edid-viewer.ico"
|
||||||
|
return Path(__file__).resolve().parent.parent / "assets" / "edid-viewer.ico"
|
||||||
|
|
||||||
|
|
||||||
|
class Scanner(QThread):
|
||||||
|
result = Signal(object)
|
||||||
|
failure = Signal(str)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
try:
|
||||||
|
self.result.emit(scan())
|
||||||
|
except Exception as exc:
|
||||||
|
self.failure.emit(str(exc))
|
||||||
|
|
||||||
|
|
||||||
|
class Window(QMainWindow):
|
||||||
|
"""Main Fluent surface; parser and Windows access remain separate modules."""
|
||||||
|
|
||||||
|
def __init__(self, theme_manager=None):
|
||||||
|
super().__init__()
|
||||||
|
self.theme_manager = theme_manager or ThemeManager(QApplication.instance())
|
||||||
|
self.setWindowTitle("EDID Viewer · HDMI 显示信息")
|
||||||
|
self.resize(1240, 820)
|
||||||
|
self.setMinimumSize(900, 620)
|
||||||
|
self.raw = b""
|
||||||
|
self.report = {}
|
||||||
|
self.worker = None
|
||||||
|
self._build_ui()
|
||||||
|
self.theme_manager.set_window(self)
|
||||||
|
self.bin_button.setEnabled(False)
|
||||||
|
self.export_button.setEnabled(False)
|
||||||
|
QTimer.singleShot(0, self.start_scan)
|
||||||
|
|
||||||
|
def _button(self, text, callback, primary=False, icon=None):
|
||||||
|
button = PrimaryPushButton(self) if primary else PushButton(self)
|
||||||
|
button.setText(text)
|
||||||
|
if icon is not None:
|
||||||
|
button.setIcon(icon)
|
||||||
|
button.clicked.connect(callback)
|
||||||
|
return button
|
||||||
|
|
||||||
|
def _card(self, title, subtitle=None, parent=None):
|
||||||
|
card = CardWidget(parent or self)
|
||||||
|
layout = QVBoxLayout(card)
|
||||||
|
layout.setContentsMargins(16, 14, 16, 16)
|
||||||
|
layout.setSpacing(9)
|
||||||
|
layout.addWidget(StrongBodyLabel(title, card))
|
||||||
|
if subtitle:
|
||||||
|
caption = CaptionLabel(subtitle, card)
|
||||||
|
caption.setWordWrap(True)
|
||||||
|
layout.addWidget(caption)
|
||||||
|
return card, layout
|
||||||
|
|
||||||
|
def _text(self, mono=False, parent=None):
|
||||||
|
text = PlainTextEdit(parent or self)
|
||||||
|
text.setReadOnly(True)
|
||||||
|
text.setLineWrapMode(QPlainTextEdit.NoWrap)
|
||||||
|
if mono:
|
||||||
|
text.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont))
|
||||||
|
return text
|
||||||
|
|
||||||
|
def _build_ui(self):
|
||||||
|
root = QWidget(self)
|
||||||
|
root.setObjectName("root")
|
||||||
|
outer = QVBoxLayout(root)
|
||||||
|
outer.setContentsMargins(22, 18, 22, 18)
|
||||||
|
outer.setSpacing(14)
|
||||||
|
|
||||||
|
header = QHBoxLayout()
|
||||||
|
title_box = QVBoxLayout()
|
||||||
|
title_box.setSpacing(1)
|
||||||
|
title_box.addWidget(SubtitleLabel("EDID Viewer", root))
|
||||||
|
title_box.addWidget(BodyLabel("显示设备能力与原始数据", root))
|
||||||
|
header.addLayout(title_box)
|
||||||
|
header.addStretch(1)
|
||||||
|
header.addWidget(BodyLabel("外观", root))
|
||||||
|
self.theme_choice = ComboBox(root)
|
||||||
|
self.theme_choice.setAccessibleName("外观主题")
|
||||||
|
for label, value in (
|
||||||
|
("跟随系统", "system"),
|
||||||
|
("Light · 浅色", "light"),
|
||||||
|
("Dark · 深色", "dark"),
|
||||||
|
("dark1 · 蓝色", "dark1"),
|
||||||
|
("dark2 · 青色", "dark2"),
|
||||||
|
):
|
||||||
|
self.theme_choice.addItem(label)
|
||||||
|
self.theme_choice.setItemData(self.theme_choice.count() - 1, value)
|
||||||
|
self.theme_choice.setCurrentIndex(self.theme_choice.findData(self.theme_manager.mode))
|
||||||
|
self.theme_choice.currentIndexChanged.connect(
|
||||||
|
lambda: self.theme_manager.set_mode(self.theme_choice.currentData())
|
||||||
|
)
|
||||||
|
header.addWidget(self.theme_choice)
|
||||||
|
header.addWidget(self._button("关于", self.show_about))
|
||||||
|
outer.addLayout(header)
|
||||||
|
|
||||||
|
note = CaptionLabel(
|
||||||
|
"Windows 驱动提供的 EDID,可能包含缓存或覆盖;EDID 是接收端声明能力,不代表当前实际输出。",
|
||||||
|
root,
|
||||||
|
)
|
||||||
|
note.setWordWrap(True)
|
||||||
|
outer.addWidget(note)
|
||||||
|
|
||||||
|
split = QSplitter(Qt.Vertical, root)
|
||||||
|
split.setChildrenCollapsible(False)
|
||||||
|
split.setHandleWidth(8)
|
||||||
|
split.addWidget(self._build_sidebar())
|
||||||
|
split.addWidget(self._build_content())
|
||||||
|
split.setStretchFactor(0, 0)
|
||||||
|
split.setStretchFactor(1, 1)
|
||||||
|
split.setSizes([150, 620])
|
||||||
|
outer.addWidget(split, 1)
|
||||||
|
self.setCentralWidget(root)
|
||||||
|
|
||||||
|
def _build_sidebar(self):
|
||||||
|
host = QWidget(self)
|
||||||
|
host.setMinimumHeight(132)
|
||||||
|
host.setMaximumHeight(210)
|
||||||
|
layout = QHBoxLayout(host)
|
||||||
|
layout.setContentsMargins(2, 2, 2, 2)
|
||||||
|
layout.setSpacing(12)
|
||||||
|
|
||||||
|
card, body = self._card("显示设备", "选择活动输出并读取驱动提供的原始 EDID。", host)
|
||||||
|
card.setMinimumWidth(360)
|
||||||
|
self.devices = ComboBox(card)
|
||||||
|
self.devices.setMinimumHeight(38)
|
||||||
|
self.devices.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
||||||
|
device_row = QHBoxLayout()
|
||||||
|
device_row.setSpacing(8)
|
||||||
|
device_row.addWidget(self.devices, 1)
|
||||||
|
self.refresh_button = self._button("刷新设备", self.start_scan, icon=FluentIcon.SYNC)
|
||||||
|
self.refresh_button.setMinimumWidth(116)
|
||||||
|
device_row.addWidget(self.refresh_button)
|
||||||
|
body.addLayout(device_row)
|
||||||
|
layout.addWidget(card)
|
||||||
|
|
||||||
|
card, body = self._card("离线文件", "适用于 .bin、.edid、.hex 和纯十六进制 .txt。", host)
|
||||||
|
card.setMinimumWidth(430)
|
||||||
|
self.open_button = self._button("打开 EDID", self.open_file, primary=True, icon=FluentIcon.FOLDER)
|
||||||
|
self.bin_button = self._button("导出 BIN", self.save_bin, icon=FluentIcon.DOWNLOAD)
|
||||||
|
self.export_button = self._button("导出 JSON 报告", self.save_report, icon=FluentIcon.SAVE)
|
||||||
|
file_row = QHBoxLayout()
|
||||||
|
file_row.setSpacing(8)
|
||||||
|
for button in (self.open_button, self.bin_button, self.export_button):
|
||||||
|
button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
||||||
|
file_row.addWidget(button, 1)
|
||||||
|
body.addLayout(file_row)
|
||||||
|
layout.addWidget(card)
|
||||||
|
|
||||||
|
layout.setStretch(0, 1)
|
||||||
|
layout.setStretch(1, 1)
|
||||||
|
return host
|
||||||
|
|
||||||
|
def _build_content(self):
|
||||||
|
card = CardWidget(self)
|
||||||
|
layout = QVBoxLayout(card)
|
||||||
|
layout.setContentsMargins(18, 16, 18, 18)
|
||||||
|
layout.setSpacing(12)
|
||||||
|
self.summary = BodyLabel("正在读取设备…", card)
|
||||||
|
self.summary.setWordWrap(True)
|
||||||
|
layout.addWidget(self.summary)
|
||||||
|
|
||||||
|
self.tabs = QTabWidget(card)
|
||||||
|
self.tabs.setDocumentMode(True)
|
||||||
|
self.tree = TreeWidget(card)
|
||||||
|
self.tree.setHeaderLabels(["项目", "详细信息"])
|
||||||
|
self.tree.setColumnWidth(0, 260)
|
||||||
|
self.tree.setAlternatingRowColors(True)
|
||||||
|
self.tabs.addTab(self.tree, "设备与能力")
|
||||||
|
|
||||||
|
self.timings = TreeWidget(card)
|
||||||
|
self.timings.setHeaderLabels(["来源 / 字段", "分辨率 / 数值", "刷新率"])
|
||||||
|
self.timings.setColumnWidth(0, 255)
|
||||||
|
self.timings.setColumnWidth(1, 360)
|
||||||
|
self.timings.setAlternatingRowColors(True)
|
||||||
|
self.tabs.addTab(self.timings, "分辨率与时序")
|
||||||
|
|
||||||
|
self.hex = self._text(mono=True, parent=card)
|
||||||
|
self.tabs.addTab(self.hex, "原始 HEX")
|
||||||
|
self.details = self._text(mono=True, parent=card)
|
||||||
|
self.tabs.addTab(self.details, "完整解析 JSON")
|
||||||
|
layout.addWidget(self.tabs, 1)
|
||||||
|
|
||||||
|
self.devices.currentIndexChanged.connect(self.select_device)
|
||||||
|
return card
|
||||||
|
|
||||||
|
def show_about(self):
|
||||||
|
QMessageBox.about(
|
||||||
|
self,
|
||||||
|
f"关于 {APP_NAME}",
|
||||||
|
f"{APP_NAME} v{APP_VERSION}\n\n"
|
||||||
|
"Windows 显示器 EDID 查看器 · 只读,不修改显示设置\n"
|
||||||
|
"PySide6-Fluent-Widgets UI\n\n"
|
||||||
|
f"{REPO_URL}",
|
||||||
|
)
|
||||||
|
|
||||||
|
def start_scan(self):
|
||||||
|
if self.worker and self.worker.isRunning():
|
||||||
|
return
|
||||||
|
self.refresh_button.setEnabled(False)
|
||||||
|
self.open_button.setEnabled(False)
|
||||||
|
self.statusBar().showMessage("正在读取活动设备…")
|
||||||
|
self.worker = Scanner(self)
|
||||||
|
self.worker.result.connect(self.scanned)
|
||||||
|
self.worker.failure.connect(self.scan_failed)
|
||||||
|
self.worker.finished.connect(lambda: self.refresh_button.setEnabled(True))
|
||||||
|
self.worker.finished.connect(lambda: self.open_button.setEnabled(True))
|
||||||
|
self.worker.start()
|
||||||
|
|
||||||
|
def scan_failed(self, message):
|
||||||
|
self.statusBar().showMessage("设备读取失败,可打开离线 EDID 文件")
|
||||||
|
self.summary.setText("Windows EDID 读取失败:" + message)
|
||||||
|
|
||||||
|
def scanned(self, items):
|
||||||
|
old = self.devices.currentData()
|
||||||
|
old_id = old.get("instance") if old else None
|
||||||
|
self.devices.blockSignals(True)
|
||||||
|
self.devices.clear()
|
||||||
|
selected = 0
|
||||||
|
for index, item in enumerate(items):
|
||||||
|
name = item["instance"]
|
||||||
|
try:
|
||||||
|
info = parse(item["raw"])["基本信息"]
|
||||||
|
name = info.get("显示器名称", info.get("厂家 PNP 代码", name))
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
self.devices.addItem(
|
||||||
|
f'{item["连接"]} · {name} · {item["instance"]}',
|
||||||
|
userData=item,
|
||||||
|
)
|
||||||
|
if item["instance"] == old_id:
|
||||||
|
selected = index
|
||||||
|
self.devices.setCurrentIndex(selected)
|
||||||
|
self.devices.blockSignals(False)
|
||||||
|
self.select_device()
|
||||||
|
self.statusBar().showMessage(f"找到 {len(items)} 个活动设备;未启用的输出可能不会列出")
|
||||||
|
|
||||||
|
def select_device(self, *_):
|
||||||
|
item = self.devices.currentData()
|
||||||
|
if item:
|
||||||
|
self.show_raw(item["raw"], item["instance"] + " / " + item["连接"], item["error"])
|
||||||
|
else:
|
||||||
|
self.show_raw(b"", "未找到活动显示器。可刷新或打开离线文件。")
|
||||||
|
|
||||||
|
def show_raw(self, raw, source, error=""):
|
||||||
|
self.raw = raw
|
||||||
|
self.report = {}
|
||||||
|
self.tree.clear()
|
||||||
|
self.timings.clear()
|
||||||
|
self.details.clear()
|
||||||
|
self.hex.setPlainText(hex_dump(raw))
|
||||||
|
self.bin_button.setEnabled(bool(raw))
|
||||||
|
self.export_button.setEnabled(False)
|
||||||
|
try:
|
||||||
|
report = parse(raw)
|
||||||
|
except ValueError as exc:
|
||||||
|
self.summary.setText(f"{source}\n{error or str(exc)}")
|
||||||
|
return
|
||||||
|
|
||||||
|
self.report = {"来源": source, "读取错误": error, **report, "原始 HEX": raw.hex(" ")}
|
||||||
|
self.export_button.setEnabled(True)
|
||||||
|
messages = report["警告"] + [item for item in report["校验"] if "失败" in item]
|
||||||
|
if error:
|
||||||
|
messages.insert(0, error)
|
||||||
|
status = "各块校验通过" if not messages else "⚠ " + ";".join(messages)
|
||||||
|
self.summary.setText(f"{source}\n{len(raw)} 字节 · {status}")
|
||||||
|
|
||||||
|
for group in ("基本信息", "能力", "校验", "警告", "数据块"):
|
||||||
|
parent = QTreeWidgetItem(self.tree, [group])
|
||||||
|
value = report[group]
|
||||||
|
rows = value.items() if isinstance(value, dict) else enumerate(value, 1)
|
||||||
|
for key, item in rows:
|
||||||
|
rendered = json.dumps(item, ensure_ascii=False) if isinstance(item, (dict, list)) else str(item)
|
||||||
|
QTreeWidgetItem(parent, [str(key), rendered])
|
||||||
|
parent.setExpanded(group != "数据块")
|
||||||
|
|
||||||
|
for timing in report["时序"]:
|
||||||
|
parent = QTreeWidgetItem(self.timings, [timing["来源"], timing["分辨率"], timing.get("刷新率", "")])
|
||||||
|
for key, value in timing.items():
|
||||||
|
if key not in ("来源", "分辨率", "刷新率"):
|
||||||
|
QTreeWidgetItem(parent, [key, str(value)])
|
||||||
|
self.details.setPlainText(json.dumps(self.report, ensure_ascii=False, indent=2))
|
||||||
|
|
||||||
|
def open_path(self, path):
|
||||||
|
try:
|
||||||
|
raw = read_file(path)
|
||||||
|
self.devices.blockSignals(True)
|
||||||
|
self.devices.setCurrentIndex(-1)
|
||||||
|
self.devices.blockSignals(False)
|
||||||
|
self.show_raw(raw, "文件:" + str(path))
|
||||||
|
except (OSError, ValueError, UnicodeError) as exc:
|
||||||
|
QMessageBox.warning(self, "无法打开", str(exc))
|
||||||
|
|
||||||
|
def open_file(self):
|
||||||
|
path, _ = QFileDialog.getOpenFileName(
|
||||||
|
self,
|
||||||
|
"打开 EDID",
|
||||||
|
"",
|
||||||
|
"EDID (*.bin *.edid *.hex *.txt);;全部文件 (*)",
|
||||||
|
)
|
||||||
|
if path:
|
||||||
|
self.open_path(path)
|
||||||
|
|
||||||
|
def save_bin(self):
|
||||||
|
path, _ = QFileDialog.getSaveFileName(self, "导出原始 EDID", "edid.bin", "BIN (*.bin)")
|
||||||
|
if path:
|
||||||
|
self.write(path, self.raw)
|
||||||
|
|
||||||
|
def save_report(self):
|
||||||
|
path, _ = QFileDialog.getSaveFileName(self, "导出报告", "edid-report.json", "JSON (*.json)")
|
||||||
|
if path:
|
||||||
|
self.write(path, json.dumps(self.report, ensure_ascii=False, indent=2).encode("utf-8"))
|
||||||
|
|
||||||
|
def write(self, path, data):
|
||||||
|
try:
|
||||||
|
Path(path).write_bytes(data)
|
||||||
|
self.statusBar().showMessage("已保存:" + path)
|
||||||
|
except OSError as exc:
|
||||||
|
QMessageBox.warning(self, "保存失败", str(exc))
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
if self.worker and self.worker.isRunning():
|
||||||
|
self.statusBar().showMessage("正在读取,请等待读取完成后关闭(最长约 45 秒)")
|
||||||
|
event.ignore()
|
||||||
|
else:
|
||||||
|
event.accept()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if sys.platform == "win32":
|
||||||
|
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("LT8619C.Tools.EDIDViewer")
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
app.setApplicationName(APP_NAME)
|
||||||
|
app.setFont(QFont("Microsoft YaHei UI", 10))
|
||||||
|
app.setWindowIcon(QIcon(str(icon_path())))
|
||||||
|
theme_manager = ThemeManager(app)
|
||||||
|
window = Window(theme_manager)
|
||||||
|
window.show()
|
||||||
|
return app.exec()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
组装 EDID-Viewer 发布包: exe + README → 一个 zip(解压即用)
|
||||||
|
================================================
|
||||||
|
把主 README 复制进 release/ 后, 与单文件 exe 一起压成 zip —— 两者内容一致。
|
||||||
|
|
||||||
|
zip 解压后根目录为 EDID-Viewer/:
|
||||||
|
EDID-Viewer.exe 主程序(先运行 build_exe.py 打包)
|
||||||
|
README.md 使用说明
|
||||||
|
|
||||||
|
用法:
|
||||||
|
python package_release.py 版本号自动取最近 git tag(EDID-Viewer-v*)
|
||||||
|
python package_release.py 0.1.0 手动指定版本号
|
||||||
|
产物: release/EDID-Viewer-v<版本>-win64.zip(zip 不入库, 上传到 Gitea Release)
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
SRC = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
BASE = os.path.dirname(SRC)
|
||||||
|
RELEASE = os.path.join(BASE, 'release')
|
||||||
|
|
||||||
|
|
||||||
|
def detect_version():
|
||||||
|
"""从最近的 EDID-Viewer-v* tag 推断版本号, 无 tag 则报错提示手动指定"""
|
||||||
|
try:
|
||||||
|
out = subprocess.check_output(
|
||||||
|
['git', 'describe', '--tags', '--abbrev=0', '--match', 'EDID-Viewer-v*'],
|
||||||
|
cwd=BASE, stderr=subprocess.DEVNULL)
|
||||||
|
return out.decode().strip().removeprefix('EDID-Viewer-v')
|
||||||
|
except Exception:
|
||||||
|
sys.exit('未能从 git tag 推断版本号, 请手动指定: python package_release.py <版本号>')
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
version = (sys.argv[1] if len(sys.argv) > 1 else detect_version()).lstrip('v')
|
||||||
|
exe = os.path.join(RELEASE, 'EDID-Viewer.exe')
|
||||||
|
readme = os.path.join(BASE, 'README.md')
|
||||||
|
if not os.path.exists(exe):
|
||||||
|
sys.exit('缺少 release/EDID-Viewer.exe, 先运行: python build_exe.py')
|
||||||
|
if not os.path.exists(readme):
|
||||||
|
sys.exit(f'缺少 {readme}')
|
||||||
|
|
||||||
|
shutil.copy2(readme, os.path.join(RELEASE, 'README.md'))
|
||||||
|
zip_name = f'EDID-Viewer-v{version}-win64.zip'
|
||||||
|
zip_path = os.path.join(RELEASE, zip_name)
|
||||||
|
with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as z:
|
||||||
|
z.write(exe, f'EDID-Viewer/{os.path.basename(exe)}')
|
||||||
|
z.write(os.path.join(RELEASE, 'README.md'), 'EDID-Viewer/README.md')
|
||||||
|
print(f'发布文件夹: {RELEASE} (exe + README)')
|
||||||
|
print(f'发布包: {zip_path} ({os.path.getsize(zip_path) / 1024 / 1024:.1f} MB)')
|
||||||
|
print('下一步上传: python publish_gitea.py', zip_name)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
创建/更新 Gitea Release 并上传发布 zip(纯标准库, 无需安装依赖)
|
||||||
|
================================================================
|
||||||
|
用法:
|
||||||
|
python publish_gitea.py EDID-Viewer-v0.1.0-win64.zip
|
||||||
|
python publish_gitea.py <zip> --notes-file release/notes-v0.1.0.md
|
||||||
|
python publish_gitea.py <zip> --tag EDID-Viewer-v0.1.0 --replace
|
||||||
|
|
||||||
|
行为:
|
||||||
|
- tag 与版本默认取 zip 文件名(EDID-Viewer-vX.Y.Z-win64.zip → EDID-Viewer-vX.Y.Z)
|
||||||
|
- release 不存在则创建(tag 不存在时 Gitea 在默认分支头自动建 tag);
|
||||||
|
已存在则复用, 仅上传/更新资产
|
||||||
|
- release 上已有同名资产时: 默认跳过, --replace 删旧再传
|
||||||
|
- API token: --token 参数或环境变量 GITEA_TOKEN(需该仓库写权限)
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import ssl
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import urllib.error
|
||||||
|
import urllib.request
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
DEFAULT_NOTES = """## EDID-Viewer {version}
|
||||||
|
|
||||||
|
Windows 显示器 EDID 查看器(LT8619C 调试工具集配套): 只读查看活动显示设备
|
||||||
|
或离线文件的 EDID —— 厂家/序列号/分辨率时序、CTA/HDMI/音频/HDR 能力、
|
||||||
|
校验诊断, 支持 BIN/HEX 导入与 BIN/JSON 报告导出。
|
||||||
|
|
||||||
|
### 安装
|
||||||
|
下载 `EDID-Viewer-v{version}-win64.zip`, 解压后双击 `EDID-Viewer.exe`(Windows 10/11 x64, 免安装)。
|
||||||
|
|
||||||
|
### 包内容
|
||||||
|
- `EDID-Viewer.exe` — 主程序
|
||||||
|
- `README.md` — 完整使用说明
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def git_remote_info():
|
||||||
|
"""从 origin 远程地址解析 API base 与 owner/repo(ssh 端口不影响 https API)"""
|
||||||
|
url = subprocess.check_output(['git', 'remote', 'get-url', 'origin']).decode().strip()
|
||||||
|
m = re.match(r'(?:ssh://git@|git@)([\w.-]+)(?::\d+)?[:/]([\w.-]+)/([\w.-]+?)(?:\.git)?$', url)
|
||||||
|
if not m:
|
||||||
|
sys.exit(f'无法从 origin 解析 Gitea 地址: {url}')
|
||||||
|
host, owner, repo = m.groups()
|
||||||
|
return f'https://{host}', owner, repo
|
||||||
|
|
||||||
|
|
||||||
|
class Api:
|
||||||
|
def __init__(self, base, owner, repo, token, insecure):
|
||||||
|
self.api = f'{base}/api/v1/repos/{owner}/{repo}'
|
||||||
|
self.headers = {'Authorization': f'token {token}'}
|
||||||
|
self.ctx = ssl._create_unverified_context() if insecure else None
|
||||||
|
|
||||||
|
def request(self, method, path, data=None, headers=None, retries=4):
|
||||||
|
"""发请求; 实例 TLS 间歇性抽风(SSL UNEXPECTED_EOF), 连接级错误自动重试"""
|
||||||
|
last = None
|
||||||
|
for attempt in range(retries):
|
||||||
|
req = urllib.request.Request(self.api + path, data=data, method=method,
|
||||||
|
headers={**self.headers, **(headers or {})})
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(req, context=self.ctx) as resp:
|
||||||
|
body = resp.read()
|
||||||
|
return resp.status, json.loads(body) if body else None
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
return e.code, json.loads(e.read() or b'{}')
|
||||||
|
except (urllib.error.URLError, ssl.SSLError, OSError) as e:
|
||||||
|
last = e
|
||||||
|
time.sleep(1.0 + attempt)
|
||||||
|
raise RuntimeError(f'Gitea 请求连续 {retries} 次失败: {last}')
|
||||||
|
|
||||||
|
def get_json(self, path):
|
||||||
|
status, data = self.request('GET', path)
|
||||||
|
return data if status == 200 else None
|
||||||
|
|
||||||
|
def upload_asset(self, release_id, filepath, replace):
|
||||||
|
name = os.path.basename(filepath)
|
||||||
|
status, rel = self.request('GET', f'/releases/{release_id}')
|
||||||
|
if status != 200:
|
||||||
|
sys.exit(f'读取 release {release_id} 失败: {status} {rel}')
|
||||||
|
# Gitea 版本差异: assets 可能是 {items:[...]} 或纯数组
|
||||||
|
assets = rel.get('assets') or []
|
||||||
|
if isinstance(assets, dict):
|
||||||
|
assets = assets.get('items', [])
|
||||||
|
for asset in assets:
|
||||||
|
if asset['name'] == name:
|
||||||
|
if not replace:
|
||||||
|
print(f'资产 {name} 已存在, 跳过(覆盖请加 --replace)')
|
||||||
|
return
|
||||||
|
self.request('DELETE', f"/releases/{release_id}/assets/{asset['id']}")
|
||||||
|
print(f'已删除旧资产 {name}')
|
||||||
|
boundary = uuid.uuid4().hex
|
||||||
|
payload = open(filepath, 'rb').read()
|
||||||
|
body = (f'--{boundary}\r\n'
|
||||||
|
f'Content-Disposition: form-data; name="attachment"; filename="{name}"\r\n'
|
||||||
|
f'Content-Type: application/octet-stream\r\n\r\n').encode() + payload + \
|
||||||
|
f'\r\n--{boundary}--\r\n'.encode()
|
||||||
|
status, data = self.request(
|
||||||
|
'POST', f'/releases/{release_id}/assets?name={name}', body,
|
||||||
|
{'Content-Type': f'multipart/form-data; boundary={boundary}'})
|
||||||
|
if status != 201:
|
||||||
|
sys.exit(f'上传资产失败: {status} {data}')
|
||||||
|
print(f'已上传资产: {name} ({len(payload) / 1024 / 1024:.1f} MB)')
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
ap = argparse.ArgumentParser()
|
||||||
|
ap.add_argument('zipfile_path', help='发布 zip(release/ 下)')
|
||||||
|
ap.add_argument('--tag', help='release 标签, 默认取 zip 文件名去掉 -win64.zip')
|
||||||
|
ap.add_argument('--notes-file', help='release 说明 markdown 文件, 默认用内置模板')
|
||||||
|
ap.add_argument('--token', default=os.environ.get('GITEA_TOKEN'), help='API token')
|
||||||
|
ap.add_argument('--replace', action='store_true', help='覆盖已存在的同名资产')
|
||||||
|
ap.add_argument('--insecure', action='store_true', help='跳过 TLS 证书校验(自签证书)')
|
||||||
|
args = ap.parse_args()
|
||||||
|
|
||||||
|
if not os.path.exists(args.zipfile_path):
|
||||||
|
sys.exit(f'找不到 {args.zipfile_path}')
|
||||||
|
if not args.token:
|
||||||
|
sys.exit('缺少 API token: 传 --token 或设环境变量 GITEA_TOKEN')
|
||||||
|
|
||||||
|
tag = args.tag or re.sub(r'-win64\.zip$', '', os.path.basename(args.zipfile_path))
|
||||||
|
version = tag.removeprefix('EDID-Viewer-v')
|
||||||
|
notes = open(args.notes_file, encoding='utf-8').read() if args.notes_file \
|
||||||
|
else DEFAULT_NOTES.format(version=version)
|
||||||
|
|
||||||
|
base, owner, repo = git_remote_info()
|
||||||
|
api = Api(base, owner, repo, args.token, args.insecure)
|
||||||
|
print(f'目标: {base}/{owner}/{repo} tag={tag}')
|
||||||
|
|
||||||
|
rel = api.get_json(f'/releases/tags/{tag}')
|
||||||
|
if rel:
|
||||||
|
print(f'release 已存在(id={rel["id"]}), 复用')
|
||||||
|
else:
|
||||||
|
status, rel = api.request('POST', '/releases', json.dumps({
|
||||||
|
'tag_name': tag,
|
||||||
|
'name': f'EDID-Viewer v{version}',
|
||||||
|
'body': notes,
|
||||||
|
}).encode(), {'Content-Type': 'application/json'})
|
||||||
|
if status != 201:
|
||||||
|
sys.exit(f'创建 release 失败: {status} {rel}')
|
||||||
|
print(f'release 已创建(id={rel["id"]})')
|
||||||
|
api.upload_asset(rel['id'], args.zipfile_path, args.replace)
|
||||||
|
print(f'完成: {rel.get("html_url", "") or f"{base}/{owner}/{repo}/releases/tag/{tag}"}')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import random
|
||||||
|
import unittest
|
||||||
|
from edid import parse,dtd
|
||||||
|
|
||||||
|
def checksum(b):
|
||||||
|
b[127]=(-sum(b[:127]))&255
|
||||||
|
return bytes(b)
|
||||||
|
|
||||||
|
def base(ext=0):
|
||||||
|
b=bytearray(128); b[:8]=bytes.fromhex('00ffffffffffff00'); b[8:10]=bytes.fromhex('4c2d')
|
||||||
|
b[18:20]=bytes((1,4)); b[20]=0xa2; b[38:54]=b'\x01\x01'*8; b[126]=ext
|
||||||
|
b[54:72]=bytes.fromhex('023a801871382d40582c4500fd1e1100001e')
|
||||||
|
b[72:90]=b'\0\0\0\xfc\0TEST PANEL\n '
|
||||||
|
return bytearray(checksum(b))
|
||||||
|
|
||||||
|
class Tests(unittest.TestCase):
|
||||||
|
def test_identity_and_dtd(self):
|
||||||
|
r=parse(base()); self.assertEqual(r['基本信息']['显示器名称'],'TEST PANEL')
|
||||||
|
self.assertEqual(r['基本信息']['厂家 PNP 代码'],'SAM')
|
||||||
|
t=r['时序'][0]; self.assertEqual(t['分辨率'],'1920×1080p'); self.assertEqual(t['刷新率'],'60.000 Hz')
|
||||||
|
self.assertEqual(t['同步'],'H+ V+'); self.assertEqual(t['水平有效/前肩/同步/后肩'],[1920,88,44,148])
|
||||||
|
def test_standard(self):
|
||||||
|
b=base(); b[38:40]=bytes((129,192)); r=parse(checksum(b))
|
||||||
|
self.assertEqual(r['时序'][0]['分辨率'],'1280×720'); self.assertEqual(r['时序'][0]['刷新率'],'60 Hz')
|
||||||
|
def test_cta(self):
|
||||||
|
b=bytearray(128); payload=bytes.fromhex('429061 23090707 67030c0012343078 e3060c01')
|
||||||
|
b[:4]=bytes((2,3,4+len(payload),0x70)); b[4:4+len(payload)]=payload
|
||||||
|
r=parse(bytes(base(1))+checksum(b)); text=str(r)
|
||||||
|
self.assertIn('1.2.3.4',text); self.assertIn('PQ / ST 2084',text); self.assertIn('3840×2160p 60 Hz',text)
|
||||||
|
self.assertIn('600 MHz',text); self.assertIn('LPCM',text)
|
||||||
|
def test_missing_extension(self):
|
||||||
|
self.assertTrue(parse(base(2))['警告'])
|
||||||
|
def test_bad_checksum_and_header(self):
|
||||||
|
b=base(); b[0]=1; r=parse(b); self.assertTrue(r['警告']); self.assertIn('失败',r['校验'][0])
|
||||||
|
def test_bounds(self):
|
||||||
|
with self.assertRaises(ValueError): parse(b'\0'*127)
|
||||||
|
b=bytearray(128); b[:5]=bytes((2,3,6,0,0x5f))
|
||||||
|
self.assertIn('越界',str(parse(bytes(base(1))+checksum(b))['警告']))
|
||||||
|
def test_unknown_extension(self):
|
||||||
|
b=bytearray(128); b[0]=0x70
|
||||||
|
self.assertIn('暂未解码',str(parse(bytes(base(1))+checksum(b))))
|
||||||
|
def test_interlaced(self):
|
||||||
|
b=bytes.fromhex('011d8018711c1620582c2500fd1e1100009e')
|
||||||
|
t=dtd(b,'test'); self.assertEqual(t['分辨率'],'1920×1080i'); self.assertEqual(t['刷新率'],'60.000 Hz(场率)')
|
||||||
|
def test_random_malformed(self):
|
||||||
|
rng=random.Random(42)
|
||||||
|
for _ in range(1000):
|
||||||
|
b=bytearray(rng.randbytes(rng.randint(128,600))); b[18]=1; parse(b)
|
||||||
|
|
||||||
|
if __name__=='__main__': unittest.main()
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
"""Theme persistence and Fluent Widgets integration."""
|
||||||
|
|
||||||
|
import ctypes
|
||||||
|
import os
|
||||||
|
|
||||||
|
from PySide6.QtCore import QObject, QSettings, Qt
|
||||||
|
from PySide6.QtGui import QColor, QPalette
|
||||||
|
from qfluentwidgets import Theme, setTheme, setThemeColor
|
||||||
|
|
||||||
|
# Fluent widgets restyle themselves on setTheme(); QMainWindow, the native
|
||||||
|
# QTabWidget/QStatusBar and the Windows title bar keep the OS palette unless
|
||||||
|
# the palette, an app stylesheet and the DWM title bar attributes follow suit
|
||||||
|
# (same approach as DLPilot app_fluent.py).
|
||||||
|
_SURFACES = {
|
||||||
|
False: {"window": "#f4f6f8", "base": "#ffffff", "text": "#1f2328",
|
||||||
|
"dim": "#57606a", "border": "#d8dee4", "selected_text": "#ffffff"},
|
||||||
|
True: {"window": "#202020", "base": "#2b2b2b", "text": "#f5f5f5",
|
||||||
|
"dim": "#9a9a9a", "border": "#3a3a3a", "selected_text": "#1f2328"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ThemeManager(QObject):
|
||||||
|
"""Keep the appearance choice persistent and synchronized with Qt."""
|
||||||
|
|
||||||
|
MODES = {"system", "light", "dark", "dark1", "dark2"}
|
||||||
|
_THEMES = {
|
||||||
|
"system": Theme.AUTO,
|
||||||
|
"light": Theme.LIGHT,
|
||||||
|
"dark": Theme.DARK,
|
||||||
|
"dark1": Theme.DARK,
|
||||||
|
"dark2": Theme.DARK,
|
||||||
|
}
|
||||||
|
_ACCENTS = {
|
||||||
|
"light": "#0f6cbd",
|
||||||
|
"dark": "#f2c94c",
|
||||||
|
"dark1": "#5aa9e6",
|
||||||
|
"dark2": "#35c6c8",
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, app):
|
||||||
|
super().__init__(app)
|
||||||
|
self.app = app
|
||||||
|
self.window = None
|
||||||
|
self.settings = QSettings("LT8619C-Tools", "EDID-Viewer")
|
||||||
|
mode = self.settings.value("appearance/theme", "system")
|
||||||
|
self.mode = mode if mode in self.MODES else "system"
|
||||||
|
self.apply()
|
||||||
|
app.styleHints().colorSchemeChanged.connect(self.apply)
|
||||||
|
|
||||||
|
def set_window(self, window):
|
||||||
|
"""Register the main window so the native title bar follows the theme."""
|
||||||
|
self.window = window
|
||||||
|
self._apply_titlebar()
|
||||||
|
|
||||||
|
def set_mode(self, mode):
|
||||||
|
if mode not in self.MODES:
|
||||||
|
raise ValueError(f"Unknown theme: {mode}")
|
||||||
|
self.mode = mode
|
||||||
|
self.settings.setValue("appearance/theme", mode)
|
||||||
|
self.apply()
|
||||||
|
|
||||||
|
def is_dark(self):
|
||||||
|
if self.mode in {"dark", "dark1", "dark2"}:
|
||||||
|
return True
|
||||||
|
return self.mode == "system" and self.app.styleHints().colorScheme() == Qt.ColorScheme.Dark
|
||||||
|
|
||||||
|
def apply(self, *_):
|
||||||
|
is_dark = self.is_dark()
|
||||||
|
setTheme(self._THEMES[self.mode])
|
||||||
|
setThemeColor(self._ACCENTS.get(self.mode, self._ACCENTS["light"]))
|
||||||
|
self._apply_palette(is_dark)
|
||||||
|
self._apply_titlebar()
|
||||||
|
|
||||||
|
def _apply_palette(self, is_dark):
|
||||||
|
"""Give native Qt surfaces the same colors as the Fluent widgets."""
|
||||||
|
surface = _SURFACES[is_dark]
|
||||||
|
accent = QColor(self._ACCENTS.get(self.mode, self._ACCENTS["light"]))
|
||||||
|
palette = QPalette()
|
||||||
|
for role, color in (
|
||||||
|
(QPalette.Window, surface["window"]),
|
||||||
|
(QPalette.Base, surface["base"]),
|
||||||
|
(QPalette.AlternateBase, surface["base"]),
|
||||||
|
(QPalette.Text, surface["text"]),
|
||||||
|
(QPalette.WindowText, surface["text"]),
|
||||||
|
(QPalette.Button, surface["base"]),
|
||||||
|
(QPalette.ButtonText, surface["text"]),
|
||||||
|
(QPalette.PlaceholderText, surface["dim"]),
|
||||||
|
(QPalette.Highlight, accent),
|
||||||
|
(QPalette.HighlightedText, surface["selected_text"]),
|
||||||
|
(QPalette.ToolTipBase, surface["base"]),
|
||||||
|
(QPalette.ToolTipText, surface["text"]),
|
||||||
|
):
|
||||||
|
palette.setColor(role, QColor(color))
|
||||||
|
self.app.setPalette(palette)
|
||||||
|
self.app.setStyleSheet(f"""
|
||||||
|
QMainWindow, QWidget#root {{ background-color: {surface['window']}; color: {surface['text']}; }}
|
||||||
|
QTabWidget::pane {{ background: {surface['base']}; border: 1px solid {surface['border']}; border-radius: 6px; }}
|
||||||
|
QTabBar {{ qproperty-drawBase: 0; }}
|
||||||
|
QTabBar::tab {{ background: transparent; color: {surface['dim']}; padding: 6px 16px;
|
||||||
|
border: 1px solid transparent; border-top-left-radius: 6px;
|
||||||
|
border-top-right-radius: 6px; }}
|
||||||
|
QTabBar::tab:selected {{ background: {surface['base']}; color: {surface['text']};
|
||||||
|
border: 1px solid {surface['border']}; }}
|
||||||
|
QTabBar::tab:hover:!selected {{ background: {surface['base']}; }}
|
||||||
|
QSplitter::handle {{ background: {surface['window']}; }}
|
||||||
|
QStatusBar {{ background: {surface['window']}; color: {surface['dim']};
|
||||||
|
border-top: 1px solid {surface['border']}; }}
|
||||||
|
QToolTip {{ background-color: {surface['base']}; color: {surface['text']};
|
||||||
|
border: 1px solid {surface['border']}; }}
|
||||||
|
""")
|
||||||
|
|
||||||
|
def _apply_titlebar(self):
|
||||||
|
"""Ask DWM for a title bar in the current surface color (Win10/11)."""
|
||||||
|
if self.window is None or os.name != "nt" or not hasattr(ctypes, "windll"):
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
hwnd = int(self.window.winId())
|
||||||
|
dwm = ctypes.windll.dwmapi
|
||||||
|
dark = ctypes.c_int(1 if self.is_dark() else 0)
|
||||||
|
dwm.DwmSetWindowAttribute(hwnd, 20, ctypes.byref(dark), ctypes.sizeof(dark))
|
||||||
|
surface = _SURFACES[self.is_dark()]
|
||||||
|
dwm.DwmSetWindowAttribute(hwnd, 35, ctypes.byref(self._colorref(QColor(surface["window"]))), 4)
|
||||||
|
dwm.DwmSetWindowAttribute(hwnd, 36, ctypes.byref(self._colorref(QColor(surface["text"]))), 4)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _colorref(color):
|
||||||
|
return ctypes.c_int(color.red() | (color.green() << 8) | (color.blue() << 16))
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
"""Read active monitors through Windows WMI; never change display settings."""
|
||||||
|
import json
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
SCRIPT = r'''
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
|
||||||
|
$connections = @{}
|
||||||
|
try { Get-CimInstance -Namespace root/wmi -ClassName WmiMonitorConnectionParams | ForEach-Object { $connections[$_.InstanceName] = [long]$_.VideoOutputTechnology } } catch {}
|
||||||
|
$result = @(Get-CimInstance -Namespace root/wmi -ClassName WmiMonitorDescriptorMethods | Where-Object Active | ForEach-Object {
|
||||||
|
$m = $_
|
||||||
|
$bytes = [System.Collections.Generic.List[byte]]::new()
|
||||||
|
$failure = ''
|
||||||
|
try {
|
||||||
|
$base = Invoke-CimMethod -InputObject $m -MethodName WmiGetMonitorRawEEdidV1Block -Arguments @{BlockId=[byte]0}
|
||||||
|
if (-not $base.ReturnValue -or $base.BlockContent.Count -ne 128) { throw 'Base EDID read failed' }
|
||||||
|
$bytes.AddRange([byte[]]$base.BlockContent)
|
||||||
|
for ($i=1; $i -le [int]$base.BlockContent[126]; $i++) {
|
||||||
|
$ext = Invoke-CimMethod -InputObject $m -MethodName WmiGetMonitorRawEEdidV1Block -Arguments @{BlockId=[byte]$i}
|
||||||
|
if (-not $ext.ReturnValue -or $ext.BlockContent.Count -ne 128) { throw "Extension $i read failed" }
|
||||||
|
$bytes.AddRange([byte[]]$ext.BlockContent)
|
||||||
|
}
|
||||||
|
} catch { $failure = $_.Exception.Message }
|
||||||
|
[pscustomobject]@{instance=$m.InstanceName; connection=$connections[$m.InstanceName]; hex=([BitConverter]::ToString($bytes.ToArray())).Replace('-',''); error=$failure}
|
||||||
|
})
|
||||||
|
ConvertTo-Json -InputObject $result -Depth 4 -Compress
|
||||||
|
'''
|
||||||
|
|
||||||
|
CONNECTIONS = {0:'VGA',4:'DVI',5:'HDMI',6:'LVDS 内屏',10:'DisplayPort',11:'eDP 内屏',15:'Miracast',16:'间接有线显示',2147483648:'内部显示'}
|
||||||
|
|
||||||
|
def scan():
|
||||||
|
import base64
|
||||||
|
command = base64.b64encode(SCRIPT.encode('utf-16le')).decode('ascii')
|
||||||
|
proc = subprocess.run(['powershell.exe','-NoProfile','-NonInteractive','-EncodedCommand',command],
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=45,
|
||||||
|
creationflags=subprocess.CREATE_NO_WINDOW)
|
||||||
|
if proc.returncode:
|
||||||
|
raise RuntimeError(proc.stderr.decode('utf-8','replace').strip())
|
||||||
|
data = json.loads(proc.stdout.decode('utf-8-sig'))
|
||||||
|
for item in data:
|
||||||
|
item['raw'] = bytes.fromhex(item.pop('hex'))
|
||||||
|
item['连接'] = CONNECTIONS.get(item['connection'],f'未知 ({item["connection"]})')
|
||||||
|
return data
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
@echo off
|
||||||
|
cd /d "%~dp0"
|
||||||
|
start "" ".venv\Scripts\pythonw.exe" "src\main.py"
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
"""Headless check for the About button and dialog: saves header and dialog PNGs."""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from PySide6.QtCore import QTimer
|
||||||
|
from PySide6.QtGui import QFont
|
||||||
|
from PySide6.QtWidgets import QApplication, QMessageBox
|
||||||
|
|
||||||
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "src"))
|
||||||
|
import main as m
|
||||||
|
|
||||||
|
OUT = Path(__file__).resolve().parent
|
||||||
|
|
||||||
|
|
||||||
|
def snap_dialog():
|
||||||
|
boxes = [w for w in QApplication.topLevelWidgets() if isinstance(w, QMessageBox)]
|
||||||
|
if not boxes:
|
||||||
|
QTimer.singleShot(200, snap_dialog)
|
||||||
|
return
|
||||||
|
boxes[0].grab().save(str(OUT / "about-dialog.png"))
|
||||||
|
boxes[0].close()
|
||||||
|
|
||||||
|
|
||||||
|
def open_about(window):
|
||||||
|
QTimer.singleShot(600, lambda: snap_dialog())
|
||||||
|
window.show_about()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
app.setApplicationName(m.APP_NAME)
|
||||||
|
app.setFont(QFont("Microsoft YaHei UI", 10))
|
||||||
|
theme_manager = m.ThemeManager(app)
|
||||||
|
window = m.Window(theme_manager)
|
||||||
|
window.show()
|
||||||
|
|
||||||
|
def grab_header():
|
||||||
|
window.grab().save(str(OUT / "about-header.png"))
|
||||||
|
open_about(window)
|
||||||
|
|
||||||
|
QTimer.singleShot(1500, grab_header)
|
||||||
|
QTimer.singleShot(6000, app.quit)
|
||||||
|
sys.exit(app.exec())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
param(
|
||||||
|
[string]$ProcessName = "python",
|
||||||
|
[string]$OutPng = "$env:TEMP\edid-window.png"
|
||||||
|
)
|
||||||
|
Add-Type @"
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
public class Win32Cap {
|
||||||
|
[DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr h, out RECT r);
|
||||||
|
[DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr h);
|
||||||
|
public struct RECT { public int Left, Top, Right, Bottom; }
|
||||||
|
}
|
||||||
|
"@
|
||||||
|
Add-Type -AssemblyName System.Drawing
|
||||||
|
$proc = Get-Process -Name $ProcessName -ErrorAction Stop |
|
||||||
|
Where-Object { $_.MainWindowHandle -ne 0 -and $_.MainWindowTitle -like 'EDID*' } |
|
||||||
|
Select-Object -First 1
|
||||||
|
if (-not $proc) { throw "no EDID window found for process '$ProcessName'" }
|
||||||
|
$hwnd = $proc.MainWindowHandle
|
||||||
|
[Win32Cap]::SetForegroundWindow($hwnd) | Out-Null
|
||||||
|
Start-Sleep -Milliseconds 800
|
||||||
|
$r = New-Object Win32Cap+RECT
|
||||||
|
[Win32Cap]::GetWindowRect($hwnd, [ref]$r) | Out-Null
|
||||||
|
$w = $r.Right - $r.Left; $h2 = $r.Bottom - $r.Top
|
||||||
|
$bmp = New-Object System.Drawing.Bitmap($w, $h2)
|
||||||
|
$g = [System.Drawing.Graphics]::FromImage($bmp)
|
||||||
|
$g.CopyFromScreen($r.Left, $r.Top, 0, 0, (New-Object System.Drawing.Size($w, $h2)))
|
||||||
|
$bmp.Save($OutPng, [System.Drawing.Imaging.ImageFormat]::Png)
|
||||||
|
$g.Dispose(); $bmp.Dispose()
|
||||||
|
Write-Output "saved $OutPng ($w x $h2)"
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"instance": "DISPLAY\\SDC420B\\4&1387f127&0&UID8388688_0",
|
||||||
|
"connection": 2147483648,
|
||||||
|
"error": "常规故障 ",
|
||||||
|
"连接": "内部显示",
|
||||||
|
"基本信息": {
|
||||||
|
"厂家 PNP 代码": "SDC",
|
||||||
|
"产品编号": "0x420B",
|
||||||
|
"数字序列号": 0,
|
||||||
|
"EDID 版本": "1.4",
|
||||||
|
"生产日期": "2024 年 / 周未指定",
|
||||||
|
"尺寸": "34 × 22 cm",
|
||||||
|
"Gamma": 2.2,
|
||||||
|
"扩展块数": 2,
|
||||||
|
"SHA-256": "16f168eda782b8d49c3ef5cdf46cb894c353c6ef2570629707b72a0cdefb9584",
|
||||||
|
"输入类型": "数字",
|
||||||
|
"接口声明": "DisplayPort",
|
||||||
|
"色深 bpc": 10,
|
||||||
|
"频率范围原始值": "垂直 48–240 Hz;水平 177–177 kHz;最大像素时钟 1170 MHz",
|
||||||
|
"描述文本": "SDC",
|
||||||
|
"显示器名称": "ATNA60HU01-0"
|
||||||
|
},
|
||||||
|
"时序": [],
|
||||||
|
"能力": [
|
||||||
|
"色度坐标:Rx=0.6807, Ry=0.3184, Gx=0.2197, Gy=0.7246, Bx=0.1426, By=0.0391, Wx=0.3135, Wy=0.3291"
|
||||||
|
],
|
||||||
|
"数据块": [
|
||||||
|
{
|
||||||
|
"块": 1,
|
||||||
|
"类型": "DisplayID(暂未解码)",
|
||||||
|
"原始": "70 20 79 02 00 20 00 0c ba 41 59 0b 42 00 00 00 00 00 18 00 21 00 1d 74 0d 69 08 00 0a 40 06 00 e5 7a 51 85 a3 b9 4a 02 0a 02 45 54 d0 5f 4c 64 00 45 23 78 26 00 09 06 00 00 00 00 00 50 00 00 22 00 28 80 c5 11 85 ff 09 87 00 07 00 1f 00 3f 06 c7 00 7f 00 07 00 80 c5 11 05 ff 09 87 00 07 00 1f 00 3f 06 df 15 97 15 07 00 81 00 0b e3 05 80 00 e6 06 05 01 8f 6a 02 00 00 00 00 00 f1 90"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"校验": [
|
||||||
|
"块 0: 通过",
|
||||||
|
"块 1: 通过"
|
||||||
|
],
|
||||||
|
"警告": [
|
||||||
|
"声明 384 字节,实际 256 字节",
|
||||||
|
"范围描述符有扩展偏移,频率范围显示原始字段,暂未应用偏移"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x4C, 0x2D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3A, 0x80, 0x18, 0x71, 0x38, 0x2D, 0x40, 0x58, 0x2C, 0x45, 0x00, 0xFD, 0x1E, 0x11, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x54, 0x45, 0x53, 0x54, 0x20, 0x50, 0x41, 0x4E, 0x45, 0x4C, 0x0A, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC2, 0x02, 0x03, 0x17, 0x70, 0x42, 0x90, 0x61, 0x23, 0x09, 0x07, 0x07, 0x67, 0x03, 0x0C, 0x00, 0x12, 0x34, 0x30, 0x78, 0xE3, 0x06, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAD
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
# AGENTS.md — DLPilot 工程档案(供 AI/Agent 使用)
|
|
||||||
|
|
||||||
> **本文档面向 AI/Agent**,是人类文档 [README.md](README.md) 的姊妹篇,两者不重叠:
|
|
||||||
> README 回答"这是什么、怎么用";本文回答"代码怎么组织、怎么构建发布、改动时哪些约束不能破坏"。
|
|
||||||
> 任何 Agent 在修改本目录代码前应先读完本文。
|
|
||||||
|
|
||||||
## 1. 项目定位
|
|
||||||
|
|
||||||
仓库 `LT8619C_Debug_Tools` 是 LT8619C(HDMI→RGB888)→ DLPC3421 投影转接板的**调试上位机工具集**,
|
|
||||||
上游主仓库(固件)为 `hulk/LT8619C_DLPC3421_HDMI`(同 Gitea 实例 `gitea.hulk.wang`),
|
|
||||||
本仓库本机路径 `E:\Hulk-Coding\LT8619C_DLPC3421_HDMI`。
|
|
||||||
DLPilot 工作在两端:HDMI **源端**(PC 显卡侧,EDID/分辨率/图案)与**光机控制端**
|
|
||||||
(RS485 → 板载 GD32E230 网关 → DLPC3421)。寄存器语义判读基线(0x606E 位交换 /
|
|
||||||
0x606D 整组顺序)与光机协议规程都在上游仓库 `doc/architecture/` 与 `protocols.md`,不在本仓库。
|
|
||||||
|
|
||||||
## 2. 目录契约(重要)
|
|
||||||
|
|
||||||
```
|
|
||||||
DLPilot/
|
|
||||||
├── src/ 源代码区 —— 只有这里可以手改(logos/ 改图标源后重跑 make_ico.py)
|
|
||||||
├── assets/ 生成资产区 —— gen_*.py 的产物(PNG 图案),可随时再生成,改动需提交
|
|
||||||
├── release/ 产物区 —— 机器生成,禁止手改:DLPilot.exe、pattern_slots.json、
|
|
||||||
│ bw/solid 图案(package_release.py 从 assets/ 平铺复制来,均入库)、
|
|
||||||
│ *.zip(gitignore,只上传 Release)。release/ 本身=完整可直接运行的
|
|
||||||
│ 发布文件夹(exe+附属平铺),内容与 zip 一致
|
|
||||||
├── README.md 人类文档
|
|
||||||
└── AGENTS.md 本文
|
|
||||||
```
|
|
||||||
|
|
||||||
划分原则:**"人写的"在 src/,"生成的"按去向分 assets/(随包分发)与 release/(直接交付)**。
|
|
||||||
新文件必须落对区域;不要在 src/ 外新建源码,不要手改 assets/ 下的 PNG(改生成脚本再跑)。
|
|
||||||
|
|
||||||
### 文件角色速查
|
|
||||||
|
|
||||||
| 文件 | 角色 |
|
|
||||||
|---|---|
|
|
||||||
| `src/hdmi_gui.py` | 入口: argparse 命令行分发(--dump/--edid-fields/--test-pattern/--dlpc-cmd/--seconds), GUI 委托 app_gui |
|
|
||||||
| `src/app_gui.py` | CustomTkinter 主界面: 双栏仪表盘(左 HDMI 源端五卡/右 光机四卡), 光强/定时快捷滑条 |
|
|
||||||
| `src/display_win.py` | Win32 显示器枚举/分辨率切换/智能拓扑(纯 ctypes) |
|
|
||||||
| `src/edid_parse.py` | EDID 1.4/CEA-861 解析(纯标准库, 上游 lt8619c_edid.c 以此为参考解码器) |
|
|
||||||
| `src/patterns.py` | 测试图案全屏投屏窗口(tkinter, ESC 退出, 测试卡区域 1:1 居中) |
|
|
||||||
| `src/config.py` | 运行目录定位(BASE_DIR)与 pattern_slots.json 读写(slots/area/serial 三键) |
|
|
||||||
| `src/dlpc_rs485.py` | 光机 RS485 协议模块: 帧构造/增量解析/译码表/预设命令/串口线程(DLPC485) |
|
|
||||||
| `src/selftest_rs485.py` | 光机协议自检(对照上游实测帧向量, 无硬件回归, 改协议代码后必跑) |
|
|
||||||
| `src/build_exe.py` | PyInstaller 打包 → `release/DLPilot.exe`(onefile/noconsole, 内嵌图标+pyserial+customtkinter) |
|
|
||||||
| `src/package_release.py` | 复制图案到 release/(平铺) → `release/DLPilot-v<ver>-win64.zip`(校验栏位引用完整性; release/ 与 zip 内容一致) |
|
|
||||||
| `src/publish_gitea.py` | 建/复用 Gitea Release 并上传 zip(tag 默认取 zip 文件名) |
|
|
||||||
| `src/hdmi_source.ps1/.bat` | 独立 PowerShell 命令行工具(自包含,与 GUI 无代码共享) |
|
|
||||||
| `src/gen_bw_patterns.py` | 生成 `assets/bw_*.png` ×5(640x360 黑白,需 Pillow) |
|
|
||||||
| `src/gen_solid_colors.py` | 生成 `assets/solid_*.png` ×10(800x600 纯色,需 Pillow) |
|
|
||||||
| `src/la_wave_analyzer*.py` | 逻辑分析仪 CSV 波形判读(2/3 通道,40MHz 像素时钟假设) |
|
|
||||||
| `src/logos/make_ico.py` | svg/png → ico(写在其自身目录) |
|
|
||||||
| `release/pattern_slots.json` | 预置栏位:西门子星/波带片/综合测试卡,area=640x360;`serial` 键记忆光机串口 |
|
|
||||||
| `UI参考布局.svg/.png` | 界面布局设计稿(app_gui.py 双栏布局的规格来源, 随分支入库) |
|
|
||||||
|
|
||||||
## 3. 代码不变量(改 hdmi_gui.py 必须维持)
|
|
||||||
|
|
||||||
1. **依赖分层**:CLI/显示/EDID/协议/配置模块(display_win/edid_parse/patterns/config/
|
|
||||||
dlpc_rs485)纯标准库;customtkinter 是 GUI(app_gui)的**硬依赖**(装了才能开界面,
|
|
||||||
CLI 不受影响)。可选依赖仍走"try-import + HAS_* 标志 + 缺失降级"模式:Pillow、
|
|
||||||
pyserial——缺失时对应功能禁用/提示安装,其余功能必须照常工作。
|
|
||||||
2. **模块边界**:hdmi_gui.py 只是入口, 不放实现; GUI 不直接碰 ctypes/winreg
|
|
||||||
(显示器走 display_win, EDID 走 edid_parse); pyserial 只准在 dlpc_rs485.py 里 import
|
|
||||||
(hdmi_gui/app_gui 经 `dlpc_rs485.HAS_SERIAL` 与 `DLPC485` 类间接使用)。
|
|
||||||
3. **BASE_DIR 语义**(定义在 config.py):frozen(PyInstaller onefile)时
|
|
||||||
`BASE_DIR=exe 所在目录`(`sys.executable`),源码运行时 `=config.py 所在目录`
|
|
||||||
(即 src/)。所有用户数据(pattern_slots.json、自定义图片)都写/读自 BASE_DIR
|
|
||||||
**平铺**存放,不建子目录。
|
|
||||||
4. **自定义栏位 `file` 字段是裸文件名**:加载时 `os.path.join(BASE_DIR, file)` 解析,
|
|
||||||
因此 pattern_slots.json 引用的图片必须与 exe 同目录 —— package_release.py 正是按此平铺打包。
|
|
||||||
5. **exe 自包含**:图标经 `--add-data` 内嵌(运行时从 `_MEIPASS` 读);内置五种图案
|
|
||||||
(红/绿/蓝/棋盘格/网格线)由程序绘制,运行时**不依赖** assets/;solid/bw PNG 只服务自定义栏位。
|
|
||||||
6. **DPI 感知**:进程启动即 `SetProcessDpiAwareness(2)`,图案窗口按物理像素定位,勿移除。
|
|
||||||
7. **智能显示拓扑(勿改回无条件扩展)**:启动时枚举"接入但不在桌面"的显示器,仅当其
|
|
||||||
EDID 厂商字节为转接板签名 `61 93`(压缩码 "XLS",上游 lt8619c_edid.c)时才
|
|
||||||
`SetDisplayConfig(SDC_TOPOLOGY_EXTEND|SDC_APPLY)` 拉回桌面,静默容错。动机:板卡
|
|
||||||
热插拔后 Windows 可能停留在"仅电脑屏幕"导致枚举不到板卡。用户主动选择的拓扑
|
|
||||||
(家里的"仅第二屏幕"等,未激活的是笔记本内屏,厂商非 XLS)一律不动。
|
|
||||||
8. **分辨率切换是临时的**:走 `CHANGEDISPLAYSETTINGS`(不写注册表),"恢复"用会话开始时快照。
|
|
||||||
9. **EDID 来源是注册表**(`HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\...\Device Parameters\EDID`),
|
|
||||||
不是 WMI/DDC;exe 的 noconsole 版无 stdout,`--dump/--edid-fields` 只在源码/控制台版可用。
|
|
||||||
10. **光机串口线程回调不直接碰 GUI**:DLPC485 的 on_event/on_status 在后台线程触发,
|
|
||||||
必须经 `queue.Queue` + `root.after(80, …)` 轮询投递回主线程(现行 `_poll_dlpc` 模式,
|
|
||||||
与 I2C-Inject 的 Injector 同源);退出路径(关窗与 `--seconds` 自动关)都会走到
|
|
||||||
`App.destroy()`,在那里 `dlpc.close()` 收线程。
|
|
||||||
11. **pattern_slots.json 格式**:`{'area', 'slots', 'serial'}` 三键共存;load 兼容旧版
|
|
||||||
纯数组(无 area)与无 serial 键两种历史格式,save 永远写全三键。`serial` 子键为
|
|
||||||
`{port, baud, bytesize(8/7/6/5), parity(N/E/O), stopbits(1/2)}`,旧配置缺子键按
|
|
||||||
默认 8-N-1 补齐。
|
|
||||||
12. **GUI = app_gui.py 双栏仪表盘**(规格:`DLPilot/UI参考布局.svg`):左列 HDMI 源端
|
|
||||||
五卡(显示器/模式/EDID 信息/测试图案/hex),右列光机四卡(串口/数据/命令/滑条),
|
|
||||||
顶栏 Dark/Light/System 切换(ttk.Treeview 颜色随动)。打包必须 `--collect-all
|
|
||||||
customtkinter`(build_exe.py 已内置,勿删)——CTk 主题/字体数据缺失会让 exe 启动即崩。
|
|
||||||
|
|
||||||
## 4. 领域语义(测试值都有含义,勿"顺手改")
|
|
||||||
|
|
||||||
- 纯色值 55/AA/FF:55(01010101) 与 AA(10101010) 互为字节镜像对(检出位序颠倒/位交换),
|
|
||||||
FF(11111111) 全高基准;R/G/B 三行对应 RGB888 三字节组(R=D[23:16]/G=D[15:8]/B=D[7:0])。
|
|
||||||
- 800x600@60:LT8619C **demo 板** shadow EDID 首选时序(solid 系列分辨率与之一致)。
|
|
||||||
- 640x360:测试卡区域默认值(16:9 半分辨率,点对点检查用);full=铺满所选屏。
|
|
||||||
**同时是转接板光机 DLPC3421 的 nHD 面板原生分辨率**(该板 shadow EDID 只声明 640x360@60),
|
|
||||||
投 640x360 图案 + RS485 开光机 = 整链路 1:1 验证。
|
|
||||||
- bw 系列图案各自目的见 `src/gen_bw_patterns.py` 顶部清单注释。
|
|
||||||
- 光机 RS485 命令集(M730/M731/M732/M201/M202/M737/M999/M888/M7/M8/M1)语义、
|
|
||||||
帧格式 `D5 01 LEN <ASCII> CRC`(累加和校验)、错误码与**就绪门禁**
|
|
||||||
(DLPC 未就绪时 M730/M731/M732 被拒回 0xFF)以上游 `protocols.md` 为唯一权威,
|
|
||||||
本仓不维护协议文档副本;注意 **M7S0 是"开启"TEC 自动控温**(方向反直觉)、
|
|
||||||
M737 在定时投光中延迟应答(CLI 等待上限 35s)。
|
|
||||||
|
|
||||||
## 5. 构建 / 发布流水线(全部在 src/ 下执行)
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
python gen_bw_patterns.py ; python gen_solid_colors.py # 仅当改了图案生成逻辑
|
|
||||||
python build_exe.py # → ../release/DLPilot.exe(缺 PyInstaller 会自动 pip install)
|
|
||||||
python build_exe.py --debug # 附加带控制台的 DLPilot-console.exe(调试 --dump 用)
|
|
||||||
python package_release.py <版本> # → ../release/DLPilot-v<版本>-win64.zip
|
|
||||||
python publish_gitea.py DLPilot-v<版本>-win64.zip --replace --insecure # 上传(需 GITEA_TOKEN)
|
|
||||||
```
|
|
||||||
|
|
||||||
发布约定:
|
|
||||||
- tag/release 命名 `DLPilot-vX.Y.Z`,zip 命名 `DLPilot-vX.Y.Z-win64.zip`(publish_gitea.py
|
|
||||||
依赖此命名从文件名推 tag);
|
|
||||||
- **exe、pattern_slots.json 与 release/ 下平铺的图案 png 改动跟随源码/资产生成提交入库;
|
|
||||||
zip 永不入库**(.gitignore 已挡);
|
|
||||||
- publish_gitea.py 幂等:release 已存在则复用,同名资产默认跳过,`--replace` 删旧重传;
|
|
||||||
- token 读环境变量 `GITEA_TOKEN`:本机已用 setx 持久化为用户级变量(新开的会话/终端自动
|
|
||||||
继承,值不入库;在 setx 之前启动的进程读不到,需重开终端),急用时也可临时传 `--token`;
|
|
||||||
- Gitea 实例 `gitea.hulk.wang`,API 走 https(443),git 走 ssh(1234)——从 origin 远程自动解析;
|
|
||||||
python urllib 连该实例会在部分请求上报 `SSL: UNEXPECTED_EOF`,**实际发布需加 `--insecure`**;
|
|
||||||
- 本实例 Gitea 的 API 兼容性怪癖:`GET /releases/tags/{tag}` 返回的 `assets` 是纯数组,
|
|
||||||
而 `GET /releases/{id}` 是 `{items:[...]}` —— publish_gitea.py 已按两种形状兼容,勿"简化"回去。
|
|
||||||
|
|
||||||
## 6. 已知坑(历史踩过,勿重蹈)
|
|
||||||
|
|
||||||
- onefile 运行时 `__file__` 指向临时解压目录 `_MEIPASS`,定位 exe 必须用 `sys.executable`(§3.3);
|
|
||||||
- 重新打包前旧 exe 可能被残留进程占用 → build_exe.py 会 taskkill 同名进程,手改打包脚本时保留;
|
|
||||||
- 打包后本机图标缓存不刷新:`ie4uinit -show`,不是产物问题;
|
|
||||||
- 改图标流程:改 svg → `make_ico.py` 生成 ico → 重新打包(ico 同时是文件图标与运行时窗口图标);
|
|
||||||
- GUI 与 hdmi_source.ps1 各自独立实现显示器枚举,行为可能微差(GUI 与 `-List` 序号一致,
|
|
||||||
但与"设置"面板序号无保证);多屏操作前先确认序号;
|
|
||||||
- `pattern_slots.json` 兼容两种历史格式,写出只写新格式(详见 §3.11);
|
|
||||||
- CustomTkinter 6.x:`CTkComboBox` 不支持 `textvariable`(用 `.set()/.get()`);`CTkTextbox`
|
|
||||||
的 `tag_config` 在部分版本不可用,app_gui 已 try/except 兜底为单色;同一容器内
|
|
||||||
grid/pack 不可混用(卡片用 grid 挂进列,卡片内部一律 pack——`_card` 返回 (卡片, 内容));
|
|
||||||
|
|
||||||
## 7. 验证清单(改完代码后)
|
|
||||||
|
|
||||||
1. `python -m py_compile src/*.py` —— 全模块可编译;
|
|
||||||
2. `python selftest_rs485.py` —— 光机协议回归(改 dlpc_rs485.py 后必跑,向量来自上游 protocols.md);
|
|
||||||
3. `python hdmi_gui.py --seconds 5` —— GUI 冒烟(自动开关);
|
|
||||||
4. `python hdmi_gui.py --test-pattern Checker --area 800x600 --seconds 3` —— 投图链路;
|
|
||||||
5. `python hdmi_gui.py --dump` —— EDID 解算不抛异常;
|
|
||||||
6. `python hdmi_gui.py --dlpc-cmd M999`(不带 --port)—— 应明确报错而非崩溃(无硬件时的优雅降级);
|
|
||||||
7. `python build_exe.py` → 双击 release/DLPilot.exe 确认图标/双栏布局/投图/光机区渲染;
|
|
||||||
8. `python package_release.py <版本>` —— 不报"引用图片缺失"即栏位完整性 OK。
|
|
||||||