File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ class Connector:
9696 notes : Optional [MultilineHypertext ] = None
9797 pinlabels : List [Pin ] = field (default_factory = list )
9898 pins : List [Pin ] = field (default_factory = list )
99+ pincolors : List [Color ] = field (default_factory = list )
99100 color : Optional [Color ] = None
100101 show_name : Optional [bool ] = None
101102 show_pincount : Optional [bool ] = None
@@ -140,6 +141,9 @@ def __post_init__(self) -> None:
140141 if len (self .pins ) != len (set (self .pins )):
141142 raise Exception ('Pins are not unique' )
142143
144+ if self .pincolors :
145+ self .pincolors .extend ([None ] * (len (self .pins ) - len (self .pincolors ))) # autofill missing pincolors as 'no color'
146+
143147 if self .show_name is None :
144148 self .show_name = not self .autogenerate # hide auto-generated designators by default
145149
Original file line number Diff line number Diff line change @@ -110,14 +110,24 @@ def create_graph(self) -> Graph:
110110 pinhtml = []
111111 pinhtml .append ('<table border="0" cellspacing="0" cellpadding="3" cellborder="1">' )
112112
113- for pin , pinlabel in zip (connector .pins , connector .pinlabels ):
113+ for pin , pinlabel , pincolor in zip (connector .pins ,
114+ connector .pinlabels ,
115+ connector .pincolors if connector .pincolors else [None ] * len (connector .pins )):
114116 if connector .hide_disconnected_pins and not connector .visible_pins .get (pin , False ):
115117 continue
116118 pinhtml .append (' <tr>' )
117119 if connector .ports_left :
118120 pinhtml .append (f' <td port="p{ pin } l">{ pin } </td>' )
119121 if pinlabel :
120122 pinhtml .append (f' <td>{ pinlabel } </td>' )
123+ if connector .pincolors :
124+ if pincolor in wv_colors ._color_hex .keys ():
125+ pinhtml .append (f'<td sides="tbl">{ pincolor } </td>' )
126+ pinhtml .append (f'<td sides="tbr"><table border="0" cellborder="1"><tr><td bgcolor="{ wv_colors .translate_color (pincolor , "HEX" )} " width="8" height="8" fixedsize="true"></td></tr></table></td>' )
127+ else :
128+ pinhtml .append (f'<td sides="tbl"></td>' )
129+ pinhtml .append (f'<td sides="tbr"></td>' )
130+
121131 if connector .ports_right :
122132 pinhtml .append (f' <td port="p{ pin } r">{ pin } </td>' )
123133 pinhtml .append (' </tr>' )
You can’t perform that action at this time.
0 commit comments