fix(solderjumper): default to 2 pins when no pin count is given - #785
fix(solderjumper): default to 2 pins when no pin count is given#785zkasuran wants to merge 2 commits into
Conversation
A bare fp.string("solderjumper") produced NaN geometry: a courtyard rect
with NaN width and center.x plus a silkscreen text with a NaN anchor,
because num_pins was read with no default and an omitted count left it
undefined. Default num_pins to 2, the same way the function already
defaults p, pw and ph, matching solderjumper2 and the repo convention of
falling back to a sensible pin count. Adds an assertion test for finite
geometry plus an SVG snapshot of the default footprint.
The bare "solderjumper" form this PR enables now defaults to 2 pins. Add a kicad-parity case that feeds it KiCad's SolderJumper-2 dimensions and checks the defaulted output against the real KiCad SolderJumper-2 footprint (courtyard diff 0.00%, under the 0.5 threshold the other parity tests use), so the new default path is proven geometrically correct, not just the right pad count. footprinter's own 2.54mm default jumper has no KiCad standard equivalent, so the KiCad dims are supplied explicitly, matching the existing solderjumper2 parity case.
|
Added a KiCad parity test up front so this does not need a separate round.
One honest note on dimensions. footprinter's own solderjumper defaults (2.54mm pitch, 1.5mm square pads) are a generic 0.1 inch jumper that does not track any KiCad standard part. KiCad's SolderJumper-2 is a smaller 1.3mm-pitch bridge pad. So the parity case supplies KiCad's dimensions explicitly ( Full suite green: 524 pass, 0 fail. |
Closes #784
What
A bare
fp.string("solderjumper")(no pin count) silently produced invalid geometry: apcb_courtyard_rectwithwidthandcenter.xset to NaN plus apcb_silkscreen_textwith a NaN anchor.solderjumper2andsolderjumper3were already fine.The cause is in
src/fn/solderjumper.ts:num_pinswas read from params with no default, so an omitted count left itundefinedand(num_pins - 1) * padSpacing(and everything derived from it) became NaN.Fix
Default
num_pinsto 2 when it is omitted, the same way the function already defaultsp,pwandph. This matches the wider convention in this repo where a missing pin count falls back to a sensible default (dipgives 6,ssopgives 8,pinrowgives 6, plus many others). 2 lines up withsolderjumper2, the smallest documented variant and the first example in the doc comment. Explicit counts are unchanged.Tests
solderjumpernow yields 2 pads with finite courtyard geometry and a finite silkscreen text anchor (no NaN). It fails on the current code (0 pads, NaN width) then passes with the fix.solderjumper_default) rendered from the fixed output, showing the real 2-pin footprint.Verification
Verified locally before submitting:
bun test: 523 pass, 0 failbun run build: success (ESM plus dts)bunx biome formatclean on the changed filesAI disclosure
AI assistance (Claude, Anthropic) was used in developing this change. Verified locally before submitting: full
bun test(523 pass, 0 fail), plusbun run buildandbiome formaton the changed files.