Skip to content

Commit

Permalink
connectors: Fix all reported library editor messages (#125)
Browse files Browse the repository at this point in the history
- Add package outline & courtyard polygons to packages
- Approve "suspicious assembly type" in soldered wire connector packages
- Approve "no default value set" message in soldered wire connector
  components
- Approve "no parts" message in all devices
  • Loading branch information
ubruhin authored Oct 21, 2023
1 parent a2d49b3 commit 58dd6e7
Show file tree
Hide file tree
Showing 2 changed files with 1,084 additions and 7 deletions.
63 changes: 56 additions & 7 deletions generate_connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
line_width = 0.25
pkg_text_height = 1.0
sym_text_height = 2.54
courtyard_offset = 0.5 # Rather large because packages are generic (i.e. not exact)


KIND_HEADER = 'pinheader'
Expand Down Expand Up @@ -155,6 +156,8 @@ def _uuid(identifier: str) -> str:
uuid_pkg = _uuid('pkg')
uuid_pads = [_uuid('pad-{}'.format(p)) for p in range(i)]
uuid_footprint = _uuid('footprint-default')
uuid_outline = _uuid('polygon-outline')
uuid_courtyard = _uuid('polygon-courtyard')
uuid_text_name = _uuid('text-name')
uuid_text_value = _uuid('text-value')

Expand Down Expand Up @@ -227,6 +230,40 @@ def _uuid(identifier: str) -> str:
silkscreen = generate_silkscreen(category, kind, variant, i, rows)
footprint.add_polygon(silkscreen)

# Package outline
dx = (width + (rows - 1) * spacing) / 2
dy = (width + (per_row - 1) * spacing) / 2
footprint.add_polygon(Polygon(
uuid=uuid_outline,
layer=Layer('top_package_outlines'),
width=Width(0),
fill=Fill(False),
grab_area=GrabArea(False),
vertices=[
Vertex(Position(-dx, dy), Angle(0)),
Vertex(Position(dx, dy), Angle(0)),
Vertex(Position(dx, -dy), Angle(0)),
Vertex(Position(-dx, -dy), Angle(0)),
],
))

# Courtyard
dx += courtyard_offset
dy += courtyard_offset
footprint.add_polygon(Polygon(
uuid=uuid_courtyard,
layer=Layer('top_courtyard'),
width=Width(0),
fill=Fill(False),
grab_area=GrabArea(False),
vertices=[
Vertex(Position(-dx, dy), Angle(0)),
Vertex(Position(dx, dy), Angle(0)),
Vertex(Position(dx, -dy), Angle(0)),
Vertex(Position(-dx, -dy), Angle(0)),
],
))

# Labels
y_max, y_min = get_rectangle_bounds(i, rows, spacing, top_offset + 1.27, False)
footprint.add_text(StrokeText(
Expand Down Expand Up @@ -267,6 +304,12 @@ def _uuid(identifier: str) -> str:
for footprint in package.footprints:
footprint.add_3d_model(Footprint3DModel(uuid_3d))

# Message approvals
if assembly_type == AssemblyType.NONE:
# Assembly type is reported as suspicious because there are
# some pads, but this is intended for soldered wire connectors.
package.add_approval("(approved suspicious_assembly_type)")

package.serialize(path.join('out', library, category))

print('{}x{:02d} {} ⌀{:.1f}mm: Wrote package {}'.format(rows, per_row, kind, drill, uuid_pkg))
Expand Down Expand Up @@ -630,6 +673,11 @@ def _uuid(identifier: str) -> str:

component.add_variant(Variant(uuid_variant, Norm.EMPTY, Name('default'), Description(''), gate))

# Message approvals
if len(default_value) == 0:
# Approve the "no default value set" message.
component.add_approval("(approved empty_default_value)")

component.serialize(path.join('out', library, category))
print('{}x{} {}: Wrote component {}'.format(rows, per_row, kind, uuid_cmp))

Expand Down Expand Up @@ -675,7 +723,7 @@ def _uuid(identifier: str) -> str:
'Generated with {}")'.format(rows, per_row, name_lower, spacing, drill, generator))
lines.append(' (keywords "connector, {}x{}, d{:.1f}, {}")'.format(rows, per_row, drill, keywords))
lines.append(' (author "{}")'.format(author))
lines.append(' (version "0.1")')
lines.append(' (version "0.1.1")')
lines.append(' (created {})'.format(create_date or now()))
lines.append(' (deprecated false)')
lines.append(' (generated_by "")')
Expand All @@ -686,6 +734,7 @@ def _uuid(identifier: str) -> str:
for p in range(1, i + 1):
signalmappings.append(' (pad {} (signal {}))'.format(uuid_pads[p - 1], uuid_signals[p - 1]))
lines.extend(sorted(signalmappings))
lines.append(" (approved no_parts)")
lines.append(')')

dev_dir_path = path.join('out', library, category, uuid_dev)
Expand Down Expand Up @@ -788,7 +837,7 @@ def _uuid(identifier: str) -> str:
generate_silkscreen=generate_silkscreen_male,
generate_3d_model=partial(generate_3d_model_generic, 'male'),
generate_3d_models=generate_3d_models,
version='0.2',
version='0.3',
create_date='2018-10-17T19:13:41Z',
)
generate_pkg(
Expand All @@ -807,7 +856,7 @@ def _uuid(identifier: str) -> str:
generate_silkscreen=generate_silkscreen_male,
generate_3d_model=partial(generate_3d_model_generic, 'male'),
generate_3d_models=generate_3d_models,
version='0.2',
version='0.3',
create_date='2019-09-17T20:00:41Z',
)
generate_dev(
Expand Down Expand Up @@ -914,7 +963,7 @@ def _uuid(identifier: str) -> str:
generate_silkscreen=generate_silkscreen_female,
generate_3d_model=partial(generate_3d_model_generic, 'female'),
generate_3d_models=generate_3d_models,
version='0.2',
version='0.3',
create_date='2018-10-17T19:13:41Z',
)
generate_pkg(
Expand All @@ -933,7 +982,7 @@ def _uuid(identifier: str) -> str:
generate_silkscreen=generate_silkscreen_female,
generate_3d_model=partial(generate_3d_model_generic, 'female'),
generate_3d_models=generate_3d_models,
version='0.2',
version='0.3',
create_date='2019-09-17T20:00:41Z',
)
generate_dev(
Expand Down Expand Up @@ -994,7 +1043,7 @@ def _uuid(identifier: str) -> str:
rows=1,
min_pads=1,
max_pads=40,
version='0.1',
version='0.1.1',
create_date='2018-10-17T19:13:41Z',
)
generate_pkg(
Expand All @@ -1013,7 +1062,7 @@ def _uuid(identifier: str) -> str:
generate_silkscreen=generate_silkscreen_female,
generate_3d_model=None,
generate_3d_models=False,
version='0.2',
version='0.3',
create_date='2018-10-17T19:13:41Z',
)
generate_dev(
Expand Down
Loading

0 comments on commit 58dd6e7

Please sign in to comment.