Skip to content

Commit

Permalink
connectors: Add support for screw terminals
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrgn committed Jul 16, 2022
1 parent 00603cb commit e79aced
Show file tree
Hide file tree
Showing 2 changed files with 2,519 additions and 5 deletions.
88 changes: 83 additions & 5 deletions generate_connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
+---+
"""
import math
from os import makedirs, path
from uuid import uuid4

Expand All @@ -20,8 +21,8 @@
from common import format_float as ff
from common import init_cache, now, save_cache
from entities.common import (
Align, Angle, Author, Category, Created, Deprecated, Description, Fill, GrabArea, Height, Keywords, Layer, Length,
Name, Polygon, Position, Rotation, Text, Value, Version, Vertex, Width
Align, Angle, Author, Category, Circle, Created, Deprecated, Description, Diameter, Fill, GrabArea, Height,
Keywords, Layer, Length, Name, Polygon, Position, Rotation, Text, Value, Version, Vertex, Width
)
from entities.component import (
Clock, Component, DefaultValue, ForcedNet, Gate, Negated, Norm, PinSignalMap, Prefix, Required, Role, SchematicOnly,
Expand All @@ -43,6 +44,7 @@
KIND_HEADER = 'pinheader'
KIND_SOCKET = 'pinsocket'
KIND_WIRE_CONNECTOR = 'wireconnector'
KIND_SCREW_TERMINAL = 'screwterminal'


# Initialize UUID cache
Expand Down Expand Up @@ -303,6 +305,10 @@ def generate_sym(
for i in range(min_pads, max_pads + 1, rows):
per_row = i // rows
w = width * rows # Make double-row symbols wider!
if kind == KIND_SCREW_TERMINAL:
w_offset = 1.27 # Make screw terminals wider on the left
else:
w_offset = 0

variant = '{}x{}'.format(rows, per_row)

Expand All @@ -313,6 +319,8 @@ def _uuid(identifier: str) -> str:
uuid_pins = [_uuid('pin-{}'.format(p)) for p in range(i)]
uuid_polygon = _uuid('polygon-contour')
uuid_decoration = _uuid('polygon-decoration')
uuid_decoration_2 = _uuid('polygon-decoration-2')
uuid_decoration_3 = _uuid('polygon-decoration-3')
uuid_text_name = _uuid('text-name')
uuid_text_value = _uuid('text-value')

Expand Down Expand Up @@ -349,11 +357,11 @@ def _uuid(identifier: str) -> str:
Fill(False),
GrabArea(True)
)
polygon.add_vertex(Vertex(Position(-w, y_max), Angle(0.0)))
polygon.add_vertex(Vertex(Position(-w - w_offset, y_max), Angle(0.0)))
polygon.add_vertex(Vertex(Position(w, y_max), Angle(0.0)))
polygon.add_vertex(Vertex(Position(w, y_min), Angle(0.0)))
polygon.add_vertex(Vertex(Position(-w, y_min), Angle(0.0)))
polygon.add_vertex(Vertex(Position(-w, y_max), Angle(0.0)))
polygon.add_vertex(Vertex(Position(-w - w_offset, y_min), Angle(0.0)))
polygon.add_vertex(Vertex(Position(-w - w_offset, y_max), Angle(0.0)))
symbol.add_polygon(polygon)

# Decorations
Expand Down Expand Up @@ -395,6 +403,45 @@ def _uuid(identifier: str) -> str:
polygon.add_vertex(Vertex(Position(x_offset, y - dy), Angle(x_sign * 135.0)))
polygon.add_vertex(Vertex(Position(x_offset, y + dy), Angle(0.0)))
symbol.add_polygon(polygon)
elif kind == KIND_SCREW_TERMINAL:
# Screw terminals: Screw circle
for p in range(1, i + 1):
y = get_y(p, i, rows, spacing, True)
dy = spacing / 4 * 0.75
diam = 1.6
x_offset = -w - w_offset + (diam / 2) + 0.6
pos = Position(x_offset, y)
symbol.add_circle(Circle(
uuid_decoration,
Layer('sym_outlines'),
Width(line_width * 0.75),
Fill(False),
GrabArea(False),
Diameter(diam),
pos,
))
line_dx = (diam / 2) * math.cos(math.pi / 4 - math.pi / 16)
line_dy = (diam / 2) * math.sin(math.pi / 4 - math.pi / 16)
line1 = Polygon(
uuid_decoration_2,
Layer('sym_outlines'),
Width(line_width * .5),
Fill(False),
GrabArea(False),
)
line1.add_vertex(Vertex(Position(pos.x + line_dx, pos.y + line_dy), Angle(0.0)))
line1.add_vertex(Vertex(Position(pos.x - line_dy, pos.y - line_dx), Angle(0.0)))
symbol.add_polygon(line1)
line2 = Polygon(
uuid_decoration_3,
Layer('sym_outlines'),
Width(line_width * .5),
Fill(False),
GrabArea(False),
)
line2.add_vertex(Vertex(Position(pos.x + line_dy, pos.y + line_dx), Angle(0.0)))
line2.add_vertex(Vertex(Position(pos.x - line_dx, pos.y - line_dy), Angle(0.0)))
symbol.add_polygon(line2)

# Text
y_max, y_min = get_rectangle_bounds(i, rows, spacing, spacing, True)
Expand Down Expand Up @@ -811,6 +858,37 @@ def _make(dirpath: str) -> None:
create_date='2019-10-12T23:40:41Z',
)

# Screw terminal
generate_sym(
dirpath='out/connectors/sym',
author='Danilo B.',
name='Screw Terminal',
name_lower='screw terminal',
kind=KIND_SCREW_TERMINAL,
cmpcat='f9db4ef5-2220-462a-adff-deac8402ecf0', # Terminal Blocks
keywords='screw terminal, terminal block',
rows=1,
min_pads=1,
max_pads=40,
version='0.1',
create_date='2022-07-16T21:23:20Z',
)
generate_cmp(
dirpath='out/connectors/cmp',
author='Danilo B.',
name='Screw Terminal',
name_lower='screw terminal',
kind=KIND_SCREW_TERMINAL,
cmpcat='f9db4ef5-2220-462a-adff-deac8402ecf0', # Terminal Blocks
keywords='screw terminal, terminal block',
default_value='{{PARTNUMBER}}',
rows=1,
min_pads=1,
max_pads=40,
version='0.1',
create_date='2022-07-16T21:23:20Z',
)

# Generic connector
generate_sym(
dirpath='out/connectors/sym',
Expand Down
Loading

0 comments on commit e79aced

Please sign in to comment.