Skip to content
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
15 changes: 8 additions & 7 deletions lib/components/primitive-components/SmtPad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
const { _parsedProps: props } = this
const isCoveredWithSolderMask = props.coveredWithSolderMask ?? false
const shouldCreateSolderPaste = !isCoveredWithSolderMask
if (!props.portHints) return

const subcircuit = this.getSubcircuit()

Expand Down Expand Up @@ -117,6 +116,8 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
finalRotationDegrees = (360 - finalRotationDegrees + 360) % 360
}

const portHints = props.portHints?.map((ph) => ph.toString()) ?? []

let pcb_smtpad: PcbSmtPad | null = null
const pcb_component_id =
this.parent?.pcb_component_id ??
Expand All @@ -128,7 +129,7 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
layer: maybeFlipLayer(props.layer ?? "top"),
shape: "circle",
radius: props.radius!,
port_hints: props.portHints.map((ph) => ph.toString()),
port_hints: portHints,
is_covered_with_solder_mask: isCoveredWithSolderMask,
x: position.x,
y: position.y,
Expand Down Expand Up @@ -160,7 +161,7 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
x: position.x,
y: position.y,
ccw_rotation: finalRotationDegrees,
port_hints: props.portHints.map((ph) => ph.toString()),
port_hints: portHints,
is_covered_with_solder_mask: isCoveredWithSolderMask,
subcircuit_id: subcircuit?.subcircuit_id ?? undefined,
pcb_group_id: this.getGroup()?.pcb_group_id ?? undefined,
Expand All @@ -174,7 +175,7 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
width: isRotated90Degrees ? props.height! : props.width!,
height: isRotated90Degrees ? props.width! : props.height!,
corner_radius: props.cornerRadius ?? undefined,
port_hints: props.portHints.map((ph) => ph.toString()),
port_hints: portHints,
is_covered_with_solder_mask: isCoveredWithSolderMask,
x: position.x,
y: position.y,
Expand Down Expand Up @@ -231,7 +232,7 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
x: position.x,
y: position.y,
ccw_rotation: padRotation,
port_hints: props.portHints.map((ph) => ph.toString()),
port_hints: portHints,
is_covered_with_solder_mask: isCoveredWithSolderMask,
subcircuit_id: subcircuit?.subcircuit_id ?? undefined,
pcb_group_id: this.getGroup()?.pcb_group_id ?? undefined,
Expand Down Expand Up @@ -269,7 +270,7 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
layer: maybeFlipLayer(props.layer ?? "top"),
shape: "polygon",
points: transformedPoints,
port_hints: props.portHints.map((ph) => ph.toString()),
port_hints: portHints,
is_covered_with_solder_mask: isCoveredWithSolderMask,
subcircuit_id: subcircuit?.subcircuit_id ?? undefined,
pcb_group_id: this.getGroup()?.pcb_group_id ?? undefined,
Expand All @@ -285,7 +286,7 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
radius: props.radius!,
height: props.height!,
width: props.width!,
port_hints: props.portHints.map((ph) => ph.toString()),
port_hints: portHints,
is_covered_with_solder_mask: isCoveredWithSolderMask,
subcircuit_id: subcircuit?.subcircuit_id ?? undefined,
pcb_group_id: this.getGroup()?.pcb_group_id ?? undefined,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { expect, test } from "bun:test"
import { getTestFixture } from "tests/fixtures/get-test-fixture"

/**
* Regression test ensuring smtpads render even when no port hints are provided.
*/
test("smtpad within footprint renders without port hints", () => {
const { circuit } = getTestFixture()

circuit.add(
<board width="10mm" height="10mm">
<chip
name="U1"
layer="top"
footprint={
<footprint>
<smtpad shape="rect" width="1mm" height="1mm" pcbX={-1} pcbY={0} />
<smtpad shape="rect" width="1mm" height="1mm" pcbX={1} pcbY={0} />
</footprint>
}
/>
</board>,
)

circuit.render()

const smtpads = circuit.db.pcb_smtpad.list()

expect(smtpads.length).toBe(2)
for (const smtpad of smtpads) {
expect(smtpad.port_hints).toEqual([])
}
})