Skip to content

implement TO-220 horizontal variant#534

Closed
victorjzq wants to merge 1 commit intotscircuit:mainfrom
victorjzq:fix/issue-185
Closed

implement TO-220 horizontal variant#534
victorjzq wants to merge 1 commit intotscircuit:mainfrom
victorjzq:fix/issue-185

Conversation

@victorjzq
Copy link
Copy Markdown
Contributor

/claim #185

Added the TO-220H (horizontal) footprint variant, which was missing despite TO-220 being a very common through-hole package. The implementation generates plated holes centered on y=0 with the body extending upward, and supports a tabup parameter to render the mounting tab on the silkscreen — I made sure the ref text shifts up accordingly when the tab is present so it doesn't overlap. Pitch auto-computes from body width when pins exceed 2 to handle wider variants correctly.

Fixes #185

@victorjzq
Copy link
Copy Markdown
Contributor Author

Duplicate of #533, closing this one.

Comment on lines +1 to +40
import { test, expect } from "bun:test"
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
import { fp } from "src/footprinter"

test("to220h_3", () => {
const circuitJson = fp.string("to220h_3").circuitJson()
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)

expect(circuitJson).toBeDefined()
expect(circuitJson.length).toBeGreaterThan(0)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "to220h_3")
})

test("to220h_3_tabup", () => {
const circuitJson = fp.string("to220h_3_tabup").circuitJson()
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)

expect(circuitJson).toBeDefined()
expect(circuitJson.length).toBeGreaterThan(0)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "to220h_3_tabup")
})

test("to220h_2", () => {
const circuitJson = fp.string("to220h_2").circuitJson()
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)

expect(circuitJson).toBeDefined()
expect(circuitJson.length).toBeGreaterThan(0)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "to220h_2")
})

test("TO-220H-3 (alias)", () => {
const aliasSvg = convertCircuitJsonToPcbSvg(
fp.string("TO-220H-3").circuitJson(),
)
const canonicalSvg = convertCircuitJsonToPcbSvg(
fp.string("to220h_3").circuitJson(),
)
expect(aliasSvg).toEqual(canonicalSvg)
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test file contains 4 test() calls (lines 5, 14, 23, and 32), but according to the style guide rule, a *.test.ts file may have AT MOST one test(...) function. After that, the user should split into multiple, numbered files. To fix this, split the tests into separate files like: to220h1.test.ts, to220h2.test.ts, to220h3.test.ts, and to220h4.test.ts, with each file containing only one test() call.

Spotted by Graphite (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

implement TO-220 horizontal variant

1 participant