Skip to content

fix: synchronize footprint polarity with component pin labels - #4836

Merged
Abse2001 merged 2 commits into
mainfrom
fix/footprinter-core-polarity
Oct 22, 2026
Merged

Abse2001 merged 2 commits into
mainfrom
fix/footprinter-core-polarity

Conversation

@Abse2001

Copy link
Copy Markdown
Contributor

A diode/LED can connect its electrical anode to pad 2 through pinLabels while footprinter still draws its positive artwork beside pad 1. Resolve polarity before generating the footprint so the electrical terminals and fabrication/silkscreen artwork use the same mapping.

For example, <led footprint="led0805" pinLabels={{ pin1: ["cathode", "neg"], pin2: ["anode", "pos"] }} /> now generates the footprint with anodepin2_cathodepin1, without modifying user props or numeric pad identities. Explicit footprint polarity options must agree with the labels; contradictory inputs produce a readable error.

Also forwards capacitor polarized to footprinter, selecting capacitor geometry for bare chip sizes when needed. Explicit capacitor positivepin/negativepin options and the cathode-first defaults of DO-219AD/SOD-323HE now initialize unambiguous electrical aliases instead of attaching both positive and negative aliases to each pin. Capacitor pinLabels are not added here; that API is not accepted by the current capacitor props schema.

Reproduction and snapshots

bun test tests/components/normal-components/footprinter-polarity-labels.test.tsx fails on unchanged main: the positive annotation lies on the opposite side of the body from its emitted electrical anode (dot product −2.59875, expected positive). It passes with this fix. Additional board regressions cover matching/conflicting options, input immutability, cathode-first defaults, capacitor controls, rotation and bottom-layer mirroring.

Default and reversed polarity, including transformed bottom-layer parts

Positive capacitor terminal 1, terminal 2, and nonpolarized control

Footprinter integration

Related marking PRs: tscircuit/footprinter#926 and tscircuit/footprinter#927. This PR passes the required options; rendering the new printed + marks still requires those changes to be released and consumed. No dependency version is changed here. Separate local end-to-end checks against each actual PR build confirm all four diode/LED cases and all four capacitor cases put the printed mark on the resolved positive terminal. Committed tests use core's declared dependency, without module mocks or sibling package links.

Validation

  • 48 tests across 41 files passed, 655 assertions, with snapshot updates disabled: diode, LED, capacitor, footprinter regressions and shared-component checks.
  • Production build and TypeScript declarations passed.
  • Changed-file formatting, new-file Biome checks and git diff --check passed.
  • All four new PCB snapshots were visually inspected. No new documentation files or workflow changes.

@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tscircuit-core-benchmarks Ready Ready Preview Oct 22, 2026 9:11pm UTC

Request Review

@Abse2001 Abse2001 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The polarity behavior looks good in the focused tests. Just two small convention fixes before approval.

Comment thread tests/components/normal-components/footprinter-polarity-labels.test.tsx Outdated
@Abse2001
Abse2001 merged commit 6b92949 into main Oct 22, 2026
19 checks passed
@Abse2001
Abse2001 deleted the fix/footprinter-core-polarity branch October 22, 2026 22:20
@tscircuitbot

Copy link
Copy Markdown
Contributor

Thank you for your contribution! 🎉

PR Rating: ⭐⭐
Impact: Minor

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


1 similar comment
@tscircuitbot

Copy link
Copy Markdown
Contributor

Thank you for your contribution! 🎉

PR Rating: ⭐⭐
Impact: Minor

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


This branch was successfully deployed

1 active deployment
Preview — 92ad6cc5 Deployed Oct 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants