Skip to content

Commit

Permalink
Merge pull request #49 from anas-sarkez/main
Browse files Browse the repository at this point in the history
Implement _silkscreenpins for dip components
  • Loading branch information
AnasSarkiz authored Oct 1, 2024
2 parents 795a032 + df37a57 commit b6ccf39
Show file tree
Hide file tree
Showing 39 changed files with 272 additions and 129 deletions.
173 changes: 115 additions & 58 deletions package-lock.json

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 @@ -20,7 +20,7 @@
"@tscircuit/soup-util": "^0.0.11",
"@types/node": "^20.12.13",
"ava": "^6.1.3",
"circuit-to-svg": "^0.0.28",
"circuit-to-svg": "^0.0.38",
"esbuild": "^0.21.4",
"esbuild-register": "^3.5.0",
"tsup": "^8.0.2",
Expand Down
36 changes: 34 additions & 2 deletions src/fn/dip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { AnySoupElement, PcbSilkscreenPath } from "@tscircuit/soup"
import type {
AnySoupElement,
PcbFabricationNoteText,
PcbSilkscreenPath,
} from "@tscircuit/soup"
import { u_curve } from "../helpers/u-curve"
import { platedhole } from "../helpers/platedhole"
import { z } from "zod"
Expand Down Expand Up @@ -116,10 +120,38 @@ export const dip = (raw_params: {
{ x: -sw / 2, y: -sh / 2 },
],
type: "pcb_silkscreen_path",
stroke_width: 0.1,
}
const silkscreenPins: PcbFabricationNoteText[] = []
for (let i = 0; i < parameters.num_pins; i++) {
const isLeft = i < parameters.num_pins / 2
const pinLabelX = isLeft
? -parameters.w / 2 - parameters.p / 2 - 0.2
: parameters.p / 2 + parameters.w / 2 + 0.2
const pinLabelY = isLeft
? (-sh + 1.6) / 2 + i * parameters.p
: (-sh + 1.6) / 2 + (i - parameters.num_pins / 2) * parameters.p
const silkscreenPin = {
type: "pcb_fabrication_note_text",
layer: "top",
pcb_component_id: `pin_${i + 1}`,
pcb_silkscreen_text_id: `pin_${i + 1}`,
text: `{pin${i + 1}}`,
anchor_position: {
x: pinLabelX,
y: pinLabelY,
},
font_size: 0.3,
font_color: "red",
font: "tscircuit2024",
anchor_alignment: "top-left",
}

silkscreenPins.push(silkscreenPin)
}

return {
circuitJson: [...platedHoles, silkscreenBorder],
circuitJson: [...platedHoles, silkscreenBorder, ...silkscreenPins],
parameters,
}
}
Loading

0 comments on commit b6ccf39

Please sign in to comment.