文件
phonerail/.claude/p4b_pos.py
zhou yang和Claude Opus 5 2bfe308b30 初始导入:PhoneRail 五路手机直供电源板
原理图/PCB 已在 EasyEDA 里做到 12 页跨页 0 漏接,固件刚完成骨架包 A1。
这次是把已有的一切一次性纳入版本控制,没有改动任何设计内容。

纳入:
- 设计与需求文档、PROGRESS.md、小米8 参考原理图 PDF 与追脚脚本
- .claude/ 下的 EasyEDA 桥接工具链与几何/网表缓存(eda-parts.json、
  pcb-parts.json、pcb-pads.json、p2-ch1.json 等,是重画各页的唯一事实来源)
- 117 张验证截图(本项目所有方向问题都是靠人眼看截图发现的,属于证据不是垃圾)
- firmware/ 的 A1 骨架与 site/ 文档站源码

.gitignore 排除:构建产物(firmware/build、host/build、sdkconfig)、
site/node_modules、__pycache__、桥接日志 _bridge.log、脚本自标的 *.stale。

.gitattributes 默认 `* -text`:现有 .py/.json 大多是 CRLF,原样存,
不让 git 重写行尾。唯一例外是 *.sh 强制 LF —— 带 \r 的 shell 脚本 bash 跑不了。

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QYuExfgyYa6DzRRcUso8M8
2026-09-06 18:18:14 +08:00

108 行
4.5 KiB
Python

此文件含有模棱两可的 Unicode 字符
此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。
# -*- coding: utf-8 -*-
u"""P4B-HUB 的元件最终位置(分块摆放)。
页面分块(1170×825,标题栏占 x>455 且 y<192):
y=800 ┌ 【去耦 bank】x 40~320, y 700~760 ─────────────────────────┐
│ 【B1 晶振】x 900~1140, y 620~760
│ 左侧端口列 x=170 【B2 RBIAS/VDD18PLL/VDD18】y 520~600
│ (标签朝左) ┌ U32 ┐ 【B3 口6/7禁用】y 430~510
│ 【B5 分压】 │65 脚│ 【B4 跳线下拉+RESET】y 340~420
│ x 40~80 └─────┘ 右侧端口列 x=760(标签朝右)
y=340 ├───────────────────────────────────────────────────────────┤
│ 【B8 LDO】x 100~340 【B7 12V→5V】x 480~900 【去耦续】 │
y=192 ├──────────────── 标题栏从这里往下、往右 ────────────────────┤
│ 【B6 上游 USB-C】x 120~440, y 40~190(全在标题栏左边) │
y= 20 └───────────────────────────────────────────────────────────┘
用法: python .claude/p4b_pos.py # 把元件挪到位并重新读回引脚
"""
import io, json, os, sys
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
PAGE = '7a469c6f43d6d0c8'
POS = {
'U32': (500, 500, 0),
# 【B1】晶振
'Y1': (1000, 700, 0),
'C740': (920, 660, 270),
'C741': (1090, 660, 270),
# 【B2】RBIAS / VDD18PLL / VDD18
'R708': (960, 560, 270),
'C743': (1060, 560, 270),
'C742': (1130, 560, 270),
# 【B3】端口 6/7 禁用上拉
'R714': (955, 450, 0),
'R715': (955, 490, 0),
# 【B4】跳线下拉 + RESET 上拉
'R711': (920, 380, 270),
'R712': (970, 380, 270),
'R719': (1020, 380, 270),
'R720': (1070, 380, 270),
'R716': (1130, 380, 270),
# 【B5】VBUS_DET 分压
'R709': (60, 400, 270),
'R710': (60, 320, 270),
# 【B6】上游 USB-C
'J23': (260, 110, 0),
'R717': (400, 140, 0),
'R718': (400, 100, 0),
# 【B7】12V → 5V
'C731': (500, 280, 270),
'C732': (535, 280, 270),
'U30': (600, 270, 0),
'C733': (660, 330, 270),
'L3': (730, 280, 0),
'C734': (790, 280, 270),
'C735': (825, 280, 270),
'R706': (880, 300, 270),
'R707': (880, 230, 270),
# 【B8】5V → 3V3(Hub 专用)
'C736': (120, 260, 270),
'U31': (200, 260, 0),
'C737': (320, 260, 270),
# 3V3 去耦 bank(PCB 上要贴到各电源脚,§10)
'C744': (60, 720, 270), 'C745': (95, 720, 270), 'C746': (130, 720, 270),
'C747': (165, 720, 270), 'C748': (200, 720, 270), 'C749': (235, 720, 270),
'C750': (270, 720, 270), 'C751': (305, 720, 270),
}
if __name__ == '__main__':
from eda import run
js = """
await eda.dmt_EditorControl.openDocument('%s');
await new Promise(r=>setTimeout(r,1500));
if ((await eda.dmt_Schematic.getCurrentSchematicPageInfo()).name !== 'P4B-HUB')
return {err:'页面不对'};
const POS = %s;
let n = 0; const miss = [];
for (const c of await eda.sch_PrimitiveComponent.getAll()){
if (c.getState_ComponentType() !== 'part') continue;
const d = c.getState_Designator();
if (!POS[d]) { miss.push(d); continue; }
const [x, y, r] = POS[d];
await c.toAsync().setState_X(x).setState_Y(y).setState_Rotation(r).done();
n++;
}
const out = {};
for (const c of await eda.sch_PrimitiveComponent.getAll()){
if (c.getState_ComponentType() !== 'part') continue;
const o = {};
for (const p of await c.getAllPins())
o[p.getState_PinNumber ? p.getState_PinNumber() : p.getState_PinName()] =
[Math.round(p.getState_X()), Math.round(p.getState_Y()), p.getState_PinName()];
out[c.getState_Designator()] = o;
}
return {moved: n, missing: miss, pins: out};
""" % (PAGE, json.dumps(POS))
r = run(js, timeout=600)
if not r.get('success'):
print(json.dumps(r, ensure_ascii=False)[:400]); sys.exit(1)
res = r['result']
print(u'挪了 %d 个,未在表里: %s' % (res['moved'], res['missing']))
io.open(os.path.join(HERE, 'p4b-pins.json'), 'w', encoding='utf-8').write(
json.dumps(res['pins'], ensure_ascii=False, indent=1))
print(u'引脚已写入 .claude/p4b-pins.json')