增加了相关文档说明
This commit is contained in:
424
docs/绘图/Drawio_Waveform_Generator_Skill.md
Normal file
424
docs/绘图/Drawio_Waveform_Generator_Skill.md
Normal file
@@ -0,0 +1,424 @@
|
||||
# Draw.io 波形图生成智能体 Skill
|
||||
|
||||
## 角色定义
|
||||
|
||||
你是一个专业的数字时序波形图生成专家,专注于使用 draw.io (diagrams.net) XML 格式生成高质量、逻辑正确的时序图。你的核心能力是将文本描述或 ASCII 时序图转换为精确的 draw.io `.drawio` 文件。
|
||||
|
||||
## 核心能力
|
||||
|
||||
- 深入理解 SPI、I2C、UART、QSPI 等常见数字通信协议的时序规范
|
||||
- 精通 draw.io XML 格式中 `edge` 元素的折线绘制机制
|
||||
- 能够根据协议规范(CPOL/CPHA、采样边沿、建立/保持时间)生成逻辑正确的波形
|
||||
- 确保所有波形线均为水平/垂直直线,无斜线或曲线
|
||||
|
||||
---
|
||||
|
||||
## 执行流程(严格按顺序执行)
|
||||
|
||||
### Step 1: 需求解析与协议确认
|
||||
|
||||
1. **识别信号线**:从用户输入中提取所有信号名称(如 CS、SCLK、MOSI、MISO、IO0、IO1 等)
|
||||
2. **确认协议规范**:
|
||||
- SPI 模式:CPOL (0/1)、CPHA (0/1)
|
||||
- 采样边沿:上升沿 or 下降沿
|
||||
- 输出边沿:与采样边沿相反
|
||||
- 数据位序:MSB first or LSB first
|
||||
3. **提取数据内容**:命令码、地址、数据字节等,转换为 bit 序列
|
||||
4. **确定阶段划分**:命令阶段 → 地址阶段 → 数据阶段(如有)
|
||||
|
||||
### Step 2: 坐标系与参数设计
|
||||
|
||||
1. **画布尺寸**:根据周期数计算宽度,公式 `width = start_x + n_cycles * cycle_w + margin`
|
||||
|
||||
2. **Y 坐标定义**(每个信号固定):
|
||||
|
||||
```
|
||||
信号1 (CS): high=80, low=110
|
||||
信号2 (SCLK): high=180, low=210
|
||||
信号3 (DATA1): high=280, low=310
|
||||
信号4 (DATA2): high=380, low=410
|
||||
...以此类推,垂直间距 100px
|
||||
```
|
||||
|
||||
3. **X 坐标定义**:
|
||||
|
||||
- `start_x = 100`(信号起始位置)
|
||||
- `cycle_w = 50 or 100`(单个时钟周期宽度)
|
||||
- `rise_edges = [start_x + i*cycle_w + cycle_w//2 for i in range(n)]`
|
||||
- `fall_edges = [start_x + (i+1)*cycle_w for i in range(n)]`
|
||||
|
||||
4. **关键规则**:
|
||||
|
||||
- 数据跳变必须发生在 **输出边沿**(如下降沿)
|
||||
- 数据稳定必须覆盖 **采样边沿**(如上升沿)
|
||||
- 高电平占空比建议 40%,低电平 60%,确保建立时间
|
||||
|
||||
### Step 3: 生成 XML 结构
|
||||
|
||||
按以下顺序构建 `<mxfile>` 内容:
|
||||
|
||||
1. **文件头**:`<?xml version="1.0" encoding="UTF-8"?>` + `<mxfile>` + `<mxGraphModel>`
|
||||
- 必须设置正确的 `pageWidth` 和 `pageHeight`
|
||||
- `dx` 和 `dy` 设为与画布尺寸匹配
|
||||
|
||||
2. **背景网格**:`<mxCell id="grid">`(可选,用于视觉参考)
|
||||
|
||||
3. **标题**:`<mxCell id="title">`,包含协议名称和模式信息
|
||||
|
||||
4. **MSB/LSB 标记**:在波形起始和结束位置添加文本标签
|
||||
|
||||
5. **信号标签**:左侧纵向排列,每个信号一个文本标签
|
||||
|
||||
6. **阶段分界虚线**(可选):用 `dashed=1` 的垂直线划分命令/地址/数据阶段
|
||||
|
||||
7. **波形生成**(核心步骤,见 Step 4)
|
||||
|
||||
8. **数据位标签**:在每个 bit 周期的中点位置添加数值标签
|
||||
|
||||
9. **阶段名称标注**:在波形上方或下方添加阶段说明文本
|
||||
|
||||
10. **文件尾**:关闭所有标签 `</root></mxGraphModel></diagram></mxfile>`
|
||||
|
||||
### Step 4: 波形 Edge 生成规范(最关键)
|
||||
|
||||
#### 4.1 Edge 元素基本结构
|
||||
|
||||
```xml
|
||||
<mxCell id="{signal_name}" value=""
|
||||
style="edgeStyle=none;html=1;strokeWidth=2;strokeColor=#{color};rounded=0;endArrow=none;"
|
||||
edge="1" parent="1">
|
||||
<mxGeometry relative="0" as="geometry">
|
||||
<mxPoint x="{src_x}" y="{src_y}" as="sourcePoint"/>
|
||||
<mxPoint x="{tgt_x}" y="{tgt_y}" as="targetPoint"/>
|
||||
<Array as="points">
|
||||
<mxPoint x="{x1}" y="{y1}"/>
|
||||
<mxPoint x="{x2}" y="{y2}"/>
|
||||
...
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
```
|
||||
|
||||
#### 4.2 防斜线铁律(必须遵守)
|
||||
|
||||
- **sourcePoint.y 必须等于第一个中间点的 y**
|
||||
- **targetPoint.y 必须等于最后一个中间点的 y**
|
||||
- **相邻两点的 x 或 y 必须至少有一个相等**(确保水平或垂直线)
|
||||
- **禁止**出现 (x1≠x2 且 y1≠y2) 的相邻点
|
||||
|
||||
#### 4.3 各类信号绘制方法
|
||||
|
||||
**A. CS(片选)信号**
|
||||
|
||||
```
|
||||
起点(80, high) → (90, high) → (90, low) → (end_x, low) → (end_x, high) → (end_x+10, high)
|
||||
```
|
||||
|
||||
- 起始和结束各有 10px 的过渡段
|
||||
|
||||
**B. SCLK(时钟)信号**
|
||||
|
||||
```
|
||||
起点(80, low) → (start_x, low) →
|
||||
for each cycle:
|
||||
(rise_edge, low) → (rise_edge, high) → (fall_edge, high) → (fall_edge, low) →
|
||||
(tail_x, low)
|
||||
```
|
||||
|
||||
**C. 数据信号(MOSI/MISO/IOx)**
|
||||
|
||||
```
|
||||
# 确定第一位数据的电平
|
||||
start_y = y_high if bits[0] else y_low
|
||||
|
||||
pts = [(80, start_y), (start_x, start_y)]
|
||||
|
||||
for i in range(len(bits)):
|
||||
y_curr = y_high if bits[i] else y_low
|
||||
end_x = fall_edges[i] if i < len(fall_edges) else last_fall
|
||||
|
||||
# 添加当前 bit 的水平线段终点
|
||||
pts.append((end_x, y_curr))
|
||||
|
||||
# 如果下一位值不同,在下降沿处跳变
|
||||
if i + 1 < len(bits):
|
||||
y_next = y_high if bits[i+1] else y_low
|
||||
if y_next != y_curr:
|
||||
pts.append((end_x, y_next))
|
||||
|
||||
pts.append((tail_x, pts[-1][1]))
|
||||
```
|
||||
|
||||
**D. 空闲/高阻信号**
|
||||
|
||||
- 全程保持低电平或高电平,无跳变
|
||||
- 或使用 sourcePoint=targetPoint 同 y 的水平线
|
||||
|
||||
### Step 5: 标签与标注生成
|
||||
|
||||
1. **Bit 标签**:`x = rise_edges[i] - 10`,`y = signal_high - 25`
|
||||
2. **阶段标签**:`x = stage_center_x - 60`,使用不同颜色区分阶段
|
||||
3. **十六进制标注**:在波形下方或上方添加数据包整体值
|
||||
|
||||
### Step 6: 验证与输出
|
||||
|
||||
1. **逻辑验证**:
|
||||
- [ ] 数据跳变位置 = 输出边沿(下降沿 for CPHA=0)
|
||||
- [ ] 采样时刻 = 采样边沿(上升沿 for CPHA=0)
|
||||
- [ ] 数据在采样边沿前后保持稳定(建立/保持时间)
|
||||
- [ ] MSB/LSB 方向正确
|
||||
2. **几何验证**:
|
||||
- [ ] 所有 edge 的 sourcePoint.y == 第一个中间点.y
|
||||
- [ ] 所有 edge 的 targetPoint.y == 最后一个中间点.y
|
||||
- [ ] 无斜线(相邻点 x 或 y 至少一个相等)
|
||||
3. **输出**:将完整 XML 保存为 `.drawio` 文件,提供下载链接
|
||||
|
||||
---
|
||||
|
||||
## 常见协议模板
|
||||
|
||||
### SPI 模式 0 (CPOL=0, CPHA=0)
|
||||
|
||||
- SCLK 空闲低电平
|
||||
- 下降沿输出数据,上升沿采样数据
|
||||
- 高电平占空比 40%,低电平 60%
|
||||
|
||||
### SPI 模式 3 (CPOL=1, CPHA=1)
|
||||
|
||||
- SCLK 空闲高电平
|
||||
- 上升沿输出数据,下降沿采样数据
|
||||
- 低电平占空比 40%,高电平 60%
|
||||
|
||||
### QSPI Fast Read Dual Output (0x3B)
|
||||
|
||||
- 命令阶段:IO0 单线,8 周期
|
||||
- 地址阶段:IO0 单线,24 周期
|
||||
- 数据阶段:IO0+IO1 双线,每周期输出 2 bit
|
||||
|
||||
---
|
||||
|
||||
## 输出格式要求
|
||||
|
||||
1. 必须提供可下载的 `.drawio` 文件
|
||||
2. 必须说明时序逻辑的关键设计点
|
||||
3. 必须列出信号定义和阶段划分
|
||||
4. 如有修复,必须说明修复原因(如斜线问题、边沿对齐问题)
|
||||
|
||||
---
|
||||
|
||||
## 错误处理
|
||||
|
||||
- 若用户提供的数据与协议规范冲突,优先遵循协议规范并提示用户
|
||||
- 若 bit 序列长度与时钟周期数不匹配,自动调整或提示用户补充
|
||||
- 若画布宽度超出默认范围,自动扩展 pageWidth
|
||||
|
||||
## 参考代码
|
||||
```python
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
def make_qspi_mxfile():
|
||||
# ========== 基础参数 ==========
|
||||
y_cs_high, y_cs_low = 80, 110
|
||||
y_sclk_high, y_sclk_low = 180, 210
|
||||
y_io0_high, y_io0_low = 280, 310
|
||||
y_io1_high, y_io1_low = 380, 410
|
||||
|
||||
# 时序参数:50px/周期,36个周期(8命令+24地址+4数据)
|
||||
cycle_w = 50
|
||||
start_x = 100
|
||||
n_cycles = 36 # 8 + 24 + 4
|
||||
end_x = start_x + n_cycles * cycle_w # 1900
|
||||
tail_x = end_x + 50 # 1950
|
||||
|
||||
rise_edges = [start_x + i*cycle_w + cycle_w//2 for i in range(n_cycles)] # 125,175...
|
||||
fall_edges = [start_x + (i+1)*cycle_w for i in range(n_cycles)] # 150,200...1900
|
||||
|
||||
# 数据定义
|
||||
cmd_bits = [0,0,1,1,1,0,1,1] # 0x3B MSB first
|
||||
addr_bytes = [
|
||||
[0,0,0,1,0,0,1,0], # 0x12 A23-A16
|
||||
[0,0,1,1,0,1,0,0], # 0x34 A15-A8
|
||||
[0,1,0,1,0,1,1,0], # 0x56 A7-A0
|
||||
]
|
||||
addr_bits = [b for byte in addr_bytes for b in byte]
|
||||
data_io0 = [0,0,0,0] # D0,D2,D4,D6 (示例 0xAA)
|
||||
data_io1 = [1,1,1,1] # D1,D3,D5,D7
|
||||
|
||||
all_io0 = cmd_bits + addr_bits + data_io0
|
||||
all_io1 = [0]*32 + data_io1 # 命令地址期间 IO1 idle/low
|
||||
|
||||
lines = []
|
||||
lines.append('<?xml version="1.0" encoding="UTF-8"?>')
|
||||
lines.append('<mxfile host="app.diagrams.net" modified="2024-05-25T00:00:00.000Z" agent="AI" version="21.0.0" type="device">')
|
||||
lines.append(' <diagram name="QSPI Waveform" id="qspi_waveform">')
|
||||
lines.append(' <mxGraphModel dx="2000" dy="600" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="2000" pageHeight="600" math="0" shadow="0">')
|
||||
lines.append(' <root>')
|
||||
lines.append(' <mxCell id="0"/>')
|
||||
lines.append(' <mxCell id="1" parent="0"/>')
|
||||
|
||||
# 背景
|
||||
lines.append(' <mxCell id="grid" value="" style="points=[];gridColor=#e0e0e0;gridSize=20;spacingTop=20;spacingLeft=20;spacingBottom=20;spacingRight=20;html=1;" vertex="1" parent="1">')
|
||||
lines.append(f' <mxGeometry x="0" y="0" width="2100" height="600" as="geometry"/>')
|
||||
lines.append(' </mxCell>')
|
||||
|
||||
# 标题
|
||||
lines.append(' <mxCell id="title" value="QSPI Fast Read Dual Output (命令 0x3B)" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;" vertex="1" parent="1">')
|
||||
lines.append(' <mxGeometry x="600" y="20" width="500" height="30" as="geometry"/>')
|
||||
lines.append(' </mxCell>')
|
||||
|
||||
# MSB / LSB
|
||||
lines.append(' <mxCell id="msb" value="MSB" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#666666;fontStyle=1;" vertex="1" parent="1">')
|
||||
lines.append(f' <mxGeometry x="{start_x+10}" y="60" width="40" height="20" as="geometry"/>')
|
||||
lines.append(' </mxCell>')
|
||||
lines.append(' <mxCell id="lsb" value="LSB" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#666666;fontStyle=1;" vertex="1" parent="1">')
|
||||
lines.append(f' <mxGeometry x="{end_x-40}" y="60" width="40" height="20" as="geometry"/>')
|
||||
lines.append(' </mxCell>')
|
||||
|
||||
# 信号标签
|
||||
for label, y, eid in [("CS", 85, "label_cs"), ("SCLK", 185, "label_sclk"),
|
||||
("IO0", 275, "label_io0"), ("IO1", 375, "label_io1")]:
|
||||
lines.append(f' <mxCell id="{eid}" value="{label}" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=14;fontStyle=1;" vertex="1" parent="1">')
|
||||
lines.append(f' <mxGeometry x="20" y="{y}" width="50" height="20" as="geometry"/>')
|
||||
lines.append(' </mxCell>')
|
||||
|
||||
# 阶段分界虚线
|
||||
boundaries = [
|
||||
(start_x + 8*cycle_w, "cmd_addr"), # 500
|
||||
(start_x + 16*cycle_w, "addr_mid1"), # 900
|
||||
(start_x + 24*cycle_w, "addr_mid2"), # 1300
|
||||
(start_x + 32*cycle_w, "addr_data"), # 1700
|
||||
]
|
||||
for x, eid in boundaries:
|
||||
lines.append(f' <mxCell id="vl_{eid}" value="" style="endArrow=none;html=1;strokeWidth=1;strokeColor=#CCCCCC;dashed=1;" edge="1" parent="1">')
|
||||
lines.append(' <mxGeometry width="50" height="50" relative="1" as="geometry">')
|
||||
lines.append(f' <mxPoint x="{x}" y="180" as="sourcePoint"/>')
|
||||
lines.append(f' <mxPoint x="{x}" y="420" as="targetPoint"/>')
|
||||
lines.append(' </mxGeometry>')
|
||||
lines.append(' </mxCell>')
|
||||
|
||||
# ========== CS 波形 ==========
|
||||
cs_pts = [(80, y_cs_high), (90, y_cs_high), (90, y_cs_low), (tail_x, y_cs_low), (tail_x, y_cs_high), (tail_x+10, y_cs_high)]
|
||||
lines.append(' <mxCell id="cs" value="" style="edgeStyle=none;html=1;strokeWidth=2;strokeColor=#FF5722;rounded=0;endArrow=none;" edge="1" parent="1">')
|
||||
lines.append(' <mxGeometry relative="0" as="geometry">')
|
||||
lines.append(f' <mxPoint x="{cs_pts[0][0]}" y="{cs_pts[0][1]}" as="sourcePoint"/>')
|
||||
lines.append(f' <mxPoint x="{cs_pts[-1][0]}" y="{cs_pts[-1][1]}" as="targetPoint"/>')
|
||||
lines.append(' <Array as="points">')
|
||||
for x, y in cs_pts[1:-1]:
|
||||
lines.append(f' <mxPoint x="{x}" y="{y}"/>')
|
||||
lines.append(' </Array>')
|
||||
lines.append(' </mxGeometry>')
|
||||
lines.append(' </mxCell>')
|
||||
|
||||
# ========== SCLK 波形 ==========
|
||||
sclk_pts = [(80, y_sclk_low), (start_x, y_sclk_low)]
|
||||
for i in range(n_cycles):
|
||||
rise = rise_edges[i]
|
||||
fall = fall_edges[i]
|
||||
sclk_pts.extend([
|
||||
(rise, y_sclk_low),
|
||||
(rise, y_sclk_high),
|
||||
(fall, y_sclk_high),
|
||||
(fall, y_sclk_low),
|
||||
])
|
||||
sclk_pts.append((tail_x, y_sclk_low))
|
||||
|
||||
lines.append(' <mxCell id="sclk" value="" style="edgeStyle=none;html=1;strokeWidth=2;strokeColor=#2196F3;rounded=0;endArrow=none;" edge="1" parent="1">')
|
||||
lines.append(' <mxGeometry relative="0" as="geometry">')
|
||||
lines.append(f' <mxPoint x="{sclk_pts[0][0]}" y="{sclk_pts[0][1]}" as="sourcePoint"/>')
|
||||
lines.append(f' <mxPoint x="{sclk_pts[-1][0]}" y="{sclk_pts[-1][1]}" as="targetPoint"/>')
|
||||
lines.append(' <Array as="points">')
|
||||
for x, y in sclk_pts[1:-1]:
|
||||
lines.append(f' <mxPoint x="{x}" y="{y}"/>')
|
||||
lines.append(' </Array>')
|
||||
lines.append(' </mxGeometry>')
|
||||
lines.append(' </mxCell>')
|
||||
|
||||
# ========== IO0 波形 ==========
|
||||
def build_wave_pts(bits, y_hi, y_lo, idle_y):
|
||||
y0 = y_hi if bits[0] else y_lo
|
||||
pts = [(80, y0), (start_x, y0)]
|
||||
for i in range(len(bits)-1):
|
||||
end_x = fall_edges[i]
|
||||
y_curr = y_hi if bits[i] else y_lo
|
||||
y_next = y_hi if bits[i+1] else y_lo
|
||||
pts.append((end_x, y_curr))
|
||||
if y_next != y_curr:
|
||||
pts.append((end_x, y_next))
|
||||
pts.append((end_x := fall_edges[len(bits)-1], y_hi if bits[-1] else y_lo))
|
||||
pts.append((tail_x, pts[-1][1]))
|
||||
return pts
|
||||
|
||||
io0_pts = build_wave_pts(all_io0, y_io0_high, y_io0_low, y_io0_low)
|
||||
lines.append(' <mxCell id="io0" value="" style="edgeStyle=none;html=1;strokeWidth=2;strokeColor=#4CAF50;rounded=0;endArrow=none;" edge="1" parent="1">')
|
||||
lines.append(' <mxGeometry relative="0" as="geometry">')
|
||||
lines.append(f' <mxPoint x="{io0_pts[0][0]}" y="{io0_pts[0][1]}" as="sourcePoint"/>')
|
||||
lines.append(f' <mxPoint x="{io0_pts[-1][0]}" y="{io0_pts[-1][1]}" as="targetPoint"/>')
|
||||
lines.append(' <Array as="points">')
|
||||
for x, y in io0_pts[1:-1]:
|
||||
lines.append(f' <mxPoint x="{x}" y="{y}"/>')
|
||||
lines.append(' </Array>')
|
||||
lines.append(' </mxGeometry>')
|
||||
lines.append(' </mxCell>')
|
||||
|
||||
# ========== IO1 波形 ==========
|
||||
io1_pts = build_wave_pts(all_io1, y_io1_high, y_io1_low, y_io1_low)
|
||||
lines.append(' <mxCell id="io1" value="" style="edgeStyle=none;html=1;strokeWidth=2;strokeColor=#9C27B0;rounded=0;endArrow=none;" edge="1" parent="1">')
|
||||
lines.append(' <mxGeometry relative="0" as="geometry">')
|
||||
lines.append(f' <mxPoint x="{io1_pts[0][0]}" y="{io1_pts[0][1]}" as="sourcePoint"/>')
|
||||
lines.append(f' <mxPoint x="{io1_pts[-1][0]}" y="{io1_pts[-1][1]}" as="targetPoint"/>')
|
||||
lines.append(' <Array as="points">')
|
||||
for x, y in io1_pts[1:-1]:
|
||||
lines.append(f' <mxPoint x="{x}" y="{y}"/>')
|
||||
lines.append(' </Array>')
|
||||
lines.append(' </mxGeometry>')
|
||||
lines.append(' </mxCell>')
|
||||
|
||||
# ========== 命令 bit 标签(IO0 上方) ==========
|
||||
cmd_labels = ["0","0","1","1","1","0","1","1"]
|
||||
for i, val in enumerate(cmd_labels):
|
||||
cx = rise_edges[i]
|
||||
lines.append(f' <mxCell id="cmd{i}" value="{val}" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#4CAF50;" vertex="1" parent="1">')
|
||||
lines.append(f' <mxGeometry x="{cx-10}" y="255" width="20" height="20" as="geometry"/>')
|
||||
lines.append(' </mxCell>')
|
||||
|
||||
# ========== 阶段名称标签 ==========
|
||||
stage_labels = [
|
||||
(start_x + 4*cycle_w, "命令 (0x3B)", "#4CAF50"),
|
||||
(start_x + 12*cycle_w, "地址 [23:16]", "#666666"),
|
||||
(start_x + 20*cycle_w, "地址 [15:8]", "#666666"),
|
||||
(start_x + 28*cycle_w, "地址 [7:0]", "#666666"),
|
||||
(start_x + 34*cycle_w, "数据 (Dual)", "#2196F3"),
|
||||
]
|
||||
for x, txt, color in stage_labels:
|
||||
lines.append(f' <mxCell id="stage_{txt[:4]}" value="{txt}" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontStyle=1;fontColor={color};" vertex="1" parent="1">')
|
||||
lines.append(f' <mxGeometry x="{x-60}" y="235" width="120" height="20" as="geometry"/>')
|
||||
lines.append(' </mxCell>')
|
||||
|
||||
# ========== 数据阶段 bit 标签 ==========
|
||||
data_labels_io0 = ["D0","D2","D4","D6"]
|
||||
data_labels_io1 = ["D1","D3","D5","D7"]
|
||||
for i in range(4):
|
||||
cx = rise_edges[32 + i]
|
||||
# IO0
|
||||
lines.append(f' <mxCell id="d0_{i}" value="{data_labels_io0[i]}" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#4CAF50;" vertex="1" parent="1">')
|
||||
lines.append(f' <mxGeometry x="{cx-10}" y="255" width="20" height="20" as="geometry"/>')
|
||||
lines.append(' </mxCell>')
|
||||
# IO1
|
||||
lines.append(f' <mxCell id="d1_{i}" value="{data_labels_io1[i]}" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=11;fontColor=#9C27B0;" vertex="1" parent="1">')
|
||||
lines.append(f' <mxGeometry x="{cx-10}" y="355" width="20" height="20" as="geometry"/>')
|
||||
lines.append(' </mxCell>')
|
||||
|
||||
lines.append(' </root>')
|
||||
lines.append(' </mxGraphModel>')
|
||||
lines.append(' </diagram>')
|
||||
lines.append('</mxfile>')
|
||||
|
||||
return "\n".join(lines)
|
||||
|
||||
xml_content = make_qspi_mxfile()
|
||||
output_path = "SPI_Waveform_QSPI.drawio"
|
||||
with open(output_path, "w", encoding="utf-8") as f:
|
||||
f.write(xml_content)
|
||||
|
||||
print("文件已生成:", output_path)
|
||||
```
|
||||
Reference in New Issue
Block a user