Skip to content

Commit

Permalink
Supported holes for stampreceiver and modified pad length and holes p…
Browse files Browse the repository at this point in the history
…osition of stampboard (#71)

* Supported holes for stampreceiver and modified pad length and holes position of stampboard

* formatted

* Added innerholeedgedistance parameter to stampboard and stampreceiver
  • Loading branch information
anas-sarkez authored Oct 21, 2024
1 parent b3b96d0 commit 623cb2a
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/fn/stampboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export const stampboard_def = z.object({
bottom: length.optional(),
p: length.default(length.parse("2.54mm")),
pw: length.default(length.parse("1.6mm")),
pl: length.default(length.parse("2.11mm")),
pl: length.default(length.parse("2.4mm")),
innerhole: z.boolean().default(false),
innerholeedgedistance: length.default(length.parse("1.61mm")),
})

export type Stampboard_def = z.input<typeof stampboard_def>
Expand Down Expand Up @@ -165,7 +166,7 @@ export const stampboard = (
holes.push(
platedhole(
i + 1,
params.w / 2 - params.pl + outerDiameter / 2,
params.w / 2 - params.innerholeedgedistance,
yoff + i * params.p,
innerDiameter,
outerDiameter,
Expand Down Expand Up @@ -206,7 +207,7 @@ export const stampboard = (
holes.push(
platedhole(
i + 1,
-params.w / 2 + params.pl - outerDiameter / 2,
-params.w / 2 + params.innerholeedgedistance,
yoff + i * params.p,
innerDiameter,
outerDiameter,
Expand Down Expand Up @@ -253,7 +254,7 @@ export const stampboard = (
platedhole(
i + 1,
xoff + i * params.p,
getHeight(params) / 2 - params.pl + outerDiameter / 2,
getHeight(params) / 2 - params.innerholeedgedistance,
innerDiameter,
outerDiameter,
),
Expand Down Expand Up @@ -294,7 +295,7 @@ export const stampboard = (
platedhole(
i + 1,
xoff + i * params.p,
-getHeight(params) / 2 + params.pl - outerDiameter / 2,
-getHeight(params) / 2 + params.innerholeedgedistance,
innerDiameter,
outerDiameter,
),
Expand Down
47 changes: 47 additions & 0 deletions src/fn/stampreceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { z } from "zod"
import { rectpad } from "../helpers/rectpad"
import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef"
import { platedhole } from "src/helpers/platedhole"

export const stampreceiver_def = z.object({
fn: z.string(),
Expand All @@ -18,6 +19,8 @@ export const stampreceiver_def = z.object({
p: length.default(length.parse("2.54mm")),
pw: length.default(length.parse("1.6mm")),
pl: length.default(length.parse("3.2mm")),
innerhole: z.boolean().default(false),
innerholeedgedistance: length.default(length.parse("1.61mm")),
})

export type Stampreceiver_def = z.input<typeof stampreceiver_def>
Expand Down Expand Up @@ -126,6 +129,9 @@ export const stampreceiver = (
): { circuitJson: AnyCircuitElement[]; parameters: any } => {
const params = stampreceiver_def.parse(raw_params)
const rectpads: AnyCircuitElement[] = []
const holes: PcbPlatedHole[] = []
const innerDiameter = 1
const outerDiameter = 1.2
let routes: { x: number; y: number }[] = []
if (params.right) {
const yoff = -((params.right - 1) / 2) * params.p
Expand All @@ -146,6 +152,16 @@ export const stampreceiver = (
params.pw,
),
)
params.innerhole &&
holes.push(
platedhole(
i + 1,
params.w / 2 - params.innerholeedgedistance,
yoff + i * params.p,
innerDiameter,
outerDiameter,
),
)
}
}
if (params.left) {
Expand All @@ -167,6 +183,16 @@ export const stampreceiver = (
params.pw,
),
)
params.innerhole &&
holes.push(
platedhole(
i + 1,
-params.w / 2 + params.innerholeedgedistance,
yoff + i * params.p,
innerDiameter,
outerDiameter,
),
)
}
}
if (params.top) {
Expand All @@ -193,6 +219,16 @@ export const stampreceiver = (
params.pl,
),
)
params.innerhole &&
holes.push(
platedhole(
i + 1,
xoff + i * params.p,
getHeight(params) / 2 - params.innerholeedgedistance,
innerDiameter,
outerDiameter,
),
)
}
}
if (params.bottom) {
Expand All @@ -214,6 +250,16 @@ export const stampreceiver = (
params.pl,
),
)
params.innerhole &&
holes.push(
platedhole(
i + 1,
xoff + i * params.p,
-getHeight(params) / 2 + params.innerholeedgedistance,
innerDiameter,
outerDiameter,
),
)
}
}

Expand Down Expand Up @@ -262,6 +308,7 @@ export const stampreceiver = (
)
return {
circuitJson: [
...holes,
...rectpads,
silkscreenPath,
silkscreenTriangle,
Expand Down
22 changes: 20 additions & 2 deletions src/footprinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,28 @@ export type Footprinter = {
"tllabel" | "trlabel" | "bllabel" | "brlabel"
>
stampboard: () => FootprinterParamsBuilder<
"w" | "left" | "right" | "top" | "bottom" | "p" | "pw" | "pl" | "innerhole"
| "w"
| "left"
| "right"
| "top"
| "bottom"
| "p"
| "pw"
| "pl"
| "innerhole"
| "innerholeedgedistance"
>
stampreceiver: () => FootprinterParamsBuilder<
"w" | "left" | "right" | "top" | "bottom" | "p" | "pw" | "pl"
| "w"
| "left"
| "right"
| "top"
| "bottom"
| "p"
| "pw"
| "pl"
| "innerhole"
| "innerholeedgedistance"
>
params: () => any
/** @deprecated use circuitJson() instead */
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions tests/stampreceiver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ test("stampreceiver", () => {
"stampreceiver_left20_right20_bottom3_top2_w21mm_p2.54mm",
)
})

test("stampreceiver", () => {
const soup = fp
.string("stampreceiver_left20_right20_bottom3_top2_w21mm_p2.54mm_innerhole")
.circuitJson()
const svgContent = convertCircuitJsonToPcbSvg(soup)
expect(svgContent).toMatchSvgSnapshot(
import.meta.path,
"stampreceiver_left20_right20_bottom3_top2_w21mm_p2.54mm_innerhole",
)
})

0 comments on commit 623cb2a

Please sign in to comment.