Merge pull request #10 from kimmoli/custom-pinnumbers
Add optional custom pinnumbers to connector
This commit is contained in:
commit
b4ddbaec35
@ -82,10 +82,17 @@ class Harness:
|
|||||||
# a = attributes
|
# a = attributes
|
||||||
a = [n.type,
|
a = [n.type,
|
||||||
n.subtype,
|
n.subtype,
|
||||||
'{}-pin'.format(len(n.pinout)) if n.show_pincount else '']
|
'{}-pin'.format(n.pincount) if n.show_pincount else '']
|
||||||
# p = pinout
|
# p = pinout
|
||||||
p = [[],[],[]]
|
p = [[],[],[]]
|
||||||
p[1] = list(n.pinout)
|
p[1] = list(n.pinout)
|
||||||
|
if (n.pinnumbers):
|
||||||
|
for i in n.pinnumbers:
|
||||||
|
if n.ports_left:
|
||||||
|
p[0].append('<p{portno}l>{portno}'.format(portno=i))
|
||||||
|
if n.ports_right:
|
||||||
|
p[2].append('<p{portno}r>{portno}'.format(portno=i))
|
||||||
|
else:
|
||||||
for i, x in enumerate(n.pinout, 1):
|
for i, x in enumerate(n.pinout, 1):
|
||||||
if n.ports_left:
|
if n.ports_left:
|
||||||
p[0].append('<p{portno}l>{portno}'.format(portno=i))
|
p[0].append('<p{portno}l>{portno}'.format(portno=i))
|
||||||
@ -318,6 +325,7 @@ class Connector:
|
|||||||
pincount: int = None
|
pincount: int = None
|
||||||
notes: str = None
|
notes: str = None
|
||||||
pinout: List[Any] = field(default_factory=list)
|
pinout: List[Any] = field(default_factory=list)
|
||||||
|
pinnumbers: List[Any] = field(default_factory=list)
|
||||||
color: str = None
|
color: str = None
|
||||||
show_name: bool = True
|
show_name: bool = True
|
||||||
show_pincount: bool = True
|
show_pincount: bool = True
|
||||||
@ -327,15 +335,17 @@ class Connector:
|
|||||||
self.ports_right = False
|
self.ports_right = False
|
||||||
self.loops = []
|
self.loops = []
|
||||||
|
|
||||||
|
if self.pincount is None:
|
||||||
if self.pinout:
|
if self.pinout:
|
||||||
if self.pincount is not None:
|
|
||||||
raise Exception('You cannot specify both pinout and pincount')
|
|
||||||
else:
|
|
||||||
self.pincount = len(self.pinout)
|
self.pincount = len(self.pinout)
|
||||||
|
elif self.pinnumbers:
|
||||||
|
self.pincount = len(self.pinnumbers)
|
||||||
else:
|
else:
|
||||||
if not self.pincount:
|
raise Exception('You need to specify at least one, pincount, pinout or pinnumbers')
|
||||||
self.pincount = 1
|
|
||||||
self.pinout = ['',] * self.pincount
|
if self.pinout and self.pinnumbers:
|
||||||
|
if len(self.pinout) != len(self.pinnumbers):
|
||||||
|
raise Exception('Given pinout and pinnumbers size mismatch')
|
||||||
|
|
||||||
def loop(self, from_pin, to_pin):
|
def loop(self, from_pin, to_pin):
|
||||||
self.loops.append((from_pin, to_pin))
|
self.loops.append((from_pin, to_pin))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user