-
Notifications
You must be signed in to change notification settings - Fork 1
/
pinout_ulx3s.py
163 lines (150 loc) · 3.65 KB
/
pinout_ulx3s.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
###########################################
#
# ULX3S based on example script to build a
# pinout diagram. Includes basic
# features and convenience classes.
#
###########################################
from pinout.core import Group
from pinout.components.layout import Diagram, Panel
from pinout.components.pinlabel import PinLabelGroup, PinLabel
from pinout.components.text import TextBlock
from pinout.components import leaderline as lline
from pinout.components.legend import Legend
from custom_components import PNG_from_web
# Import data for the diagram
import data
# Create a new diagram
diagram = Diagram(2200, 1700, "diagram")
# Add a stylesheet
diagram.add_stylesheet("styles.css", True)
# Create a layout
content = diagram.add(
Panel(
width=1852,
height=1214,
inset=(2, 2, 2, 2),
)
)
panel_main = content.add(
Panel(
width=content.inset_width,
height=742,
inset=(2, 2, 2, 2),
tag="panel--main",
)
)
panel_info = content.add(
Panel(
x=0,
y=panel_main.height,
width=panel_main.width,
height=content.inset_height - panel_main.height,
inset=(2, 2, 2, 2),
tag="panel--info",
)
)
# Create a group to hold the pinout-diagram components.
graphic = panel_main.add(Group(1, 1))
# Add and embed an image
graphic.add(PNG_from_web("https://raw.githubusercontent.com/ulx3s/ulx3s-pinout/main/ulx3s.png", width=1372, height=742, embed=True))
# This works too(!). Changing 'blob' to 'raw' matches the 'download' button url.
#graphic.add(PNG_from_web("https://github.com/ulx3s/ulx3s-pinout/raw/main/ulx3s.png", width=1372, height=742, embed=True))
# Create a single pin label
graphic.add(
PinLabel(
content=(content.inset_height - graphic.height) / 2,
x=100,
y=1,
tag="pwr",
body={"x": 200, "y": 20, "width": 200, "height": 20},
leaderline={"direction": "vh"},
)
)
#
## Create pinlabels on the right header
#graphic.add(
# PinLabelGroup(
# x=1372,
# y=742,
# pin_pitch=(0, 30),
# label_start=(60, 0),
# label_pitch=(0, 30),
# labels=data.right_header,
# )
#)
#
# Create pinlabels on the left header
graphic.add(
PinLabelGroup(
x=280,
y=145,
body={"height": 20},
pin_pitch=(0, 22.5),
label_start=(30, 0),
label_pitch=(0, 22.5),
scale=(-1, 1),
labels=data.left_header_even,
)
)
graphic.add(
PinLabelGroup(
x=304,
y=145,
body={"height": 20},
pin_pitch=(0, 22.5),
label_start=(30, 0),
label_pitch=(0, 22.5),
scale=(1, 1),
labels=data.left_header_odd,
)
)
#
## Create pinlabels on the lower header
#graphic.add(
# PinLabelGroup(
# x=65,
# y=244,
# scale=(-1, 1),
# pin_pitch=(30, 0),
# label_start=(110, 30),
# label_pitch=(0, 30),
# labels=data.lower_header,
# leaderline=lline.Curved(direction="vh"),
# )
#)
#
## Create a title and a text-block
#title_block = panel_info.add(
# TextBlock(
# data.title,
# x=20,
# y=30,
# line_height=18,
# tag="panel title_block",
# )
#)
#panel_info.add(
# TextBlock(
# data.description,
# x=20,
# y=60,
# width=title_block.width,
# height=panel_info.height - title_block.height,
# line_height=18,
# tag="panel text_block",
# )
#)
#
# Create a legend
legend = panel_info.add(
Legend(
data.legend,
x=340,
y=8,
max_height=132,
)
)
#
# Export the diagram via commandline:
# >>> py -m pinout.manager --export pinout_diagram diagram.svg