cartridge/cn1.py
2023-06-19 17:57:22 +00:00

22 lines
638 B
Python

from kicad_sym import *
def make_pins(lines, half_width):
for ix, (number, name, type) in enumerate(lines):
x = u(-half_width) if number[0] == 'A' else u(half_width)
y = u((-ix + 0) * 2) if number[0] == 'A' else u((-ix + 67) * 2)
r = 0 if number[0] == 'A' else 180
yield pin(x, y, r, number, name, type)
def make_lib(lines):
half_width = 12
pins = list(make_pins(lines, half_width))
return lib([
symbol("CN1", "CN1",
pins,
u(-half_width), u(2),
u(half_width), u(-len(pins)))
])
lines = read_txt("cn1.txt")
print(make_lib(lines))