Skip to content
Open
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
183 changes: 10 additions & 173 deletions src/pcb/pcb_smtpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,178 +123,15 @@ const pcb_smtpad_polygon = z.object({
soldermask_margin: z.number().optional(),
})

export const pcb_smtpad = z
.discriminatedUnion("shape", [
pcb_smtpad_circle,
pcb_smtpad_rect,
pcb_smtpad_rotated_rect,
pcb_smtpad_rotated_pill,
pcb_smtpad_pill,
pcb_smtpad_polygon,
])
.describe("Defines an SMT pad on the PCB")
export const pcb_smtpad = z.union([
pcb_smtpad_circle,
pcb_smtpad_rect,
pcb_smtpad_rotated_rect,
pcb_smtpad_pill,
pcb_smtpad_rotated_pill,
pcb_smtpad_polygon,
])

export type PCBSMTPadInput = z.input<typeof pcb_smtpad>
type PCBSMTPadCircle = z.infer<typeof pcb_smtpad_circle>
type PCBSMTPadRect = z.infer<typeof pcb_smtpad_rect>
type PCBSMTPadRotatedRect = z.infer<typeof pcb_smtpad_rotated_rect>
type PCBSMTPadRotatedPill = z.infer<typeof pcb_smtpad_rotated_pill>
type PCBSMTPadPill = z.infer<typeof pcb_smtpad_pill>
type PCBSMTPadPolygon = z.infer<typeof pcb_smtpad_polygon>
export type PCBSMTPad = z.infer<typeof pcb_smtpad>

/**
* Defines a circular SMT pad on the PCB
*/
export interface PcbSmtPadCircle {
type: "pcb_smtpad"
shape: "circle"
pcb_smtpad_id: string
pcb_group_id?: string
subcircuit_id?: string
x: Distance
y: Distance
radius: number
layer: LayerRef
port_hints?: string[]
pcb_component_id?: string
pcb_port_id?: string
is_covered_with_solder_mask?: boolean
soldermask_margin?: number
}

/**
* Defines a rectangular SMT pad on the PCB
*/
export interface PcbSmtPadRect {
type: "pcb_smtpad"
shape: "rect"
pcb_smtpad_id: string
pcb_group_id?: string
subcircuit_id?: string
x: Distance
y: Distance
width: number
height: number
rect_border_radius?: number
corner_radius?: number
layer: LayerRef
port_hints?: string[]
pcb_component_id?: string
pcb_port_id?: string
is_covered_with_solder_mask?: boolean
soldermask_margin?: number
soldermask_margin_left?: number
soldermask_margin_top?: number
soldermask_margin_right?: number
soldermask_margin_bottom?: number
}

/**
* Defines a rotated rectangular SMT pad on the PCB
*/
export interface PcbSmtPadRotatedRect {
type: "pcb_smtpad"
shape: "rotated_rect"
pcb_smtpad_id: string
pcb_group_id?: string
subcircuit_id?: string
x: Distance
y: Distance
width: number
height: number
rect_border_radius?: number
corner_radius?: number
ccw_rotation: Rotation
layer: LayerRef
port_hints?: string[]
pcb_component_id?: string
pcb_port_id?: string
is_covered_with_solder_mask?: boolean
soldermask_margin?: number
soldermask_margin_left?: number
soldermask_margin_top?: number
soldermask_margin_right?: number
soldermask_margin_bottom?: number
}
/**
* Defines a pill-shaped SMT pad on the PCB (rounded rectangle).
*/
export interface PcbSmtPadPill {
type: "pcb_smtpad"
shape: "pill"
pcb_smtpad_id: string
pcb_group_id?: string
subcircuit_id?: string
x: Distance
y: Distance
width: number
height: number
radius: number
layer: LayerRef
port_hints?: string[]
pcb_component_id?: string
pcb_port_id?: string
is_covered_with_solder_mask?: boolean
soldermask_margin?: number
}

/**
* Defines a rotated pill-shaped SMT pad on the PCB
*/
export interface PcbSmtPadRotatedPill {
type: "pcb_smtpad"
shape: "rotated_pill"
pcb_smtpad_id: string
pcb_group_id?: string
subcircuit_id?: string
x: Distance
y: Distance
width: number
height: number
radius: number
ccw_rotation: Rotation
layer: LayerRef
port_hints?: string[]
pcb_component_id?: string
pcb_port_id?: string
is_covered_with_solder_mask?: boolean
soldermask_margin?: number
}

/**
* Defines a polygonal SMT pad on the PCB
*/
export interface PcbSmtPadPolygon {
type: "pcb_smtpad"
shape: "polygon"
pcb_smtpad_id: string
pcb_group_id?: string
subcircuit_id?: string
points: Point[]
layer: LayerRef
port_hints?: string[]
pcb_component_id?: string
pcb_port_id?: string
is_covered_with_solder_mask?: boolean
soldermask_margin?: number
}

export type PcbSmtPad =
| PcbSmtPadCircle
| PcbSmtPadRect
| PcbSmtPadRotatedRect
| PcbSmtPadRotatedPill
| PcbSmtPadPill
| PcbSmtPadPolygon

/**
* @deprecated use PcbSmtPad
*/
export type PCBSMTPad = PcbSmtPad

expectTypesMatch<PcbSmtPadCircle, PCBSMTPadCircle>(true)
expectTypesMatch<PcbSmtPadRect, PCBSMTPadRect>(true)
expectTypesMatch<PcbSmtPadRotatedRect, PCBSMTPadRotatedRect>(true)
expectTypesMatch<PcbSmtPadRotatedPill, PCBSMTPadRotatedPill>(true)
expectTypesMatch<PcbSmtPadPill, PCBSMTPadPill>(true)
expectTypesMatch<PcbSmtPadPolygon, PCBSMTPadPolygon>(true)
expectTypesMatch<PCBSMTPad, PCBSMTPad>(true)