biscuitboard 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 tscircuit Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,377 @@
1
+ # biscuit-boards
2
+
3
+ Prefabricated copper-clad boards for ordinary tscircuit TSX.
4
+
5
+ ```sh
6
+ bun add biscuitboard
7
+ ```
8
+
9
+ ```tsx
10
+ import { BiscuitBoard } from "biscuitboard"
11
+
12
+ export default () => (
13
+ <BiscuitBoard>
14
+ <chip name="U1" footprint="soic8" />
15
+ {/* components and traces */}
16
+ </BiscuitBoard>
17
+ )
18
+ ```
19
+
20
+ Generate a Gerber ZIP without the front or back solder-mask layers with:
21
+
22
+ ```sh
23
+ bun run export:gerbers:no-solder-mask examples/breadboard-clad.tsx
24
+ ```
25
+
26
+ The archive defaults to `dist/gerbers/<board-name>.zip`. Pass a second argument
27
+ to choose another ZIP path.
28
+
29
+ `BiscuitBoard` owns the fixed 75 mm x 55 mm outline, mounting holes, and
30
+ assignable prefabricated vias. Copper pours are intentionally disabled. Its
31
+ `<board>` uses a local
32
+ `autorouter.algorithmFn` backed by the standalone
33
+ [`@tscircuit/biscuit-board-autorouter`](https://github.com/tscircuit/biscuit-board-autorouter)
34
+ package. Its graph generator creates cross-layer hyperedges only at
35
+ `netIsAssignable` multi-layer obstacles, and its output validator rejects any
36
+ other layer transition. Each prefabricated-via crossing stays in one
37
+ `pcb_trace.route` as a `via` point between its top and bottom wire segments;
38
+ the existing board via is claimed instead of manufacturing a duplicate. The
39
+ router uses negotiated rip-and-replace with history costs and precomputed
40
+ trace-edge conflict lists. Its routing post-processing enforces the configured
41
+ copper clearance. A mandatory pre-expansion beautification stage then
42
+ increases spacing between foreign-net traces, consolidates same-net copper,
43
+ and replaces corners with the largest clearance-safe 45° chamfers available.
44
+ A final obstacle-aware expansion stage targets 0.3 mm copper by default,
45
+ widening in place or moving traces around neighboring copper and pads where
46
+ needed. It may retain a narrower neck where the board cannot safely accommodate
47
+ 0.3 mm, and it never introduces a non-prefabricated via. Override the target
48
+ with the `nominalTraceWidth` prop; `minTraceWidth` remains the hard routing
49
+ minimum.
50
+
51
+ The complete STM32C071FBP6 + SWD + status LED circuit is in
52
+ [`examples/stm32c071.tsx`](./examples/stm32c071.tsx). Its checked-in
53
+ `tsci snapshot` artifacts cover both the routed PCB and schematic views. The
54
+ denser [`examples/rp2040.tsx`](./examples/rp2040.tsx) example uses the RP2040
55
+ module from `@tsci/seveibar.common` and is also checked in with solved PCB and
56
+ schematic snapshots.
57
+
58
+ ## 40 mm square clad
59
+
60
+ [`Clad40x40`](./lib/Clad40x40.tsx) is a two-layer 40 mm x 40 mm clad without
61
+ pin headers. It has one centered 2 mm mounting hole plus a second 2 mm mounting
62
+ hole at the top-right, inset 3 mm from both edges. Three centered concentric
63
+ square rings provide 72 assignable prefabricated vias. The vias use 0.3 mm
64
+ drills and 0.6 mm pads at 1.3 mm pitch, matching the XIAO clad's via geometry.
65
+
66
+ ```tsx
67
+ import { Clad40x40 } from "@tsci/tscircuit.biscuit-boards";
68
+
69
+ export default () => <Clad40x40 />;
70
+ ```
71
+
72
+ The preview and checked-in PCB snapshot are in
73
+ [`examples/clad-40x40.tsx`](./examples/clad-40x40.tsx).
74
+
75
+ ```sh
76
+ bun run build:clad-40x40
77
+ bun run snapshot:clad-40x40
78
+ bun test tests/clad-40x40.test.tsx
79
+ ```
80
+
81
+ ## Combined clad panel
82
+
83
+ [`CladPanel`](./lib/CladPanel.tsx) places the breadboard clad at the upper-left
84
+ and the Arduino UNO R3 shield at the upper-right. Two standard XIAO clads and
85
+ two perforated XIAO clads sit below the breadboard. A Feather clad occupies the
86
+ remaining lower-left space, replacing four XIAOs; the TI BoosterPack remains at
87
+ the lower-right. The resulting 158 mm x 118 mm fabrication panel has 2 mm
88
+ tab-routing gaps, 3 mm edge rails, and mouse bites enabled by default.
89
+
90
+ ```sh
91
+ bun run build:clad-panel
92
+ bun run snapshot:clad-panel
93
+ bun test tests/clad-panel.test.tsx
94
+ ```
95
+
96
+ The preview entry point is [`examples/clad-panel.tsx`](./examples/clad-panel.tsx).
97
+
98
+ ## Additional fabrication panels
99
+
100
+ [`FourBoardCladPanel`](./lib/four-board-clad-panel.tsx) is a 2x2 grid containing
101
+ two breadboard clads, one BoosterPack clad, and one Arduino shield clad.
102
+ [`XiaoPairCladPanel`](./lib/xiao-pair-clad-panel.tsx) places one standard XIAO
103
+ clad beside one perforated XIAO clad. Both use 2 mm routed gaps, 3 mm edge
104
+ padding, 2 mm tabs, and mouse bites by default.
105
+
106
+ ```sh
107
+ bun run build:four-board-clad-panel
108
+ bun run build:xiao-pair-clad-panel
109
+ bun run snapshot:four-board-clad-panel
110
+ bun run snapshot:xiao-pair-clad-panel
111
+ ```
112
+
113
+ Their preview entry points are
114
+ [`examples/four-board-clad-panel.tsx`](./examples/four-board-clad-panel.tsx)
115
+ and [`examples/xiao-pair-clad-panel.tsx`](./examples/xiao-pair-clad-panel.tsx).
116
+
117
+ ## TI BoosterPack clad feasibility layout
118
+
119
+ [`BoosterPackClad`](./lib/BoosterPackClad.tsx) is an initial prefabricated-via
120
+ clad with a TI 40-pin BoosterPack-compatible header pattern. It retains the
121
+ existing clad's 75 mm x 55 mm outline and the exact same five 2.2 mm mounting
122
+ holes. The board is therefore larger than the 2000 mil x 1700 mil maximum
123
+ outline in TI SLAA542, while the mating geometry remains at the specified
124
+ 2.54 mm header pitch and 1800 mil (45.72 mm) outer-column spacing. It uses two
125
+ downward-facing 2x10 male headers for the target LaunchPad mating arrangement;
126
+ TI's generic stacking recommendation normally describes downward-facing female
127
+ BoosterPack headers.
128
+
129
+ The via field uses 289 candidates at 1.3 mm pitch. Four L-shaped corner fields
130
+ have 4 mm-wide arms; their vertical arms are 14 mm long, and the upper and
131
+ lower pairs leave a symmetric 39.468 mm opening in the center. A compact 5x5
132
+ escape grid is centered at x=-12.795 mm, 2 mm left of the midpoint between
133
+ J1/J3 and the board center. Candidates within 1 mm copper-edge clearance of a
134
+ mounting hole are omitted. A standard upward-facing 1x18 pin header sits flush
135
+ with the left board edge and extends to the top and bottom mounting-hole
136
+ keepouts. Vias that would overlap its body are omitted, and all 18 breakout
137
+ pins are explicitly marked unconnected until a signal map is chosen. Each
138
+ prefabricated via uses a 0.3 mm finished hole and a 0.6 mm copper pad, leaving
139
+ 0.7 mm between neighboring pads. The central chips/sensors bay and centered
140
+ upper and lower connector openings remain free for component placement and
141
+ outside-board access.
142
+ The bare template preview is in
143
+ [`examples/boosterpack-clad.tsx`](./examples/boosterpack-clad.tsx), and the
144
+ routed example is in
145
+ [`examples/stm32c071-display-boosterpack.tsx`](./examples/stm32c071-display-boosterpack.tsx).
146
+ It places the STM32C071, display connector, both buttons, status LEDs, SWD
147
+ connector, bulk capacitor, and the two LaunchPad headers within the outline.
148
+
149
+ The complete example routes all 36 PCB traces, including all five J_SWD pads
150
+ and both bulk-capacitor pads, with no router or clearance errors. SWDIO, SWCLK,
151
+ and SWD reset use three deterministic escape traces whose channels are reserved
152
+ from the board autorouter; the other 33 traces are autorouted. The solved route
153
+ claims 19 of the 289 prefabricated vias, at these positions in millimeters:
154
+
155
+ ```text
156
+ (-31.6,-13.7) (-27.7,25.4)
157
+ (-22.5,21.5) (-22.5,22.8) (-21.2,22.8)
158
+ (-19.9,-21.5) (-19.9,21.5) (-19.9,22.8)
159
+ (-15.395,-1.3) (-15.395,0)
160
+ (-14.095,-1.3) (-14.095,0) (-14.095,1.3)
161
+ (-12.795,-2.6) (-12.795,-1.3)
162
+ (-11.495,2.6) (-10.195,1.3) (-10.195,2.6)
163
+ (19.9,21.5)
164
+ ```
165
+
166
+ Every router-generated layer change uses one of those fixed via locations; no
167
+ new manufactured vias are introduced. LaunchPad 3V3 and GND are connected to
168
+ the example circuit. The remaining LaunchPad signal pads are explicitly marked
169
+ unconnected until a signal mapping is chosen, rather than being silently left
170
+ dangling. Unused MCU GPIO/oscillator pads are likewise explicit no-connects;
171
+ the pushbuttons' duplicate terminals are declared as internally connected by
172
+ the component model. Set `ROUTE_SWD_AND_BULK=0` only to compare against the
173
+ reduced routing experiment.
174
+
175
+ ```sh
176
+ bun run build:boosterpack
177
+ bun run analyze:boosterpack
178
+ bun run snapshot:boosterpack
179
+ bun run snapshot:boosterpack-clad
180
+ ROUTE_SWD_AND_BULK=0 bun run analyze:boosterpack
181
+ bun test tests/boosterpack-clad.test.tsx
182
+ ```
183
+
184
+ ## Arduino UNO R3 shield clad
185
+
186
+ [`ArduinoShieldClad`](./lib/ArduinoShieldClad.tsx) is a 75 mm x 55 mm
187
+ prefabricated-via clad for Arduino UNO R3-compatible shields. It retains the
188
+ existing clad outline and all five original 2.2 mm mounting holes. The complete
189
+ UNO R3 mating pattern is shifted left by one 2.54 mm header pitch so the
190
+ upper-right clad hole clears the D0-D7 header. Relative placement remains
191
+ official UNO R3 geometry for the 1x8 power header, 1x6 analog header, 1x8
192
+ D0-D7 header, 1x10 R3 digital/AREF/I2C header, and 2x3 ICSP socket.
193
+
194
+ The 262 assignable fixed vias use 0.3 mm drills, 0.6 mm copper pads, and 1.3 mm
195
+ center-to-center pitch. The clustered layout has upper- and lower-left edge
196
+ fields, two inset left fields, a central routing field spanning -19 to -3 mm,
197
+ and split right-edge rails. The area immediately left of ICSP, the header rows, and
198
+ the original clad mounting holes remain open. The bare template and its
199
+ checked-in PCB snapshot are in
200
+ [`examples/arduino-shield-clad.tsx`](./examples/arduino-shield-clad.tsx).
201
+
202
+ The routed
203
+ [`examples/stm32c071-display-arduino-shield.tsx`](./examples/stm32c071-display-arduino-shield.tsx)
204
+ example adds the complete STM32C071 display/button/SWD circuit. It takes 3.3 V
205
+ and ground from the Arduino power header, while all unused Arduino and MCU pins
206
+ are explicit no-connects. The display connector is shifted clear of the central
207
+ via field, and the SWD connector sits above the lower shield-header row.
208
+
209
+ ```sh
210
+ bun run build:arduino-shield
211
+ bun run build:arduino-display
212
+ bun run snapshot:arduino-shield
213
+ bun run snapshot:arduino-display
214
+ bun test tests/arduino-shield-clad.test.tsx
215
+ bun test tests/arduino-shield-display.test.tsx
216
+ ```
217
+
218
+ ## Seeed Studio XIAO form-factor clad
219
+
220
+ [`XiaoCladWithPinHeaders`](./lib/xiao-clad.tsx) is a two-layer 17.8 mm x 21 mm
221
+ clad matching the classic Seeed Studio XIAO outline. It includes the standard
222
+ two rows of seven through-hole headers at 2.54 mm pin pitch and 15.24 mm row
223
+ spacing, and the USB end is marked `UP` on top silkscreen. Its 26 fixed
224
+ through-vias use 0.3 mm drills and 0.6 mm pads. They form two 1 x 13 columns on a
225
+ 1.3 mm pitch, leaving the central component field open while clearing the header
226
+ pads.
227
+
228
+ The populated clad preview has a checked-in PCB snapshot:
229
+
230
+ ```sh
231
+ bun run snapshot:xiao-clad-with-pin-headers
232
+ bun test tests/xiao-clad.test.tsx
233
+ ```
234
+
235
+ [`XiaoCladWithPerforatedPinHeaders`](./lib/xiao-clad-with-perforated-pin-headers.tsx)
236
+ keeps the same XIAO
237
+ outline and 2x7 header centers, but extends each pin into a 2.13 mm x 2 mm copper
238
+ pad with a 0.7 mm perforation centered on the corresponding side edge. This
239
+ creates the through-hole-plus-edge-notch geometry used by castellated XIAO
240
+ modules while retaining compatibility with ordinary 2.54 mm pin headers.
241
+ The bare preview and its checked-in PCB snapshot are in
242
+ [`examples/xiao-clad-with-perforated-pin-headers.tsx`](./examples/xiao-clad-with-perforated-pin-headers.tsx).
243
+
244
+ ```sh
245
+ bun run snapshot:xiao-clad-with-perforated-pin-headers
246
+ ```
247
+
248
+ [`examples/xiao-stm32-usb.tsx`](./examples/xiao-stm32-usb.tsx) validates the
249
+ via placement with a routed STM32C071 USB device. It includes a compact USB-C
250
+ USB2 module, two 5.1 kOhm CC pulldowns, a 3.3 V LDO, input/output capacitors,
251
+ and bottom-side MCU decoupling. All 16 PCB traces route without router or
252
+ clearance errors, and the solution claims two fixed vias at `(-5.8, 3.7)` and
253
+ `(5.8, -5.4)` mm. No manufactured vias are added.
254
+
255
+ ```sh
256
+ bun run build:xiao-stm32-usb
257
+ bun run snapshot:xiao-stm32-usb
258
+ ```
259
+
260
+ ## Adafruit Feather form-factor clad
261
+
262
+ [`FeatherCladWithPinHeaders`](./lib/feather-clad.tsx) is a two-layer 22.86 mm x
263
+ 50.8 mm clad following the
264
+ [classic Adafruit Feather specification](https://learn.adafruit.com/adafruit-feather/feather-specification).
265
+ With USB at the top, it provides the standard 16-pin left header and 12-pin
266
+ right header at 2.54 mm pin pitch and 20.32 mm row spacing, plus four 2.54 mm
267
+ mounting holes. Its 53 fixed through-vias use 0.3 mm drills and 0.6 mm pads on a
268
+ 1.3 mm pitch. The left 1 x 31 and right 1 x 22 columns leave the central
269
+ component field and the header-free upper-right region open. The USB edge is
270
+ marked `UP` on top silkscreen.
271
+
272
+ The populated clad preview has a checked-in PCB snapshot:
273
+
274
+ ```sh
275
+ bun run build:feather-clad-with-pin-headers
276
+ bun run snapshot:feather-clad-with-pin-headers
277
+ bun test tests/feather-clad.test.tsx
278
+ ```
279
+
280
+ ## Breadboard clad
281
+
282
+ [`BreadboardClad`](./lib/breadboard-clad.tsx) is a laser-routable 75 mm x
283
+ 55 mm plug-in prototyping board. It provides 210 individually routable female
284
+ header sockets labeled A1 through J21, with the standard 2.54 mm terminal pitch
285
+ and a 7.62 mm DIP channel. Four 21-pin power/header rails run along the top and
286
+ bottom. Unlike a solderless breadboard, none of these sockets are connected in
287
+ groups: the consuming tscircuit design defines every connection, allowing the
288
+ corresponding copper traces to be laser cut for a particular circuit.
289
+
290
+ The 162 assignable prefabricated vias have 0.3 mm holes and 0.6 mm pads. A
291
+ single 21-via row sits between each power-header pair and its neighboring
292
+ terminal field, while two 21-via rows run through the central DIP channel. A
293
+ single-via-wide outer field runs beyond the headers on all four sides. The
294
+ socket grids themselves remain clear.
295
+ `BreadboardTerminalHeaders` exposes terminal aliases such as `A1` and `J21`;
296
+ `BreadboardPowerHeader` exposes `COL1` through `COL21`. The bare preview is in
297
+ [`examples/breadboard-clad.tsx`](./examples/breadboard-clad.tsx).
298
+
299
+ ```sh
300
+ bun run build:breadboard-clad
301
+ bun run snapshot:breadboard-clad:update
302
+ bun test tests/breadboard-clad.test.tsx
303
+ ```
304
+
305
+ ## Stainless-steel stencil blank
306
+
307
+ [`mechanical/biscuit-board-stencil.step`](./mechanical/biscuit-board-stencil.step)
308
+ is a millimeter-scale AP214 STEP model for a 0.12 mm thick stainless-steel
309
+ stencil blank. It follows the standard 75 mm x 55 mm clad outline, including
310
+ the 2 mm corner radius and all five 2.2 mm mounting holes at the exact
311
+ `BISCUIT_BOARD_MOUNTING_HOLE_POSITIONS` coordinates.
312
+
313
+ Regenerate the checked-in model with `manifold-3d` and `manifold-to-step`:
314
+
315
+ ```sh
316
+ bun run export:stencil-step mechanical/biscuit-board-stencil.step
317
+ ```
318
+
319
+ The generator verifies the model bounds, expected solid volume, and five-hole
320
+ topology before writing the file. This model is a mechanical blank and does
321
+ not contain board-specific solder-paste apertures.
322
+
323
+ ## LightBurn export
324
+
325
+ Generate routed Circuit JSON and laser-ready files for any circuit entry file
326
+ that has a default component export:
327
+
328
+ ```sh
329
+ bun run export:lightburn examples/stm32c071-display.tsx
330
+ ```
331
+
332
+ Output is written to `dist/lightburn/<circuit-file-name>/`. For example, the
333
+ command above writes to `dist/lightburn/stm32c071-display/` and includes the
334
+ original Circuit JSON, a LightBurn-prepared Circuit JSON, a combined `.lbrn2`
335
+ project containing every populated board side, a forward-calibrated
336
+ `*-lensdistortion.lbrn2` companion, an SVG preview, a manifest, and separate
337
+ `.lbrn2` files for each operation. Bottom layers are mirrored for flipped-board
338
+ machining and omitted entirely when the circuit has no bottom-side geometry.
339
+
340
+ The lens-distortion companion converts top-left LightBurn coordinates to the
341
+ board-centered design frame, then applies a smooth Shepard-style
342
+ inverse-distance-weighted calibration. A global affine fit preserves the board
343
+ translation, rotation, and scale; measured residual corrections are blended
344
+ using inverse-square distance weights. Each measured coordinate is matched
345
+ exactly without triangle boundaries or nearest-neighbor membership changes.
346
+
347
+ The control points and affine baseline are generated from
348
+ [`lib/coordinate_map/via-coordinate-map.csv`](./lib/coordinate_map/via-coordinate-map.csv)
349
+ with `bun run generate:lens-calibration`. The current CSV fit uses all 51 points
350
+ and has effectively zero residual at those calibration coordinates. Every
351
+ control point participates in the weighted blend, so the correction remains
352
+ continuous inside and outside the measured region as more CSV rows are added.
353
+
354
+ Before applying the nonlinear transform, straight lines and Bezier curves are
355
+ flattened to line segments no longer than 0.5 mm. This ensures the calibration
356
+ is sampled along the complete path instead of transforming only its endpoints
357
+ and curve handles.
358
+
359
+ The fabrication preparation is deliberately drill-free. It removes board
360
+ holes, cutouts, unused prefabricated vias, and all through-board LightBurn
361
+ operations. A prefabricated via is included only when a routed trace uses it;
362
+ it is emitted as solid copper so the laser ablates around the via without
363
+ trying to cut its existing hole. Pads are emitted as a fill/scan operation,
364
+ and routed copper receives a 0.15 mm clipped ablation band by default. Bottom
365
+ geometry is mirrored for machining after the board is flipped.
366
+
367
+ ```sh
368
+ bun install
369
+ bun run generate:lens-calibration
370
+ bun run typecheck
371
+ bun test
372
+ bun run snapshot:stm32
373
+ bun run snapshot:rp2040
374
+ bun run build
375
+ bun run build:example
376
+ bun run export:lightburn examples/stm32c071-display.tsx
377
+ ```