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
22 changes: 17 additions & 5 deletions src/fn/bga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ export const bga = (

const missing_pin_nums_set = new Set(missing_pin_nums)

let missing_pins_passed = 0
// Sort missing pin numbers so we can efficiently count how many are
// below a given pin_num. This is necessary because with non-default
// origins (bl, br, tr) the physical iteration order doesn't match
// the pin numbering order.
const sorted_missing = [...missing_pin_nums_set].sort((a, b) => a - b)

for (let y = 0; y < grid.y; y++) {
for (let x = 0; x < grid.x; x++) {
// Calculate physical pad position (always centered around origin)
Expand Down Expand Up @@ -146,15 +151,22 @@ export const bga = (
break
}

let pin_num = pin_y * grid.x + pin_x + 1
const pin_num = pin_y * grid.x + pin_x + 1
if (missing_pin_nums_set.has(pin_num)) {
missing_pins_passed++
continue
}
pin_num -= missing_pins_passed

// Count how many missing pins have a lower pin number than this one
// to compute the correct renumbered pin index.
let missing_below = 0
for (const m of sorted_missing) {
if (m < pin_num) missing_below++
else break
}
const renumbered_pin = pin_num - missing_below

// TODO handle >26 rows
const portHints = [pin_num, `${ALPHABET[pin_y]}${pin_x + 1}`]
const portHints = [renumbered_pin, `${ALPHABET[pin_y]}${pin_x + 1}`]
pads.push(
parameters.circularpads
? circlepad(portHints, {
Expand Down
9 changes: 7 additions & 2 deletions src/footprinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,17 @@ export const footprinter = (): Footprinter & {
} else {
target[prop] = true
target.fn = prop
if (prop === "res" || prop === "cap") {
if (
prop === "res" ||
prop === "cap" ||
prop === "led" ||
prop === "diode"
) {
if (v) {
if (typeof v === "string" && v.includes("_metric")) {
target.metric = v.split("_metric")[0]
} else {
target.imperial = v // e.g., res0402, cap0603 etc.
target.imperial = v // e.g., res0402, cap0603, led0805 etc.
}
}
} else {
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/bga_3x3_blorigin_missing_B2.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/__snapshots__/diode0402_string.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/__snapshots__/diode0805_string.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/__snapshots__/diode1206_string.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/__snapshots__/led0402_string.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading