Skip to content
Open
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
5 changes: 2 additions & 3 deletions src/fn/dfn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const dfn = (
): { circuitJson: AnyCircuitElement[]; parameters: any } => {
const parameters = dfn_def.parse(raw_params)
const pads: AnyCircuitElement[] = []
const cornerRadius = Math.min(parameters.pl, parameters.pw) / 8
for (let i = 0; i < parameters.num_pins; i++) {
const { x, y } = getCcwSoicCoords({
num_pins: parameters.num_pins,
Expand All @@ -35,9 +36,7 @@ export const dfn = (
pl: parameters.pl,
widthincludeslegs: true,
})
pads.push(
rectpad(i + 1, x, y, parameters.pl ?? "1mm", parameters.pw ?? "0.6mm"),
)
pads.push(rectpad(i + 1, x, y, parameters.pl, parameters.pw, cornerRadius))
}

// The silkscreen is 4 corners and an arrow identifier for pin1
Expand Down
3 changes: 2 additions & 1 deletion src/fn/msop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@ export const msop = (
const p = length.parse(parameters.p || defaults.p)
const pl = length.parse(parameters.pl || defaults.pl)
const pw = length.parse(parameters.pw || defaults.pw)
const cornerRadius = Math.min(pl, pw) / 8

const pads: AnyCircuitElement[] = []

for (let i = 0; i < parameters.num_pins; i++) {
const { x, y } = getMsopCoords(parameters.num_pins, i + 1, w, p, pl)
pads.push(rectpad(i + 1, x, y, pl, pw))
pads.push(rectpad(i + 1, x, y, pl, pw, cornerRadius))
}

const silkscreenBoxWidth = w
Expand Down
3 changes: 2 additions & 1 deletion src/fn/quad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,12 @@ export const quad = (
if (orientation === "vert") {
;[padWidth, padHeight] = [padHeight, padWidth]
}
const cornerRadius = Math.min(padWidth, padHeight) / 8

const pn = pin_map[i + 1]!
padOuterHalfX = Math.max(padOuterHalfX, Math.abs(x) + padWidth / 2)
padOuterHalfY = Math.max(padOuterHalfY, Math.abs(y) + padHeight / 2)
pads.push(rectpad(pn, x, y, padWidth, padHeight))
pads.push(rectpad(pn, x, y, padWidth, padHeight, cornerRadius))
}

if (parameters.thermalpad) {
Expand Down
5 changes: 4 additions & 1 deletion src/fn/soic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const soic = (raw_params: {

export const soicWithoutParsing = (parameters: z.infer<typeof soic_def>) => {
const pads: AnyCircuitElement[] = []
const cornerRadius = Math.min(parameters.pl, parameters.pw) / 8
let maxPadExtentX = 0
let maxPadExtentY = 0
for (let i = 0; i < parameters.num_pins; i++) {
Expand All @@ -132,7 +133,9 @@ export const soicWithoutParsing = (parameters: z.infer<typeof soic_def>) => {
if (parameters.pillpads) {
pads.push(pillpad(i + 1, x, y, parameters.pl, parameters.pw))
} else {
pads.push(rectpad(i + 1, x, y, parameters.pl, parameters.pw))
pads.push(
rectpad(i + 1, x, y, parameters.pl, parameters.pw, cornerRadius),
)
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/fn/son.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ export const son = (
const pw = length.parse(parameters.pw)
const epw = length.parse(parameters.epw)
const eph = length.parse(parameters.eph)
const cornerRadius = Math.min(pl, pw) / 8

const pads: AnyCircuitElement[] = []

for (let i = 0; i < parameters.num_pins; i++) {
const { x, y } = getSonPadCoord(parameters.num_pins, i + 1, w, p)
pads.push(rectpad(i + 1, x, y, pl, pw))
pads.push(rectpad(i + 1, x, y, pl, pw, cornerRadius))
}

if (parameters.ep) {
Expand Down
5 changes: 2 additions & 3 deletions src/fn/sop8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const sop8 = (
): { circuitJson: AnyCircuitElement[]; parameters: any } => {
const parameters = sop8_def.parse(raw_params)
const pads: AnyCircuitElement[] = []
const cornerRadius = Math.min(parameters.pl, parameters.pw) / 8

for (let i = 0; i < parameters.num_pins; i++) {
const { x, y } = getCcwSoicCoords({
Expand All @@ -30,9 +31,7 @@ export const sop8 = (
pl: parameters.pl,
widthincludeslegs: true,
})
pads.push(
rectpad(i + 1, x, y, parameters.pl ?? "1.5mm", parameters.pw ?? "0.6mm"),
)
pads.push(rectpad(i + 1, x, y, parameters.pl, parameters.pw, cornerRadius))
}

const sh = (parameters.num_pins / 2 - 1) * parameters.p + parameters.pw
Expand Down
48 changes: 21 additions & 27 deletions src/fn/sot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,30 @@ export const getCcwSotCoords = (parameters: {

export const sotWithoutParsing = (parameters: z.infer<typeof sot_def>) => {
const pads: AnyCircuitElement[] = []
const h = Number.parseFloat(parameters.h)
const p = Number.parseFloat(parameters.p)
const pl = Number.parseFloat(parameters.pl)
const pw = Number.parseFloat(parameters.pw)
const cornerRadius = Math.min(pl, pw) / 8

for (let i = 1; i <= parameters.num_pins; i++) {
const { x, y } = getCcwSotCoords({
h: Number.parseFloat(parameters.h),
p: Number.parseFloat(parameters.p),
h,
p,
pn: i,
})
pads.push(
rectpad(
i,
x,
y,
Number.parseFloat(parameters.pl),
Number.parseFloat(parameters.pw),
),
)
pads.push(rectpad(i, x, y, pl, pw, cornerRadius))
}

const width = (parameters.num_pins / 2) * Number.parseFloat(parameters.p)
const height = Number.parseFloat(parameters.h)
const width = (parameters.num_pins / 2) * p
const height = h
const silkscreenPath1: PcbSilkscreenPath = {
layer: "top",
pcb_component_id: "",
pcb_silkscreen_path_id: "silkscreen_path_1",
route: [
{ x: -width / 3, y: height / 2 + Number.parseFloat(parameters.p) / 1.3 },
{ x: width / 3, y: height / 2 + Number.parseFloat(parameters.p) / 1.3 },
{ x: width / 3, y: height / 2 + p / 1.3 },
],
type: "pcb_silkscreen_path",
stroke_width: 0.05,
Expand All @@ -92,19 +90,19 @@ export const sotWithoutParsing = (parameters: z.infer<typeof sot_def>) => {
pcb_component_id: "",
pcb_silkscreen_path_id: "silkscreen_path_2",
route: [
{ x: -width / 3, y: -height / 2 - Number.parseFloat(parameters.p) / 1.3 },
{ x: width / 3, y: -height / 2 - Number.parseFloat(parameters.p) / 1.3 },
{ x: -width / 3, y: -height / 2 - p / 1.3 },
{ x: width / 3, y: -height / 2 - p / 1.3 },
],
type: "pcb_silkscreen_path",
stroke_width: 0.05,
}
const silkscreenRefText: SilkscreenRef = silkscreenRef(0, height + 0.3, 0.3)
const pin1Position = getCcwSotCoords({
h: Number.parseFloat(parameters.h),
p: Number.parseFloat(parameters.p),
h,
p,
pn: 1,
})
pin1Position.x = pin1Position.x - Number.parseFloat(parameters.pw) * 1.5
pin1Position.x = pin1Position.x - pw * 1.5
const triangleHeight = 0.7
const triangleWidth = 0.3
const pin1Indicator: PcbSilkscreenPath = {
Expand Down Expand Up @@ -133,14 +131,10 @@ export const sotWithoutParsing = (parameters: z.infer<typeof sot_def>) => {
stroke_width: 0.05,
}

const h_val = Number.parseFloat(parameters.h)
const p_val = Number.parseFloat(parameters.p)
const pl_val = Number.parseFloat(parameters.pl)
const pw_val = Number.parseFloat(parameters.pw)
const pinColumnCenterX = h_val / 2 + 0.4875
const pinRowSpanY = p_val * 2 + pw_val
const pinToeHalfSpanX = pinColumnCenterX + pl_val / 2
const courtyardStepInnerHalfWidth = h_val / 2 + 0.4
const pinColumnCenterX = h / 2 + 0.4875
const pinRowSpanY = p * 2 + pw
const pinToeHalfSpanX = pinColumnCenterX + pl / 2
const courtyardStepInnerHalfWidth = h / 2 + 0.4
const courtyardStepOuterHalfWidth = pinToeHalfSpanX + 0.25
const courtyardStepInnerHalfHeight = pinRowSpanY / 2 + 0.25
const courtyardStepOuterHalfHeight = courtyardStepInnerHalfHeight + 0.2
Expand Down
58 changes: 35 additions & 23 deletions src/fn/sot223.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,32 +89,38 @@ export const sot223_4 = (parameters: z.infer<typeof sot223_def>) => {
const pads: AnyCircuitElement[] = []
let padOuterHalfWidth = 0
let padOuterHalfHeight = 0
const w = Number.parseFloat(parameters.w)
const h = Number.parseFloat(parameters.h)
const pl = Number.parseFloat(parameters.pl)
const p = Number.parseFloat(parameters.p)
const pw = Number.parseFloat(parameters.pw)

for (let i = 0; i < parameters.num_pins; i++) {
const { x, y } = get2CcwSot223Coords({
num_pins: parameters.num_pins,
pn: i + 1,
w: Number.parseFloat(parameters.w),
h: Number.parseFloat(parameters.h),
pl: Number.parseFloat(parameters.pl),
p: Number.parseFloat(parameters.p),
w,
h,
pl,
p,
})

const pinWidth = i === 3 ? 3.8 : Number.parseFloat(parameters.pw)
const pinLength = Number.parseFloat(parameters.pl)
const pinWidth = i === 3 ? 3.8 : pw
const pinLength = pl
const cornerRadius = Math.min(pinLength, pinWidth) / 8

padOuterHalfWidth = Math.max(padOuterHalfWidth, Math.abs(x) + pinLength / 2)
padOuterHalfHeight = Math.max(
padOuterHalfHeight,
Math.abs(y) + pinWidth / 2,
)
pads.push(rectpad(i + 1, x, y, pinLength, pinWidth))
pads.push(rectpad(i + 1, x, y, pinLength, pinWidth, cornerRadius))
}

const silkscreenRefText: SilkscreenRef = silkscreenRef(0, 0, 0.3)

const width = Number.parseFloat(parameters.w) / 2 - 2.4
const height = Number.parseFloat(parameters.h) / 2
const width = w / 2 - 2.4
const height = h / 2
const silkscreenPath1: PcbSilkscreenPath = {
layer: "top",
pcb_component_id: "",
Expand All @@ -140,8 +146,8 @@ export const sot223_4 = (parameters: z.infer<typeof sot223_def>) => {
stroke_width: 0.1,
}

const bodyHalfWidth = Number.parseFloat(parameters.w) / 2
const bodyHalfHeight = Number.parseFloat(parameters.h) / 2
const bodyHalfWidth = w / 2
const bodyHalfHeight = h / 2
const courtyardHalfWidth = Math.max(
padOuterHalfWidth + 0.25,
bodyHalfWidth + 0.15,
Expand Down Expand Up @@ -204,12 +210,14 @@ export const sot223_5 = (parameters: z.infer<typeof sot223_def>) => {
const pads: AnyCircuitElement[] = []
let padOuterHalfWidth = 0
let padOuterHalfHeight = 0
const w = Number.parseFloat(parameters.w)
const h = Number.parseFloat(parameters.h)
for (let i = 1; i <= parameters.num_pins; i++) {
const { x, y } = get2CcwSot2235Coords({
h: Number.parseFloat(parameters.h),
h,
p: 1.5,
pn: i,
w: Number.parseFloat(parameters.w),
w,
})

let pinWidth = Number.parseFloat(parameters.pw)
Expand All @@ -222,17 +230,18 @@ export const sot223_5 = (parameters: z.infer<typeof sot223_def>) => {
pinWidth = 1
pinLength = 2.2
}
const cornerRadius = Math.min(pinLength, pinWidth) / 8

padOuterHalfWidth = Math.max(padOuterHalfWidth, Math.abs(x) + pinLength / 2)
padOuterHalfHeight = Math.max(
padOuterHalfHeight,
Math.abs(y) + pinWidth / 2,
)
pads.push(rectpad(i, x, y, pinLength, pinWidth))
pads.push(rectpad(i, x, y, pinLength, pinWidth, cornerRadius))
}

const width = Number.parseFloat(parameters.w) / 2 - 2.4
const height = Number.parseFloat(parameters.h) / 2
const width = w / 2 - 2.4
const height = h / 2
const silkscreenPath1: PcbSilkscreenPath = {
layer: "top",
pcb_component_id: "",
Expand Down Expand Up @@ -260,8 +269,8 @@ export const sot223_5 = (parameters: z.infer<typeof sot223_def>) => {

const silkscreenRefText: SilkscreenRef = silkscreenRef(0, 0, 0.3)

const bodyHalfWidth = Number.parseFloat(parameters.w) / 2
const bodyHalfHeight = Number.parseFloat(parameters.h) / 2
const bodyHalfWidth = w / 2
const bodyHalfHeight = h / 2
const courtyardHalfWidth = Math.max(
padOuterHalfWidth + 0.25,
bodyHalfWidth + 0.15,
Expand Down Expand Up @@ -321,12 +330,14 @@ export const sot223_6 = (parameters: z.infer<typeof sot223_def>) => {
const pads: AnyCircuitElement[] = []
let padOuterHalfWidth = 0
let padOuterHalfHeight = 0
const h = Number.parseFloat(parameters.h)
const w = 8.7
for (let i = 1; i <= parameters.num_pins; i++) {
const { x, y } = get2CcwSot2236Coords({
h: Number.parseFloat(parameters.h),
h,
p: 1.3,
pn: i,
w: 8.7,
w,
})

let pinWidth = Number.parseFloat(parameters.pw)
Expand All @@ -339,17 +350,18 @@ export const sot223_6 = (parameters: z.infer<typeof sot223_def>) => {
pinWidth = 0.6
pinLength = 2.2
}
const cornerRadius = Math.min(pinLength, pinWidth) / 8

padOuterHalfWidth = Math.max(padOuterHalfWidth, Math.abs(x) + pinLength / 2)
padOuterHalfHeight = Math.max(
padOuterHalfHeight,
Math.abs(y) + pinWidth / 2,
)
pads.push(rectpad(i, x, y, pinLength, pinWidth))
pads.push(rectpad(i, x, y, pinLength, pinWidth, cornerRadius))
}

const width = Number.parseFloat(parameters.w) / 2 - 2.4
const height = Number.parseFloat(parameters.h) / 2
const height = h / 2
const silkscreenPath1: PcbSilkscreenPath = {
layer: "top",
pcb_component_id: "",
Expand Down Expand Up @@ -378,7 +390,7 @@ export const sot223_6 = (parameters: z.infer<typeof sot223_def>) => {
const silkscreenRefText: SilkscreenRef = silkscreenRef(0, 0, 0.3)

const bodyHalfWidth = Number.parseFloat(parameters.w) / 2
const bodyHalfHeight = Number.parseFloat(parameters.h) / 2
const bodyHalfHeight = h / 2
const courtyardHalfWidth = Math.max(
padOuterHalfWidth + 0.25,
bodyHalfWidth + 0.15,
Expand Down
Loading
Loading