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
|
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
"""Write the footprint for the ARKLED SM410561N 0.56" single digit display.
Dimensions from the ARKLED specification, page 4/4: body 12.60 x 19.0 mm,
2 x 5 pins on a 2.54 mm pitch, rows 15.24 mm apart, pin diameter 0.51 mm,
pin 1 bottom left (digit upright), numbering counter-clockwise.
Footprint origin = pin 1.
make_7seg_fp.py OUT.kicad_mod
"""
import sys
import uuid
NS = uuid.UUID("2f1b6f2e-9a77-4b8e-8f0e-5a3c7e1d2b44")
OUT = sys.argv[1]
W, H, PITCH, ROW = 12.60, 19.0, 2.54, 15.24
CX, CY = 2 * PITCH, -ROW / 2 # body centre relative to pin 1
def u(*a):
return str(uuid.uuid5(NS, "/".join(map(str, a))))
def f(v):
v = round(v, 4)
return "0" if v == 0 else f"{v:g}"
o = ['(footprint "7SegmentLED_0.56in_1Digit_SM410561N"\n\t(version 20241229)\n\t(generator "eboard")\n'
'\t(generator_version "9.0")\n\t(layer "F.Cu")\n'
'\t(descr "0.56 inch single digit 7-segment display, ARKLED SM410561N, '
'https://www.lcsc.com/product-detail/C141368.html")\n'
'\t(tags "7 segment LED display 0.56 inch")\n']
def prop(name, val, x, y, layer, hide=False):
o.append(f'\t(property "{name}" "{val}"\n\t\t(at {f(x)} {f(y)} 0)\n\t\t(layer "{layer}")\n'
+ ('\t\t(hide yes)\n' if hide else '')
+ f'\t\t(uuid "{u("p", name)}")\n\t\t(effects\n\t\t\t(font\n\t\t\t\t(size 1 1)\n'
'\t\t\t\t(thickness 0.15)\n\t\t\t)\n\t\t)\n\t)\n')
def line(x1, y1, x2, y2, layer, w):
o.append(f'\t(fp_line\n\t\t(start {f(x1)} {f(y1)})\n\t\t(end {f(x2)} {f(y2)})\n\t\t(stroke\n'
f'\t\t\t(width {w})\n\t\t\t(type solid)\n\t\t)\n\t\t(layer "{layer}")\n'
f'\t\t(uuid "{u("l", layer, x1, y1, x2, y2)}")\n\t)\n')
def rect(x1, y1, x2, y2, layer, w):
for a, b in (((x1, y1), (x2, y1)), ((x2, y1), (x2, y2)), ((x2, y2), (x1, y2)), ((x1, y2), (x1, y1))):
line(*a, *b, layer, w)
x1, x2, y1, y2 = CX - W / 2, CX + W / 2, CY - H / 2, CY + H / 2
prop("Reference", "REF**", CX, y1 - 1.5, "F.SilkS")
prop("Value", "SM410561N", CX, y2 + 1.5, "F.Fab")
prop("Datasheet", "https://www.lcsc.com/product-detail/C141368.html", 0, 0, "F.Fab", hide=True)
prop("Description", "0.56 inch single digit 7-segment display", 0, 0, "F.Fab", hide=True)
o.append('\t(attr through_hole)\n')
rect(x1, y1, x2, y2, "F.Fab", 0.1)
rect(x1 - 0.12, y1 - 0.12, x2 + 0.12, y2 + 0.12, "F.SilkS", 0.12)
rect(x1 - 0.5, y1 - 0.5, x2 + 0.5, y2 + 0.5, "F.CrtYd", 0.05)
line(x1 - 0.5, 1.2, x1 - 0.5, -1.2, "F.SilkS", 0.12) # pin 1 marker
o.append(f'\t(fp_text user "${{REFERENCE}}"\n\t\t(at {f(CX)} {f(CY)} 0)\n\t\t(layer "F.Fab")\n'
f'\t\t(uuid "{u("t")}")\n\t\t(effects\n\t\t\t(font\n\t\t\t\t(size 1 1)\n'
'\t\t\t\t(thickness 0.15)\n\t\t\t)\n\t\t)\n\t)\n')
pads = [(n, (n - 1) * PITCH, 0.0) for n in range(1, 6)] + \
[(n, (10 - n) * PITCH, -ROW) for n in range(6, 11)]
for n, x, y in pads:
shape = "rect" if n == 1 else "circle"
o.append(f'\t(pad "{n}" thru_hole {shape}\n\t\t(at {f(x)} {f(y)})\n\t\t(size 1.5 1.5)\n'
f'\t\t(drill 0.8)\n\t\t(layers "*.Cu" "*.Mask")\n\t\t(remove_unused_layers no)\n'
f'\t\t(uuid "{u("pad", n)}")\n\t)\n')
o.append('\t(embedded_fonts no)\n)\n')
open(OUT, "w").write("".join(o))
print("wrote", OUT)
|