Skip to content

Commit d762334

Browse files
authored
Merge pull request #163 from LibrePCB/dfn-fix-messages
dfn: Do not round pad coordinates & reduce min_copper_clearance
2 parents e32561c + 5c4d383 commit d762334

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

generate_dfn.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
FootprintPad,
5151
LetterSpacing,
5252
LineSpacing,
53+
MinCopperClearance,
5354
Mirror,
5455
Package,
5556
Package3DModel,
@@ -99,22 +100,15 @@ def uuid(category: str, full_name: str, identifier: str) -> str:
99100
return uuid_cache[key]
100101

101102

102-
def get_y(pin_number: int, pin_count: int, spacing: float, grid_align: bool) -> float:
103+
def get_y(pin_number: int, pin_count: int, spacing: float) -> float:
103104
"""
104-
Return the y coordinate of the specified pin. Keep the pins grid aligned, if desired.
105+
Return the y coordinate of the specified pin.
105106
106107
The pin number is 1 index based. Pin 1 is at the top. The middle pin will
107108
be at or near 0.
108-
109109
"""
110-
if grid_align:
111-
mid = float((pin_count + 1) // 2)
112-
else:
113-
mid = (pin_count + 1) / 2
114-
y = -round(pin_number * spacing - mid * spacing, 2)
115-
if y == -0.0: # Returns true for 0.0 too, but that doesn't matter
116-
return 0.0
117-
return y
110+
mid = (pin_count + 1) / 2
111+
return -pin_number * spacing + mid * spacing
118112

119113

120114
def generate_pkg(
@@ -193,12 +187,13 @@ def _uuid(identifier: str) -> str:
193187
description=Description(full_description),
194188
keywords=Keywords(full_keywords),
195189
author=Author(author),
196-
version=Version('0.2'),
190+
version=Version('0.3'),
197191
created=Created(create_date or now()),
198192
deprecated=Deprecated(False),
199193
generated_by=GeneratedBy(''),
200194
categories=[Category(pkgcat)],
201195
assembly_type=AssemblyType.SMT,
196+
min_copper_clearance=MinCopperClearance(0.15),
202197
)
203198

204199
# Create pads
@@ -254,7 +249,7 @@ def _generate_footprint(key: str, name: str, tag: str, pad_extension: float) ->
254249
# Place pads
255250
for pad_idx, pad_nr in enumerate(range(1, config.pin_count + 1)):
256251
half_n_pads = config.pin_count // 2
257-
pad_pos_y = get_y(pad_idx % half_n_pads + 1, half_n_pads, config.pitch, False)
252+
pad_pos_y = get_y(pad_idx % half_n_pads + 1, half_n_pads, config.pitch)
258253

259254
if pad_idx < (config.pin_count / 2):
260255
pad_pos_x = -abs_pad_pos_x
@@ -314,7 +309,7 @@ def _generate_footprint(key: str, name: str, tag: str, pad_extension: float) ->
314309
silk_down = (
315310
config.length / 2
316311
- SILKSCREEN_OFFSET
317-
- get_y(1, half_n_pads, config.pitch, False)
312+
- get_y(1, half_n_pads, config.pitch)
318313
- config.lead_width / 2
319314
- SILKSCREEN_LINE_WIDTH / 2
320315
) # required for round ending of line
@@ -383,7 +378,7 @@ def _generate_footprint(key: str, name: str, tag: str, pad_extension: float) ->
383378

384379
# Make silkscreen lead exact pad width and length
385380
half_n_pads = config.pin_count // 2
386-
pad_pos_y = get_y(pad_idx % half_n_pads + 1, half_n_pads, config.pitch, False)
381+
pad_pos_y = get_y(pad_idx % half_n_pads + 1, half_n_pads, config.pitch)
387382
if pad_idx >= (config.pin_count / 2):
388383
pad_pos_y = -pad_pos_y
389384
y_min = pad_pos_y - config.lead_width / 2
@@ -625,7 +620,7 @@ def generate_3d(
625620
pins_per_side = config.pin_count // 2
626621
for i in range(0, config.pin_count):
627622
side = -1 if (i < pins_per_side) else 1
628-
y1 = get_y(1 if (i < pins_per_side) else pins_per_side, pins_per_side, config.pitch, False)
623+
y1 = get_y(1 if (i < pins_per_side) else pins_per_side, pins_per_side, config.pitch)
629624
y_index = i % pins_per_side
630625
assembly.add_body(
631626
lead,

0 commit comments

Comments
 (0)