Skip to content

Commit

Permalink
fix: enforce min size for polygon pads #28
Browse files Browse the repository at this point in the history
  • Loading branch information
urish committed Mar 7, 2020
1 parent f6de75f commit 471f9e4
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 3 deletions.
74 changes: 72 additions & 2 deletions src/board.spec.ts
Expand Up @@ -12,10 +12,11 @@ function round(obj: ISpectraList | string | number, precision = 3): ISpectraList
return obj.map((item) => round(item, precision));
}
if (typeof obj === 'number') {
if (obj > -Number.EPSILON && obj < Number.EPSILON) {
const result = parseFloat(obj.toFixed(precision));
if (result > -Number.EPSILON && result < Number.EPSILON) {
return 0;
}
return parseFloat(obj.toFixed(precision));
return result;
}
return obj;
}
Expand Down Expand Up @@ -464,4 +465,73 @@ describe('convertLib()', () => {
]
]);
});

it('should enforce minimal width and height for polygon pads', () => {
const input =
'LIB~585.7~338.9~package`0603`value`1.00k~90~~gge35720~1~c25f29e5d54148509f1fe8ecc29bd248~1549637911~0~#@$PAD~POLYGON~593.939~338.901~0~0~1~SYNC-OUT~1~0~595.51 340.87 592.37 340.87 592.37 336.93 595.51 336.93~180~gge35721~0~~Y~0~0~0.4~593.939,338.901#@$PAD~POLYGON~586.459~338.901~3.15~3.94~1~SYNC-OUT~2~0~588.03 340.87 584.88 340.87 584.88 336.93 588.03 336.93~180~gge35727~0~~Y~0~0~0.4~586.459,338.901';
const nets = ['', 'GND', 'B-IN'];
expect(normalize(convertShape(input, nets)[0])).toEqual([
'module',
'easyeda:0603',
['layer', 'F.Cu'],
['at', -867.232, -675.919, 90],
['attr', 'smd'],
[
'pad',
1,
'smd',
'custom',
['at', 0, 2.093, 180],
['size', 0.01, 0.01],
['layers', 'F.Cu', 'F.Paste', 'F.Mask'],
['net', 3, 'SYNC-OUT'],
[
'primitives',
[
'gr_poly',
[
'pts',
['xy', -0.399, -0.5],
['xy', 0.399, -0.5],
['xy', 0.399, 0.501],
['xy', -0.399, 0.501]
],
['width', 0.1]
]
]
],
[
'pad',
2,
'smd',
'custom',
['at', 0, 0.193, 180],
['size', 0.8, 1.001],
['layers', 'F.Cu', 'F.Paste', 'F.Mask'],
['net', 3, 'SYNC-OUT'],
[
'primitives',
[
'gr_poly',
[
'pts',
['xy', -0.399, -0.5],
['xy', 0.401, -0.5],
['xy', 0.401, 0.501],
['xy', -0.399, 0.501]
],
['width', 0.1]
]
]
],
[
'fp_text',
'user',
'gge35720',
['at', 0, 0],
['layer', 'Cmts.User'],
['effects', ['font', ['size', 1, 1], ['thickness', 0.15]]]
]
]);
});
});
2 changes: 1 addition & 1 deletion src/board.ts
Expand Up @@ -297,7 +297,7 @@ function convertPad(args: string[], nets: string[], transform: IParentTransform)
kiUnits(holeRadius) > 0 ? 'thru_hole' : 'smd',
shapes[shape],
kiAt(x, y, rotation, transform),
['size', kiUnits(width), kiUnits(height)],
['size', Math.max(kiUnits(width), 0.01), Math.max(kiUnits(height), 0.01)],
['layers', ...layers[layerId]],
getDrill(kiUnits(holeRadius), kiUnits(holeLength)),
netId > 0 ? ['net', netId, net] : null,
Expand Down

0 comments on commit 471f9e4

Please sign in to comment.