@tscircuit/footprinter 0.0.152 → 0.0.154

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1058,6 +1058,7 @@ type Footprinter = {
1058
1058
  soup: () => AnySoupElement[];
1059
1059
  circuitJson: () => AnyCircuitElement[];
1060
1060
  };
1061
+ solderjumper: (num_pins?: number) => FootprinterParamsBuilder<"bridged" | "p" | "pw" | "ph">;
1061
1062
  params: () => any;
1062
1063
  /** @deprecated use circuitJson() instead */
1063
1064
  soup: () => AnySoupElement[];
package/dist/index.js CHANGED
@@ -53,6 +53,7 @@ __export(fn_exports, {
53
53
  sod882d: () => sod882d,
54
54
  sod923: () => sod923,
55
55
  soic: () => soic,
56
+ solderjumper: () => solderjumper,
56
57
  sop8: () => sop8,
57
58
  sot223: () => sot223,
58
59
  sot23: () => sot23,
@@ -213,7 +214,7 @@ var dip = (raw_params) => {
213
214
  const isLeft = i < parameters.num_pins / 2;
214
215
  const pinLabelX = isLeft ? -parameters.w / 2 - parameters.p / 2 - 0.2 : parameters.p / 2 + parameters.w / 2 + 0.2;
215
216
  const pinLabelY = isLeft ? (-sh + 1.6) / 2 + i * parameters.p : (-sh + 1.6) / 2 + (i - parameters.num_pins / 2) * parameters.p;
216
- const silkscreenPin = {
217
+ const silkscreenPin2 = {
217
218
  type: "pcb_fabrication_note_text",
218
219
  layer: "top",
219
220
  pcb_component_id: `pin_${i + 1}`,
@@ -228,7 +229,7 @@ var dip = (raw_params) => {
228
229
  font: "tscircuit2024",
229
230
  anchor_alignment: "top-left"
230
231
  };
231
- silkscreenPins.push(silkscreenPin);
232
+ silkscreenPins.push(silkscreenPin2);
232
233
  }
233
234
  const silkscreenRefText = silkscreenRef(0, sh / 2 + 0.5, 0.4);
234
235
  return {
@@ -1532,6 +1533,29 @@ var dfn = (raw_params) => {
1532
1533
  // src/fn/pinrow.ts
1533
1534
  import { z as z11 } from "zod";
1534
1535
  import { length as length5 } from "circuit-json";
1536
+
1537
+ // src/helpers/silkscreenPin.ts
1538
+ var silkscreenPin = ({
1539
+ x,
1540
+ y,
1541
+ fs,
1542
+ pn
1543
+ }) => {
1544
+ return {
1545
+ type: "pcb_silkscreen_text",
1546
+ pcb_silkscreen_text_id: "silkscreen_text_1",
1547
+ font: "tscircuit2024",
1548
+ font_size: fs,
1549
+ stroke_width: fs / 100,
1550
+ pcb_component_id: "pcb_component_1",
1551
+ text: `{PIN${pn}}`,
1552
+ layer: "top",
1553
+ anchor_position: { x, y },
1554
+ anchor_alignment: "center"
1555
+ };
1556
+ };
1557
+
1558
+ // src/fn/pinrow.ts
1535
1559
  var pinrow_def = z11.object({
1536
1560
  fn: z11.string(),
1537
1561
  num_pins: z11.number().optional().default(6),
@@ -1557,45 +1581,44 @@ var pinrow_def = z11.object({
1557
1581
  var pinrow = (raw_params) => {
1558
1582
  const parameters = pinrow_def.parse(raw_params);
1559
1583
  const { p, id, od, rows } = parameters;
1584
+ const numPins = parameters.num_pins;
1560
1585
  const holes = [];
1561
- const num_pins = parameters.num_pins;
1586
+ const addPin = (pinNumber, xoff, yoff) => {
1587
+ holes.push(platedhole(pinNumber, xoff, yoff, id, od));
1588
+ holes.push(
1589
+ silkscreenPin({ x: xoff, y: yoff + p / 2, fs: od / 5, pn: pinNumber })
1590
+ );
1591
+ };
1562
1592
  if (rows > 1) {
1563
- const num_pins_per_row = Math.ceil(num_pins / rows);
1593
+ const numPinsPerRow = Math.ceil(numPins / rows);
1564
1594
  const ySpacing = p;
1565
1595
  for (let row = 0; row < rows; row++) {
1566
1596
  const yoff = row * ySpacing;
1567
- const startPin = row * num_pins_per_row;
1568
- for (let pinIndex = 0; pinIndex < num_pins_per_row; pinIndex++) {
1569
- const pinNumber = startPin + pinIndex + 1;
1570
- if (pinNumber > num_pins)
1597
+ const startPin = row * numPinsPerRow;
1598
+ const xStart = -((numPinsPerRow - 1) / 2) * p;
1599
+ for (let i = 0; i < numPinsPerRow; i++) {
1600
+ const pinNumber = startPin + i + 1;
1601
+ if (pinNumber > numPins)
1571
1602
  break;
1572
- const xoff = pinIndex * p;
1573
- holes.push(platedhole(pinNumber, xoff, yoff, id, od));
1603
+ const xoff = xStart + i * p;
1604
+ addPin(pinNumber, xoff, yoff);
1574
1605
  }
1575
1606
  }
1576
1607
  } else {
1577
- const num_spaces = num_pins - 1;
1578
- const xoff = -(num_spaces / 2) * p;
1579
- for (let i = 0; i < num_pins; i++) {
1580
- holes.push(platedhole(i + 1, xoff + i * p, 0, id, od));
1608
+ const xStart = -((numPins - 1) / 2) * p;
1609
+ for (let i = 0; i < numPins; i++) {
1610
+ const pinNumber = i + 1;
1611
+ const xoff = xStart + i * p;
1612
+ addPin(pinNumber, xoff, 0);
1581
1613
  }
1582
1614
  }
1583
- if (rows === 1) {
1584
- const silkscreenRefText2 = silkscreenRef(0, rows * p, 0.5);
1585
- return {
1586
- circuitJson: [...holes, silkscreenRefText2],
1587
- parameters
1588
- };
1589
- }
1590
- const silkscreenRefText = silkscreenRef(
1591
- (num_pins / rows - 1) * p / 2,
1592
- // Center the silkscreen horizontally
1593
- rows * p,
1594
- // Keep it at the top vertically
1595
- 0.5
1596
- );
1615
+ const perRow = rows > 1 ? Math.ceil(numPins / rows) : numPins;
1616
+ const xStartGroup = -((perRow - 1) / 2) * p;
1617
+ const groupTextX = xStartGroup + (perRow - 1) / 2 * p;
1618
+ const groupTextY = rows * p;
1619
+ const refText = silkscreenRef(groupTextX, groupTextY, 0.5);
1597
1620
  return {
1598
- circuitJson: [...holes, silkscreenRefText],
1621
+ circuitJson: [...holes, refText],
1599
1622
  parameters
1600
1623
  };
1601
1624
  };
@@ -5619,6 +5642,59 @@ var sodWithoutParsing15 = (parameters) => {
5619
5642
  return pads;
5620
5643
  };
5621
5644
 
5645
+ // src/fn/solderjumper.ts
5646
+ var solderjumper = (params) => {
5647
+ const { num_pins, bridged, p = 2.54, pw = 1.5, ph = 1.5 } = params;
5648
+ const padSpacing = p;
5649
+ const padWidth = pw;
5650
+ const padHeight = ph;
5651
+ const pads = [];
5652
+ for (let i = 0; i < num_pins; i++) {
5653
+ pads.push(rectpad(i + 1, i * padSpacing, 0, padWidth, padHeight));
5654
+ }
5655
+ let traces = [];
5656
+ if (bridged) {
5657
+ const pins = bridged.split("").map(Number);
5658
+ if (pins.length > 1) {
5659
+ for (let i = 0; i < pins.length - 1; i++) {
5660
+ const from = pins[i];
5661
+ const to = pins[i + 1];
5662
+ if (typeof from === "number" && typeof to === "number" && !isNaN(from) && !isNaN(to)) {
5663
+ traces.push({
5664
+ type: "pcb_trace",
5665
+ pcb_trace_id: "",
5666
+ route: [
5667
+ {
5668
+ x: (from - 1) * padSpacing,
5669
+ y: 0,
5670
+ width: 0.5,
5671
+ layer: "top",
5672
+ route_type: "wire"
5673
+ },
5674
+ {
5675
+ x: (to - 1) * padSpacing,
5676
+ y: 0,
5677
+ width: 0.5,
5678
+ layer: "top",
5679
+ route_type: "wire"
5680
+ }
5681
+ ]
5682
+ });
5683
+ }
5684
+ }
5685
+ }
5686
+ }
5687
+ const silk = silkscreenRef(
5688
+ (num_pins - 1) * padSpacing / 2,
5689
+ Number(padHeight) + 0.1,
5690
+ 0.4
5691
+ );
5692
+ return {
5693
+ circuitJson: [...pads, ...traces, silk],
5694
+ parameters: params
5695
+ };
5696
+ };
5697
+
5622
5698
  // src/helpers/is-not-null.ts
5623
5699
  function isNotNull(value) {
5624
5700
  return value !== null;