Skip to content
Open
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
2 changes: 2 additions & 0 deletions src/fn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ export { sot343 } from "./sot343"
export { m2host } from "./m2host"
export { mountedpcbmodule } from "./mountedpcbmodule"
export { to92l } from "./to92l"
export { led5050 } from "./led5050"
export { led2835 } from "./led2835"
31 changes: 31 additions & 0 deletions src/fn/led2835.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { AnySoupElement } from "circuit-json"
import { z } from "zod"
import { rectpad } from "../helpers/rectpad"
import { silkscreenRef } from "../helpers/silkscreenRef"

export const led2835_def = z.object({
fn: z.string().default("led2835"),
})

/**
* LED 2835 footprint (2.8mm x 3.5mm SMD LED)
* Common 2-pin white/single color LED package
*/
export const led2835 = (
parameters: z.input<typeof led2835_def>,
): { circuitJson: AnySoupElement[]; parameters: any } => {
const pads: AnySoupElement[] = []

// 2835 LED: 2.8mm x 3.5mm body, 2 pads
const padWidth = 0.9
const padHeight = 2.8
const xOffset = 1.45

pads.push(rectpad(1, -xOffset, 0, padWidth, padHeight))
pads.push(rectpad(2, xOffset, 0, padWidth, padHeight))

return {
circuitJson: [...pads, silkscreenRef(0, 2.2, 0.5)],
parameters,
}
Comment on lines +6 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The num_pins parameter is defined in the schema (line 8) but never validated or used in the function implementation. The function always generates exactly 2 pads regardless of this parameter value. This creates a misleading API where users might expect to configure the pin count, but changes to this parameter will be silently ignored.

If num_pins should be fixed at 2, remove it from the schema:

export const led2835_def = z.object({
  fn: z.string().default("led2835"),
})

Or if it should be configurable, the schema needs to be parsed and the parameter needs to be used:

const parsed = led2835_def.parse(parameters)
const numPins = parsed.num_pins
// Then generate pads based on numPins
Suggested change
export const led2835_def = z.object({
fn: z.string().default("led2835"),
num_pins: z.number().default(2),
})
/**
* LED 2835 footprint (2.8mm x 3.5mm SMD LED)
* Common 2-pin white/single color LED package
*/
export const led2835 = (
parameters: z.input<typeof led2835_def>,
): { circuitJson: AnySoupElement[]; parameters: any } => {
const pads: AnySoupElement[] = []
// 2835 LED: 2.8mm x 3.5mm body, 2 pads
const padWidth = 0.9
const padHeight = 2.8
const xOffset = 1.45
pads.push(rectpad(1, -xOffset, 0, padWidth, padHeight))
pads.push(rectpad(2, xOffset, 0, padWidth, padHeight))
return {
circuitJson: [...pads, silkscreenRef(0, 2.2, 0.5)],
parameters,
}
export const led2835_def = z.object({
fn: z.string().default("led2835"),
})
/**
* LED 2835 footprint (2.8mm x 3.5mm SMD LED)
* Common 2-pin white/single color LED package
*/
export const led2835 = (
parameters: z.input<typeof led2835_def>,
): { circuitJson: AnySoupElement[]; parameters: any } => {
const pads: AnySoupElement[] = []
// 2835 LED: 2.8mm x 3.5mm body, 2 pads
const padWidth = 0.9
const padHeight = 2.8
const xOffset = 1.45
pads.push(rectpad(1, -xOffset, 0, padWidth, padHeight))
pads.push(rectpad(2, xOffset, 0, padWidth, padHeight))
return {
circuitJson: [...pads, silkscreenRef(0, 2.2, 0.5)],
parameters,
}

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

}
39 changes: 39 additions & 0 deletions src/fn/led5050.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { AnySoupElement } from "circuit-json"
import { z } from "zod"
import { rectpad } from "../helpers/rectpad"
import { silkscreenRef } from "../helpers/silkscreenRef"

export const led5050_def = z.object({
fn: z.string().default("led5050"),
})

/**
* LED 5050 footprint (5.0mm x 5.0mm SMD RGB LED)
* Common 6-pin RGB LED package
*/
export const led5050 = (
parameters: z.input<typeof led5050_def>,
): { circuitJson: AnySoupElement[]; parameters: any } => {
const pads: AnySoupElement[] = []

// 5050 LED: 5.0mm x 5.0mm body, 6 pads (3 each side)
const padWidth = 1.5
const padHeight = 0.9
const xOffset = 2.2
const ySpacing = 1.6

// Left side pads (1, 2, 3)
pads.push(rectpad(1, -xOffset, ySpacing, padWidth, padHeight))
pads.push(rectpad(2, -xOffset, 0, padWidth, padHeight))
pads.push(rectpad(3, -xOffset, -ySpacing, padWidth, padHeight))

// Right side pads (4, 5, 6)
pads.push(rectpad(4, xOffset, -ySpacing, padWidth, padHeight))
pads.push(rectpad(5, xOffset, 0, padWidth, padHeight))
pads.push(rectpad(6, xOffset, ySpacing, padWidth, padHeight))

return {
circuitJson: [...pads, silkscreenRef(0, 3.5, 0.5)],
parameters,
}
}
Loading