Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@tscircuit/soup-util": "^0.0.41",
"@types/bun": "^1.2.2",
"@types/node": "^20.12.13",
"bun-match-svg": "^0.0.10",
"bun-match-svg": "^0.0.11",
"circuit-json": "^0.0.190",
"circuit-json-to-connectivity-map": "^0.0.18",
"circuit-to-svg": "^0.0.152",
Expand Down
1 change: 1 addition & 0 deletions src/fn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ export { sot323 } from "./sot323"
export { smtpad } from "./smtpad"
export { platedhole } from "./platedhole"
export { sot } from "./sot"
export { m2host } from "./m2host"
41 changes: 41 additions & 0 deletions src/fn/m2host.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { length, type AnySoupElement } from "circuit-json"
import { z } from "zod"
import { mm } from "@tscircuit/mm"
import { rectpad } from "../helpers/rectpad"
import { silkscreenRef } from "../helpers/silkscreenRef"

export const m2host_def = z.object({
fn: z.string(),
pad_w: length.default("0.25mm"),
pad_l: length.default("0.60mm"),
pitch: length.default("0.50mm"),
row_spacing: length.default("0.25mm"),
edge_clearance: length.default("0.30mm"),
})

export type M2HostDef = z.input<typeof m2host_def>

export const m2host = (
raw_params: M2HostDef,
): { circuitJson: AnySoupElement[]; parameters: any } => {
const p = m2host_def.parse(raw_params)
const padW = mm(p.pad_w)
const padL = mm(p.pad_l)
const pitch = mm(p.pitch)
const rowSpacing = mm(p.row_spacing)
const edge = mm(p.edge_clearance)
const pads: AnySoupElement[] = []
const total = 75
const start = -((total - 1) / 2) * pitch
for (let i = 0; i < total; i++) {
const n = i + 1
const x = start + i * pitch
const y = n % 2 === 1 ? edge : edge + rowSpacing
pads.push(rectpad(n, x, y, padL, padW))
}
const silk = silkscreenRef(0, edge + rowSpacing + 1, 0.5)
return {
circuitJson: [...pads, silk],
parameters: p,
}
}
1 change: 1 addition & 0 deletions tests/__snapshots__/m2host.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions tests/m2host.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test, expect } from "bun:test"
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
import { fp } from "../src/footprinter"

test("m2host", () => {
const circuitJson = fp.string("m2host").circuitJson()
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "m2host")
})