Skip to content

feat: add led5050 and led2835 footprints#512

Open
dagangtj wants to merge 2 commits intotscircuit:mainfrom
dagangtj:feat/led5050-led2835
Open

feat: add led5050 and led2835 footprints#512
dagangtj wants to merge 2 commits intotscircuit:mainfrom
dagangtj:feat/led5050-led2835

Conversation

@dagangtj
Copy link

Adds support for common SMD LED footprints.

Changes

  • led5050: 5.0mm x 5.0mm 6-pin RGB LED package
  • led2835: 2.8mm x 3.5mm 2-pin SMD LED package

These are widely used LED packages for lighting applications.

Closes #122

- led5050: 5.0mm x 5.0mm 6-pin RGB LED
- led2835: 2.8mm x 3.5mm 2-pin SMD LED
- Common LED packages for lighting applications

Closes tscircuit#122
Comment on lines +6 to +31
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,
}
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.

As suggested by graphite-app[bot], the num_pins parameter was defined
but never validated or used in the function implementation. Since
these LED footprints have fixed pin counts (2 for 2835, 6 for 5050),
removed the misleading parameter from the schema.
@dagangtj
Copy link
Author

dagangtj commented Mar 5, 2026

@graphite-app[bot] Thanks for the review! I've removed the unused parameter from both and schemas as suggested. Since these LED footprints have fixed pin counts, the parameter was indeed misleading. Fixed in commit 54e662f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for led5050 footprint and led2835 footprint

1 participant