Skip to content

Commit

Permalink
dfn: Rework for file format 1.0
Browse files Browse the repository at this point in the history
- Specify assembly type & pad functions
- Add package outline polygons
  • Loading branch information
ubruhin committed Nov 15, 2024
1 parent 2a741f0 commit c562bea
Show file tree
Hide file tree
Showing 2 changed files with 1,094 additions and 4 deletions.
42 changes: 38 additions & 4 deletions generate_dfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
SILKSCREEN_OFFSET = 0.15
SILKSCREEN_LINE_WIDTH = 0.254
LABEL_OFFSET = 1.0
COURTYARD_EXCESS = 0.2

MIN_CLEARANCE = 0.20 # For checking only --> warns if violated
MIN_TRACE = 0.10
Expand Down Expand Up @@ -143,12 +144,12 @@ def _uuid(identifier: str) -> str:
description=Description(full_description),
keywords=Keywords(full_keywords),
author=Author(author),
version=Version('0.1.2'),
version=Version('0.2'),
created=Created(create_date or now()),
deprecated=Deprecated(False),
generated_by=GeneratedBy(''),
categories=[Category(pkgcat)],
assembly_type=AssemblyType.AUTO,
assembly_type=AssemblyType.SMT,
)

# Create pads
Expand Down Expand Up @@ -213,7 +214,7 @@ def _generate_footprint(key: str, name: str, pad_extension: float) -> None:
stop_mask=StopMaskConfig.AUTO,
solder_paste=SolderPasteConfig.AUTO,
copper_clearance=CopperClearance(0.0),
function=PadFunction.UNSPECIFIED,
function=PadFunction.STANDARD_PAD,
package_pad=PackagePadUuid(uuid_pads[pad_idx]),
holes=[],
))
Expand All @@ -232,7 +233,7 @@ def _generate_footprint(key: str, name: str, pad_extension: float) -> None:
stop_mask=StopMaskConfig.AUTO,
solder_paste=SolderPasteConfig.AUTO,
copper_clearance=CopperClearance(0.0),
function=PadFunction.UNSPECIFIED,
function=PadFunction.STANDARD_PAD,
package_pad=PackagePadUuid(uuid_exp),
holes=[],
))
Expand Down Expand Up @@ -386,6 +387,32 @@ def _generate_footprint(key: str, name: str, pad_extension: float) -> None:
Position(silk_circ_x, silk_circ_y),
))

# Package Outline
dx = config.width / 2
dy = config.length / 2
footprint.add_polygon(Polygon(
uuid=_uuid('polygon-outline-{}'.format(key)),
layer=Layer('top_package_outlines'),
width=Width(0),
fill=Fill(False),
grab_area=GrabArea(False),
vertices=[
Vertex(Position(-dx, dy), Angle(0)), # NW
Vertex(Position(dx, dy), Angle(0)), # NE
Vertex(Position(dx, -dy), Angle(0)), # SE
Vertex(Position(-dx, -dy), Angle(0)), # SW
],
))

# Courtyard
footprint.add_polygon(generate_courtyard(
uuid=_uuid('polygon-courtyard-{}'.format(key)),
max_x=config.width / 2,
max_y=config.length / 2,
excess_x=COURTYARD_EXCESS,
excess_y=COURTYARD_EXCESS,
))

# Add name and value labels
uuid_text_name = _uuid('text-name-{}'.format(key))
uuid_text_value = _uuid('text-value-{}'.format(key))
Expand Down Expand Up @@ -418,6 +445,13 @@ def _generate_footprint(key: str, name: str, pad_extension: float) -> None:
value=Value('{{VALUE}}'),
))

# Approvals
package.add_approval(
"(approved missing_footprint_3d_model\n" +
" (footprint {})\n".format(uuid_footprint) +
")"
)

# Apply function to available footprints
_generate_footprint('reflow', 'reflow', 0.0)
_generate_footprint('hand-soldering', 'hand soldering', 0.3)
Expand Down
Loading

0 comments on commit c562bea

Please sign in to comment.