diff --git a/src/fn/index.ts b/src/fn/index.ts index e2e70c86..7a49d7a0 100644 --- a/src/fn/index.ts +++ b/src/fn/index.ts @@ -59,6 +59,7 @@ export { sot23w } from "./sot23w" export { to92s } from "./to92s" export { jst } from "./jst" export { sod110 } from "./sod110" +export { vson } from "./vson" export { vssop } from "./vssop" export { msop } from "./msop" export { sod323w } from "./sod323w" diff --git a/src/fn/vson.ts b/src/fn/vson.ts new file mode 100644 index 00000000..ca0529f7 --- /dev/null +++ b/src/fn/vson.ts @@ -0,0 +1,156 @@ +import type { + AnyCircuitElement, + PcbSmtPad, + PcbSilkscreenPath, +} from "circuit-json" +import { rectpad } from "../helpers/rectpad" +import { z } from "zod" +import { base_def } from "../helpers/zod/base_def" +import { length, distance } from "circuit-json" +import { dim2d } from "src/helpers/zod/dim-2d" +import { type SilkscreenRef, silkscreenRef } from "src/helpers/silkscreenRef" + +// can't use defaults because there is not a lot of common dimensions. +export const vson_def = base_def.extend({ + fn: z.string(), + num_pins: z.number().optional().default(8), + p: distance.describe("pitch (distance between center of each pin)"), + w: length.describe("width between vertical rows of pins"), + grid: dim2d.describe("width and height of the border of the footprint"), + ep: dim2d + .default("0x0mm") + .describe("width and height of the central exposed thermal pad"), + epx: length + .default("0mm") + .describe("x offset of the center of the central exposed thermal pad"), + pinw: length.describe("width of the pin pads"), + pinh: length.describe("height of the pin pads"), +}) + +export type VsonDefInput = z.input +export type VsonDef = z.infer + +export const vson = ( + raw_params: VsonDefInput, +): { circuitJson: AnyCircuitElement[]; parameters: any } => { + const parameters = vson_def.parse(raw_params) + const { num_pins, p, w, grid, ep, epx, pinw, pinh } = parameters + + if (num_pins % 2 !== 0) { + throw new Error("invalid number of pins") + } + + const pads: PcbSmtPad[] = [] + + // place the 8 or 10 outside pins + for (let i = 0; i < num_pins; i++) { + const { pinX, pinY } = getCcwVsonCoords({ + pinCount: num_pins, + pinIndex: i, + width: w, + pitch: p, + }) + pads.push(rectpad(i + 1, pinX, pinY, pinw, pinh)) + } + + // place the central exposed pad (ep) + if (ep.x > 0 && ep.y > 0) { + pads.push(rectpad(parameters.num_pins + 1, epx, 0, ep.x, ep.y)) + } + + // draw silkscreen lines around grid dimensions + const silkscreenPaths = getSilkscreenPaths(grid) + + // draw the text for the reference designator + const silkscreenRefText: SilkscreenRef = silkscreenRef( + 0, + grid.y / 2 + p, + grid.y / 6, + ) + + return { + circuitJson: [...pads, ...silkscreenPaths, silkscreenRefText], + parameters, + } +} + +const getCcwVsonCoords = (params: { + pinCount: number + pinIndex: number + width: number + pitch: number +}) => { + let pinY = 0 + let pinX = 0 + const centerY = ((params.pinCount / 2 - 1) * params.pitch) / 2 + const pinHalf = params.pinCount / 2 + if (params.pinIndex + 1 <= pinHalf) { + pinY = params.pitch * params.pinIndex - centerY + pinX = 0 - params.width / 2 + } else { + pinY = params.pitch * (params.pinCount - params.pinIndex - 1) - centerY + pinX = params.width / 2 + } + + return { pinX, pinY } +} + +const getSilkscreenPaths = (grid: { x: number; y: number }) => { + const borderMargin = 0.1 + const cornerLine = grid.y / 30 + const silkscreenPaths: PcbSilkscreenPath[] = [ + // top silkscreen path + { + layer: "top", + pcb_component_id: "", + pcb_silkscreen_path_id: "", + type: "pcb_silkscreen_path", + route: [ + { + x: -grid.x / 2 - borderMargin, + y: grid.y / 2 + borderMargin - cornerLine, + }, + { + x: -grid.x / 2 - borderMargin, + y: grid.y / 2 + borderMargin, + }, + { + x: grid.x / 2 + borderMargin, + y: grid.y / 2 + borderMargin, + }, + { + x: grid.x / 2 + borderMargin, + y: grid.y / 2 + borderMargin - cornerLine, + }, + ], + stroke_width: grid.y / 30, + }, + // bottom silkscreen path + { + layer: "top", + pcb_component_id: "", + pcb_silkscreen_path_id: "", + type: "pcb_silkscreen_path", + route: [ + { + x: -grid.x / 2 - borderMargin, + y: -grid.y / 2 - borderMargin + cornerLine, + }, + { + x: -grid.x / 2 - borderMargin, + y: -grid.y / 2 - borderMargin, + }, + { + x: grid.x / 2 + borderMargin, + y: -grid.y / 2 - borderMargin, + }, + { + x: grid.x / 2 + borderMargin, + y: -grid.y / 2 - borderMargin + cornerLine, + }, + ], + stroke_width: grid.y / 30, + }, + ] + return silkscreenPaths +} diff --git a/src/footprinter.ts b/src/footprinter.ts index 99fd0344..6c1f0ec1 100644 --- a/src/footprinter.ts +++ b/src/footprinter.ts @@ -167,6 +167,11 @@ export type Footprinter = { ) => FootprinterParamsBuilder< "w" | "h" | "p" | "pl" | "pw" | "epw" | "eph" | "ep" > + vson: ( + num_pins?: number, + ) => FootprinterParamsBuilder< + "p" | "w" | "grid" | "ep" | "epx" | "pinw" | "pinh" + > vssop: ( num_pins?: number, ) => FootprinterParamsBuilder<"w" | "h" | "p" | "pl" | "pw"> diff --git a/tests/__snapshots__/Texas_VSON-HR-8_1.5x2mm_P0.5mm.snap.svg b/tests/__snapshots__/Texas_VSON-HR-8_1.5x2mm_P0.5mm.snap.svg new file mode 100644 index 00000000..1bf6ed40 --- /dev/null +++ b/tests/__snapshots__/Texas_VSON-HR-8_1.5x2mm_P0.5mm.snap.svg @@ -0,0 +1 @@ +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm.snap.svg b/tests/__snapshots__/VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm.snap.svg new file mode 100644 index 00000000..c71a17f5 --- /dev/null +++ b/tests/__snapshots__/VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm.snap.svg @@ -0,0 +1 @@ +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm.snap.svg b/tests/__snapshots__/VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm.snap.svg new file mode 100644 index 00000000..884c22c8 --- /dev/null +++ b/tests/__snapshots__/VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm.snap.svg @@ -0,0 +1 @@ +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/VSON-8_1.5x2mm_P0.5mm.snap.svg b/tests/__snapshots__/VSON-8_1.5x2mm_P0.5mm.snap.svg new file mode 100644 index 00000000..50895921 --- /dev/null +++ b/tests/__snapshots__/VSON-8_1.5x2mm_P0.5mm.snap.svg @@ -0,0 +1 @@ +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/VSON-8_3.3x3.3mm_P0.65mm_NexFET.snap.svg b/tests/__snapshots__/VSON-8_3.3x3.3mm_P0.65mm_NexFET.snap.svg new file mode 100644 index 00000000..eae241a9 --- /dev/null +++ b/tests/__snapshots__/VSON-8_3.3x3.3mm_P0.65mm_NexFET.snap.svg @@ -0,0 +1 @@ +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/VSONP-8-1EP_5x6_P1.27mm.snap.svg b/tests/__snapshots__/VSONP-8-1EP_5x6_P1.27mm.snap.svg new file mode 100644 index 00000000..e73683e9 --- /dev/null +++ b/tests/__snapshots__/VSONP-8-1EP_5x6_P1.27mm.snap.svg @@ -0,0 +1 @@ +{REF} \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/Texas_VSON-HR-8_1.5x2mm_P0.5mm.snap.svg b/tests/kicad-parity/__snapshots__/Texas_VSON-HR-8_1.5x2mm_P0.5mm.snap.svg new file mode 100644 index 00000000..2fd653d9 --- /dev/null +++ b/tests/kicad-parity/__snapshots__/Texas_VSON-HR-8_1.5x2mm_P0.5mm.snap.svg @@ -0,0 +1 @@ +{REF}Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/Texas_VSON-HR-8_1.5x2mm_P0.5mm_boolean_difference.snap.svg b/tests/kicad-parity/__snapshots__/Texas_VSON-HR-8_1.5x2mm_P0.5mm_boolean_difference.snap.svg new file mode 100644 index 00000000..56cfe474 --- /dev/null +++ b/tests/kicad-parity/__snapshots__/Texas_VSON-HR-8_1.5x2mm_P0.5mm_boolean_difference.snap.svg @@ -0,0 +1 @@ +Texas_VSON-HR-8_1.5x2mm_P0.5mm - Alignment Analysis (Footprinter vs KiCad)VSON8_grid1.5x2mm_P0.5mm_w1.45mm_pinw0.8mm_pinh0.25mmKiCad: Texas_VSON-HR-8_1.5x2mm_P0.5mmPerfect alignment = complete overlap \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm.snap.svg b/tests/kicad-parity/__snapshots__/VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm.snap.svg new file mode 100644 index 00000000..6e117e84 --- /dev/null +++ b/tests/kicad-parity/__snapshots__/VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm.snap.svg @@ -0,0 +1 @@ +{REF}Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm_boolean_difference.snap.svg b/tests/kicad-parity/__snapshots__/VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm_boolean_difference.snap.svg new file mode 100644 index 00000000..f91c57f3 --- /dev/null +++ b/tests/kicad-parity/__snapshots__/VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm_boolean_difference.snap.svg @@ -0,0 +1 @@ +VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm - Alignment Analysis (Footprinter vs KiCad)VSON10-1EP_grid3x3mm_P0.5mm_EP1.2x2mm_w2.875mm_pinw0.875mm_pinh0.25mmKiCad: VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mmPerfect alignment = complete overlap \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm.snap.svg b/tests/kicad-parity/__snapshots__/VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm.snap.svg new file mode 100644 index 00000000..eb82fa5c --- /dev/null +++ b/tests/kicad-parity/__snapshots__/VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm.snap.svg @@ -0,0 +1 @@ +{REF}Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm_boolean_difference.snap.svg b/tests/kicad-parity/__snapshots__/VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm_boolean_difference.snap.svg new file mode 100644 index 00000000..b873927b --- /dev/null +++ b/tests/kicad-parity/__snapshots__/VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm_boolean_difference.snap.svg @@ -0,0 +1 @@ +VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm - Alignment Analysis (Footprinter vs KiCad)VSON8-1EP_grid3x3mm_P0.65mm_EP1.65x2.4mm_w2.9mm_pinw0.85mm_pinh0.35mmKiCad: VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mmPerfect alignment = complete overlap \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/VSON-8_1.5x2mm_P0.5mm.snap.svg b/tests/kicad-parity/__snapshots__/VSON-8_1.5x2mm_P0.5mm.snap.svg new file mode 100644 index 00000000..9ba88e70 --- /dev/null +++ b/tests/kicad-parity/__snapshots__/VSON-8_1.5x2mm_P0.5mm.snap.svg @@ -0,0 +1 @@ +{REF}Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/VSON-8_1.5x2mm_P0.5mm_boolean_difference.snap.svg b/tests/kicad-parity/__snapshots__/VSON-8_1.5x2mm_P0.5mm_boolean_difference.snap.svg new file mode 100644 index 00000000..0a71de6d --- /dev/null +++ b/tests/kicad-parity/__snapshots__/VSON-8_1.5x2mm_P0.5mm_boolean_difference.snap.svg @@ -0,0 +1 @@ +VSON-8_1.5x2mm_P0.5mm - Alignment Analysis (Footprinter vs KiCad)VSON8_grid1.5x2mm_P0.5mm_w1.075mm_pinw0.575mm_pinh0.35mmKiCad: VSON-8_1.5x2mm_P0.5mmPerfect alignment = complete overlap \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/VSON-8_3.3x3.3mm_P0.65mm_NexFET.snap.svg b/tests/kicad-parity/__snapshots__/VSON-8_3.3x3.3mm_P0.65mm_NexFET.snap.svg new file mode 100644 index 00000000..9e62be06 --- /dev/null +++ b/tests/kicad-parity/__snapshots__/VSON-8_3.3x3.3mm_P0.65mm_NexFET.snap.svg @@ -0,0 +1 @@ +{REF}Diff: 9.63% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/VSON-8_3.3x3.3mm_P0.65mm_NexFET_boolean_difference.snap.svg b/tests/kicad-parity/__snapshots__/VSON-8_3.3x3.3mm_P0.65mm_NexFET_boolean_difference.snap.svg new file mode 100644 index 00000000..b1686312 --- /dev/null +++ b/tests/kicad-parity/__snapshots__/VSON-8_3.3x3.3mm_P0.65mm_NexFET_boolean_difference.snap.svg @@ -0,0 +1 @@ +VSON-8_3.3x3.3mm_P0.65mm_NexFET - Alignment Analysis (Footprinter vs KiCad)VSON8_grid3.3x3.3mm_P0.65mm_ep1.9x2.45mm_epx0.385mm_w2.88mm_pinw0.63mm_pinh0.5mmKiCad: VSON-8_3.3x3.3mm_P0.65mm_NexFETPerfect alignment = complete overlap \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/VSONP-8-1EP_5x6_P1.27mm.snap.svg b/tests/kicad-parity/__snapshots__/VSONP-8-1EP_5x6_P1.27mm.snap.svg new file mode 100644 index 00000000..88008807 --- /dev/null +++ b/tests/kicad-parity/__snapshots__/VSONP-8-1EP_5x6_P1.27mm.snap.svg @@ -0,0 +1 @@ +{REF}Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/VSONP-8-1EP_5x6_P1.27mm_boolean_difference.snap.svg b/tests/kicad-parity/__snapshots__/VSONP-8-1EP_5x6_P1.27mm_boolean_difference.snap.svg new file mode 100644 index 00000000..477785d4 --- /dev/null +++ b/tests/kicad-parity/__snapshots__/VSONP-8-1EP_5x6_P1.27mm_boolean_difference.snap.svg @@ -0,0 +1 @@ +VSONP-8-1EP_5x6_P1.27mm - Alignment Analysis (Footprinter vs KiCad)VSON8-1EP_grid5x6_P1.27mm_ep4.35x4.51mm_epx0.33mm_w5.6mm_pinw0.7mm_pinh0.7mmKiCad: VSONP-8-1EP_5x6_P1.27mmPerfect alignment = complete overlap \ No newline at end of file diff --git a/tests/kicad-parity/vson1_kicad_parity.test.ts b/tests/kicad-parity/vson1_kicad_parity.test.ts new file mode 100644 index 00000000..e03527a3 --- /dev/null +++ b/tests/kicad-parity/vson1_kicad_parity.test.ts @@ -0,0 +1,21 @@ +import { expect, test } from "bun:test" +import { compareFootprinterVsKicad } from "../fixtures/compareFootprinterVsKicad" +import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" + +test("parity/VSON8-1EP_grid3x3mm_P0.65mm_EP1.65x2.4mm_w2.9mm_pinw0.85mm_pinh0.35mm", async () => { + const { avgRelDiff, combinedFootprintElements, booleanDifferenceSvg } = + await compareFootprinterVsKicad( + "VSON8-1EP_grid3x3mm_P0.65mm_EP1.65x2.4mm_w2.9mm_pinw0.85mm_pinh0.35mm", + "Package_SON.pretty/VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm.circuit.json", + ) + + const svgContent = convertCircuitJsonToPcbSvg(combinedFootprintElements) + expect(svgContent).toMatchSvgSnapshot( + import.meta.path, + "VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm", + ) + expect(booleanDifferenceSvg).toMatchSvgSnapshot( + import.meta.path, + "VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm_boolean_difference", + ) +}) diff --git a/tests/kicad-parity/vson2_kicad_parity.test.ts b/tests/kicad-parity/vson2_kicad_parity.test.ts new file mode 100644 index 00000000..57dd4325 --- /dev/null +++ b/tests/kicad-parity/vson2_kicad_parity.test.ts @@ -0,0 +1,21 @@ +import { expect, test } from "bun:test" +import { compareFootprinterVsKicad } from "../fixtures/compareFootprinterVsKicad" +import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" + +test("parity/VSON10-1EP_grid3x3mm_P0.5mm_EP1.2x2mm_w2.875mm_pinw0.875mm_pinh0.25mm", async () => { + const { avgRelDiff, combinedFootprintElements, booleanDifferenceSvg } = + await compareFootprinterVsKicad( + "VSON10-1EP_grid3x3mm_P0.5mm_EP1.2x2mm_w2.875mm_pinw0.875mm_pinh0.25mm", + "Package_SON.pretty/VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm.circuit.json", + ) + + const svgContent = convertCircuitJsonToPcbSvg(combinedFootprintElements) + expect(svgContent).toMatchSvgSnapshot( + import.meta.path, + "VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm", + ) + expect(booleanDifferenceSvg).toMatchSvgSnapshot( + import.meta.path, + "VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm_boolean_difference", + ) +}) diff --git a/tests/kicad-parity/vson3_kicad_parity.test.ts b/tests/kicad-parity/vson3_kicad_parity.test.ts new file mode 100644 index 00000000..44eeaafd --- /dev/null +++ b/tests/kicad-parity/vson3_kicad_parity.test.ts @@ -0,0 +1,21 @@ +import { expect, test } from "bun:test" +import { compareFootprinterVsKicad } from "../fixtures/compareFootprinterVsKicad" +import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" + +test("parity/VSON8_grid1.5x2mm_P0.5mm_w1.075mm_pinw0.575mm_pinh0.35mm", async () => { + const { avgRelDiff, combinedFootprintElements, booleanDifferenceSvg } = + await compareFootprinterVsKicad( + "VSON8_grid1.5x2mm_P0.5mm_w1.075mm_pinw0.575mm_pinh0.35mm", + "Package_SON.pretty/VSON-8_1.5x2mm_P0.5mm.circuit.json", + ) + + const svgContent = convertCircuitJsonToPcbSvg(combinedFootprintElements) + expect(svgContent).toMatchSvgSnapshot( + import.meta.path, + "VSON-8_1.5x2mm_P0.5mm", + ) + expect(booleanDifferenceSvg).toMatchSvgSnapshot( + import.meta.path, + "VSON-8_1.5x2mm_P0.5mm_boolean_difference", + ) +}) diff --git a/tests/kicad-parity/vson4_kicad_parity.test.ts b/tests/kicad-parity/vson4_kicad_parity.test.ts new file mode 100644 index 00000000..aa0a0382 --- /dev/null +++ b/tests/kicad-parity/vson4_kicad_parity.test.ts @@ -0,0 +1,21 @@ +import { expect, test } from "bun:test" +import { compareFootprinterVsKicad } from "../fixtures/compareFootprinterVsKicad" +import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" + +test("parity/VSON8-1EP_grid5x6_P1.27mm_ep4.35x4.51mm_epx0.33mm_w5.6mm_pinw0.7mm_pinh0.7mm", async () => { + const { avgRelDiff, combinedFootprintElements, booleanDifferenceSvg } = + await compareFootprinterVsKicad( + "VSON8-1EP_grid5x6_P1.27mm_ep4.35x4.51mm_epx0.33mm_w5.6mm_pinw0.7mm_pinh0.7mm", + "Package_SON.pretty/VSONP-8-1EP_5x6_P1.27mm.circuit.json", + ) + + const svgContent = convertCircuitJsonToPcbSvg(combinedFootprintElements) + expect(svgContent).toMatchSvgSnapshot( + import.meta.path, + "VSONP-8-1EP_5x6_P1.27mm", + ) + expect(booleanDifferenceSvg).toMatchSvgSnapshot( + import.meta.path, + "VSONP-8-1EP_5x6_P1.27mm_boolean_difference", + ) +}) diff --git a/tests/kicad-parity/vson5_kicad_parity.test.ts b/tests/kicad-parity/vson5_kicad_parity.test.ts new file mode 100644 index 00000000..3678f709 --- /dev/null +++ b/tests/kicad-parity/vson5_kicad_parity.test.ts @@ -0,0 +1,21 @@ +import { expect, test } from "bun:test" +import { compareFootprinterVsKicad } from "../fixtures/compareFootprinterVsKicad" +import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" + +test("parity/VSON8_grid3.3x3.3mm_P0.65mm_ep1.9x2.45mm_epx0.385mm_w2.88mm_pinw0.63mm_pinh0.5mm", async () => { + const { avgRelDiff, combinedFootprintElements, booleanDifferenceSvg } = + await compareFootprinterVsKicad( + "VSON8_grid3.3x3.3mm_P0.65mm_ep1.9x2.45mm_epx0.385mm_w2.88mm_pinw0.63mm_pinh0.5mm", + "Package_SON.pretty/VSON-8_3.3x3.3mm_P0.65mm_NexFET.circuit.json", + ) + + const svgContent = convertCircuitJsonToPcbSvg(combinedFootprintElements) + expect(svgContent).toMatchSvgSnapshot( + import.meta.path, + "VSON-8_3.3x3.3mm_P0.65mm_NexFET", + ) + expect(booleanDifferenceSvg).toMatchSvgSnapshot( + import.meta.path, + "VSON-8_3.3x3.3mm_P0.65mm_NexFET_boolean_difference", + ) +}) diff --git a/tests/vson1.test.ts b/tests/vson1.test.ts new file mode 100644 index 00000000..1d24e781 --- /dev/null +++ b/tests/vson1.test.ts @@ -0,0 +1,18 @@ +import { test, expect } from "bun:test" +import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" +import { fp } from "../src/footprinter" + +// can't use VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm title from kicad-viewer. +// instead have to add extra flags +test("VSON8-1EP_grid3x3mm_P0.65mm_EP1.65x2.4mm_w2.9mm_pinw0.85mm_pinh0.35mm", () => { + const circuitJson = fp + .string( + "VSON8-1EP_grid3x3mm_P0.65mm_EP1.65x2.4mm_w2.9mm_pinw0.85mm_pinh0.35mm", + ) + .circuitJson() + const svgContent = convertCircuitJsonToPcbSvg(circuitJson) + expect(svgContent).toMatchSvgSnapshot( + import.meta.path, + "VSON-8-1EP_3x3mm_P0.65mm_EP1.65x2.4mm", + ) +}) diff --git a/tests/vson2.test.ts b/tests/vson2.test.ts new file mode 100644 index 00000000..6b694edd --- /dev/null +++ b/tests/vson2.test.ts @@ -0,0 +1,18 @@ +import { test, expect } from "bun:test" +import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" +import { fp } from "../src/footprinter" + +// can't use VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm title from kicad-viewer. +// instead have to add extra flags +test("VSON10-1EP_grid3x3mm_P0.5mm_EP1.2x2mm_w2.875mm_pinw0.875mm_pinh0.25mm", () => { + const circuitJson = fp + .string( + "VSON10-1EP_grid3x3mm_P0.5mm_EP1.2x2mm_w2.875mm_pinw0.875mm_pinh0.25mm", + ) + .circuitJson() + const svgContent = convertCircuitJsonToPcbSvg(circuitJson) + expect(svgContent).toMatchSvgSnapshot( + import.meta.path, + "VSON-10-1EP_3x3mm_P0.5mm_EP1.2x2mm", + ) +}) diff --git a/tests/vson3.test.ts b/tests/vson3.test.ts new file mode 100644 index 00000000..b03840af --- /dev/null +++ b/tests/vson3.test.ts @@ -0,0 +1,16 @@ +import { test, expect } from "bun:test" +import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" +import { fp } from "../src/footprinter" + +// can't use VSON-8_1.5x2mm_P0.5mm title from kicad-viewer. +// instead have to add extra flags +test("VSON8_grid1.5x2mm_P0.5mm_w1.075mm_pinw0.575mm_pinh0.35mm", () => { + const circuitJson = fp + .string("VSON8_grid1.5x2mm_P0.5mm_w1.075mm_pinw0.575mm_pinh0.35mm") + .circuitJson() + const svgContent = convertCircuitJsonToPcbSvg(circuitJson) + expect(svgContent).toMatchSvgSnapshot( + import.meta.path, + "VSON-8_1.5x2mm_P0.5mm", + ) +}) diff --git a/tests/vson4.test.ts b/tests/vson4.test.ts new file mode 100644 index 00000000..ca3f9d2b --- /dev/null +++ b/tests/vson4.test.ts @@ -0,0 +1,18 @@ +import { test, expect } from "bun:test" +import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" +import { fp } from "../src/footprinter" + +// can't use VSONP-8-1EP_5x6_P1.27mm title from kicad-viewer. +// instead have to add extra flags +test("VSON8-1EP_grid5x6_P1.27mm_ep4.35x4.51mm_epx0.33mm_w5.6mm_pinw0.7mm_pinh0.7mm", () => { + const circuitJson = fp + .string( + "VSON8-1EP_grid5x6_P1.27mm_ep4.35x4.51mm_epx0.33mm_w5.6mm_pinw0.7mm_pinh0.7mm", + ) + .circuitJson() + const svgContent = convertCircuitJsonToPcbSvg(circuitJson) + expect(svgContent).toMatchSvgSnapshot( + import.meta.path, + "VSONP-8-1EP_5x6_P1.27mm", + ) +}) diff --git a/tests/vson5.test.ts b/tests/vson5.test.ts new file mode 100644 index 00000000..9defbf71 --- /dev/null +++ b/tests/vson5.test.ts @@ -0,0 +1,18 @@ +import { test, expect } from "bun:test" +import { convertCircuitJsonToPcbSvg } from "circuit-to-svg" +import { fp } from "../src/footprinter" + +// can't use VSON-8_3.3x3.3mm_P0.65mm_NexFET title from kicad-viewer. +// instead have to add extra flags +test("VSON8_grid3.3x3.3mm_P0.65mm_ep1.9x2.45mm_epx0.385mm_w2.88mm_pinw0.63mm_pinh0.5mm", () => { + const circuitJson = fp + .string( + "VSON8_grid3.3x3.3mm_P0.65mm_ep1.9x2.45mm_epx0.385mm_w2.88mm_pinw0.63mm_pinh0.5mm", + ) + .circuitJson() + const svgContent = convertCircuitJsonToPcbSvg(circuitJson) + expect(svgContent).toMatchSvgSnapshot( + import.meta.path, + "VSON-8_3.3x3.3mm_P0.65mm_NexFET", + ) +})