google / pcbdl

PCB Design Language: A programming way to design schematics.
Other
155 stars 23 forks source link

Multiple GND symbols #16

Open kiavash-at-work opened 5 years ago

kiavash-at-work commented 5 years ago

Generated SVG treats all nets with GND in it the same GND symbol, however it would be better to have different symbols for AGND and GND.

kiavash-at-work commented 5 years ago
diff --git a/lib/analog.svg b/lib/analog.svg
index c73f649..a5fc479 100644
--- a/lib/analog.svg
+++ b/lib/analog.svg
@@ -59,6 +59,13 @@ text {
   <g s:x="10" s:y="-30" s:pid="A" s:position="bottom"/>
 </g>

+<g s:type="agnd" s:width="20" s:height="30" transform="translate(120,35)">
+  <s:alias val="agnd" />
+  <text x="10" y="10" class="nodelabel $cell_id" s:attribute="name">AGND</text>
+  <path d="M0,-15 H20 L10,0 Z M10,-15 V-30" class="$cell_id"/>
+  <g s:x="10" s:y="-30" s:pid="A" s:position="bottom"/>
+</g>
+
 <g s:type="gnd" s:width="20" s:height="30" transform="translate(80,35)">
   <s:alias val="gnd"/>
   <path d="M0,0 H20 M3,5 H17 M7,10 H13 M10,0 V-15" class="$cell_id"/>

and

diff --git a/pcbdl/netlistsvg.py b/pcbdl/netlistsvg.py
index 956284c..2f8a915 100644
--- a/pcbdl/netlistsvg.py
+++ b/pcbdl/netlistsvg.py
@@ -111,12 +111,19 @@ class SVGPart(object):
                name_attribute = net.name
                if len(name_attribute) > 10:
                        name_attribute = name_attribute.replace("PP","")
-                       name_attribute = name_attribute.replace("_VREF","")
-
+                       name_attribute = name_attribute.replace("_VREF","")     
+                       
+               if net.name == "GND":
+                       part_type = "gnd"
+               elif net.is_gnd:
+                       part_type = "agnd"
+               elif net.is_power:
+                       part_type = "vcc"
+               
                power_symbol = {
                        "connections": {"A": [net_node_number]},
                        "attributes": {"value": name_attribute},
-                       "type": "gnd" if net.is_gnd else "vcc",
+                       "type": part_type,
                }

                self.schematic_page.parts_dict[name] = power_symbol
amstan commented 5 years ago

New behavior now!

Every GND net that's not named GND will just have the text displaying so.

https://github.com/google/pcbdl/commit/93378310b6d10e15ef07b5a149b9c2ba4dfc6522#diff-526fb11c69a6225770197dff49f9efeaR120

So: