Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add square pcb plated hole #105

Merged
merged 8 commits into from
Dec 28, 2024
Merged
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
19 changes: 18 additions & 1 deletion docs/PCB_COMPONENT_OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,24 @@ export interface PcbPlatedHoleOval {
pcb_plated_hole_id: string
}

export type PcbPlatedHole = PcbPlatedHoleCircle | PcbPlatedHoleOval
export interface PcbHoleCircularWithRectPad {
type: "pcb_plated_hole"
shape: "circular_hole_with_rect_pad"
hole_shape: "circle"
pad_shape: "rect"
hole_diameter: number
rect_pad_width: number
rect_pad_height: number
x: Distance
y: Distance
layers: LayerRef[]
port_hints?: string[]
pcb_component_id?: string
pcb_port_id?: string
pcb_plated_hole_id: string
}

export type PcbPlatedHole = PcbPlatedHoleCircle | PcbPlatedHoleOval | PcbHoleCircularWithRectPad

export interface PcbFabricationNoteText {
type: "pcb_fabrication_note_text"
Expand Down
45 changes: 43 additions & 2 deletions src/pcb/pcb_plated_hole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,58 @@ export interface PcbPlatedHoleOval {
pcb_plated_hole_id: string
}

const pcb_circular_hole_with_rect_pad = z.object({
type: z.literal("pcb_plated_hole"),
shape: z.literal("circular_hole_with_rect_pad"),
hole_shape: z.literal("circle"),
pad_shape: z.literal("rect"),
hole_diameter: z.number(),
rect_pad_width: z.number(),
rect_pad_height: z.number(),
x: distance,
y: distance,
layers: z.array(layer_ref),
port_hints: z.array(z.string()).optional(),
pcb_component_id: z.string().optional(),
pcb_port_id: z.string().optional(),
pcb_plated_hole_id: getZodPrefixedIdWithDefault("pcb_plated_hole"),
})

export interface PcbHoleCircularWithRectPad {
type: "pcb_plated_hole"
shape: "circular_hole_with_rect_pad"
hole_shape: "circle"
pad_shape: "rect"
hole_diameter: number
rect_pad_width: number
rect_pad_height: number
x: Distance
y: Distance
layers: LayerRef[]
port_hints?: string[]
pcb_component_id?: string
pcb_port_id?: string
pcb_plated_hole_id: string
}

export const pcb_plated_hole = z.union([
pcb_plated_hole_circle,
pcb_plated_hole_oval,
pcb_circular_hole_with_rect_pad,
])
export type PcbPlatedHole = PcbPlatedHoleCircle | PcbPlatedHoleOval
export type PcbPlatedHole =
| PcbPlatedHoleCircle
| PcbPlatedHoleOval
| PcbHoleCircularWithRectPad

expectTypesMatch<PcbPlatedHoleCircle, z.infer<typeof pcb_plated_hole_circle>>(
true,
)
expectTypesMatch<PcbPlatedHoleOval, z.infer<typeof pcb_plated_hole_oval>>(true)

expectTypesMatch<
PcbHoleCircularWithRectPad,
z.infer<typeof pcb_circular_hole_with_rect_pad>
>(true)
/**
* @deprecated use PcbPlatedHole
*/
Expand Down
Loading