Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connectors: Add support for screw terminals #96

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 80 additions & 4 deletions generate_connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

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


# Initialize UUID cache
Expand Down Expand Up @@ -485,6 +487,8 @@ 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!
pin_length_inside = 0.6 if kind == KIND_SCREW_TERMINAL else 1.27
pin_name_offset = 5.2 if kind == KIND_SCREW_TERMINAL else 5.08

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

Expand All @@ -495,6 +499,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 All @@ -520,8 +526,8 @@ def _uuid(identifier: str) -> str:
Name(str(p)),
Position((w + 2.54) * x_sign, get_y(p, i, rows, spacing, True)),
Rotation(180.0 if p % rows == 0 else 0),
Length(3.81),
NamePosition(5.08, 0.0),
Length(2.54 + pin_length_inside),
NamePosition(pin_name_offset, 0.0),
NameRotation(0.0),
NameHeight(2.5),
NameAlign('left center'),
Expand Down Expand Up @@ -583,6 +589,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 - (diam / 2) - pin_length_inside
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 @@ -1014,6 +1059,37 @@ def _uuid(identifier: str) -> str:
create_date='2019-10-12T23:40:41Z',
)

# Screw terminal
generate_sym(
library='LibrePCB_Connectors.lplib',
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.2',
create_date='2022-07-16T21:23:20Z',
)
generate_cmp(
library='LibrePCB_Connectors.lplib',
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='{{MPN}}',
rows=1,
min_pads=1,
max_pads=40,
version='0.2',
create_date='2022-07-16T21:23:20Z',
)

# Generic connector
generate_sym(
library='LibrePCB_Connectors.lplib',
Expand Down
Loading
Loading