@rulecad/pcb 0.6.0 → 0.7.0

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.
Files changed (6) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +21 -8
  3. package/circuit.mjs +1956 -474
  4. package/kicad.mjs +409 -77
  5. package/package.json +5 -5
  6. package/pcb.mjs +2486 -601
package/CHANGELOG.md CHANGED
@@ -3,6 +3,46 @@
3
3
  What changed in each release, for someone upgrading a workspace. A **drilled size** here is a dimension the fab
4
4
  makes (a hole's diameter in the drill file). Each release says whether any drilled or printed size moved, and why.
5
5
 
6
+ ## 0.7.0: unused names removed and ignored failures explained; a hole that breaks through a round or rounded board's edge fails; KiCad footprints with oval, slotted or turned pads import; back text mirrored; simple mistakes refused; needs Node 24 or later, as two of the libraries it draws with do; on a shaped board, rectangular pads and slotted holes are checked against the edge by their whole shape
7
+
8
+ ### Changed
9
+
10
+ - Names the code set and never read are gone, and each place that ignores a failure (a route that is tried another
11
+ way, a cache that can't be written) says why in a comment. No printed size moves, and nothing a design or a check
12
+ does changes.
13
+
14
+ - pcb now states Node 24 or later in its `engines`. It said Node 20.6, while routing needed Node 22 and two of the
15
+ libraries it draws with, `circuit-to-svg` and `jscad-electronics`, state Node 24 only, so npm warned about them
16
+ instead of about pcb. The rest of rulecad needs Node 22.13; pcb is the one package that needs more, and the tests hold
17
+ it to that.
18
+ - Routing a board below Node 22 still stops before the router starts, and now says that pcb needs Node 24 or newer.
19
+
20
+ Upgrading: on Node 22 or 23, npm now warns at install that pcb needs Node 24; boards still build there as before, but
21
+ only Node 24 and later are supported. Install Node 24. No printed size moves.
22
+
23
+ ### Fixed
24
+
25
+ - On a board with an `outline` (`shape.circle`, `shape.rounded`, or any other shape), a hole that broke through the edge used to pass: the check asked only whether each hole's centre was inside the board, so an M3 `mount()` hole with 1.2 mm of it past the rim passed, and the fab would mill a notch where the screw goes. Every hole is now checked as a circle against the edge, on every board shape (a rectangular board's edge is its four sides): its centre inside the board and its whole circle within it. A round plated hole is checked by its copper ring, a hole in an oval pad by its drill.
26
+ - The fail names each hole and says how far it breaks out: `the board can't be made as drawn: mounting hole 1 (3.4 mm) breaks through the board's edge by 1.2 mm at (14.5, 0)` (a part's hole reads `J1's hole`, a plated one `J1.pin3's hole`). It used to say only `1 holes break through the board's edge`.
27
+ - A round surface pad on a shaped board is checked as a circle against the edge too, not by its centre alone.
28
+ - Castellated half holes, and a clone's parts that reach past the edge as its source has them, are left out of the test as before (the clone's parts on a shaped board only, as before).
29
+ - On a shaped board a hole that crosses the edge is said once, in that fail, not also as one of the `pads or holes outside the board's outline`; the outline's line then reads `its pads are inside it, but not its holes (above)` (an info) in place of the pass `all N pads and holes inside it`.
30
+
31
+ Upgrading: a shaped board with a hole that crosses its rim, which passed before, now fails `cad check` (and `checks()`) until the hole is moved in. No printed size moves.
32
+
33
+ - `fromKicad` then `footprint` (the README's "Parts from KiCad") crashed with `Cannot read properties of undefined (reading '0')` on any through-hole pad whose width and height differ, so USB-C sockets, barrel jacks and slide switches could not be used. Such a pad now renders as KiCad draws it. Its `rect` is `{ w, h, offset, slot }`: `offset` is where the hole is from the copper's centre (a KiCad drill `(offset ...)` is now read, where it used to be ignored), and `slot` is a slotted hole's size, now drilled as a slot. `footprint()` used to drop the slot silently. Footprint data kept from before (`slot` beside `rect`, no `offset`) still reads the same.
34
+ - A pad turned by anything but a quarter turn was read as if it were not turned, giving wrong copper with no warning. An SMD pad so turned now comes through turned, as its copper's outline (`points`), with rounded ends for oval and rounded pads. Such a pad gets no solder paste (as a cloned board's outline pads don't), so a board assembled by a fab needs paste added for it by hand. A through-hole pad that isn't round, turned so, is refused by name: turn it in KiCad by a quarter turn.
35
+ - A KiCad 5 footprint (`(module ...`) was refused as having "no pads". It is now named as a KiCad 5 file, with what to do: open it in KiCad 6 or later and save it.
36
+ - Text on a back layer of the KiCad board (back silkscreen, back fabrication layer) is now always mirrored, so it reads the right way round from below, and `kicadFab` refuses to plot fab files if KiCad's own check still finds back text that isn't mirrored (KiCad counts that only a warning). The back silkscreen texts written today were already mirrored; KiCad's warnings came from the diodes' `+` and `-` marks on the back fabrication layer, which is not plotted.
37
+ - Simple mistakes are refused in plain words before anything is built, where they used to crash far away: a board with no size (`render({})` said `reading 'toFixed'`), a place that isn't a number (`Illegal Parameters`; NaN and Infinity are now shown as themselves, where `mount()` said `got null`), `header()` with no pin count (it built an "undefined-pin header"), `shape.rounded` with a corner radius over half the shorter side (it drew an outline crossing itself), and a net taking in both ends of one diode (shorting it).
38
+
39
+ Upgrading: a board with no `width`/`height` (or `outline`), no `center` (without an outline), a part, pad, hole or track point that isn't a finite number, a `header()` without `pins`, a `shape.rounded` radius over half the shorter side, or a net on both ends of a diode now throws where it used to build. Data from `fromKicad` has `slot` inside `rect` now; read it there. The back fabrication layer of KiCad boards changes (mirrored text); no printed size moves, and the plotted back silkscreen (GBO) is as before.
40
+
41
+ - On a board with an `outline` (`shape.circle`, `shape.rounded`, or any other shape), a rectangular surface pad, and the copper of a plated hole in a rectangular (oval) or pill-shaped pad, was checked against the edge by its centre alone: a 4 mm square pad whose corner hung 0.5 mm past a round board's rim passed `shaped board: all N pads and holes inside it`, and the fab would cut through its copper. Each pad is now checked by its whole copper: a rectangle by its corners and sides, turned as it is, its rounded corners as rounded; a pill as a slot; a polygon by its corners and sides. One that crosses the edge fails `N pads or holes outside the board's outline`.
42
+ - A slotted hole was checked as a circle as wide as the hole's width across the board (its x size), so a slot running towards the edge could pass with its end through it (a 1 × 4 mm slot 0.3 mm past a round board's rim passed), and a slot lying along the edge could fail when it was well inside. A slot is now checked as its true shape, its two end circles and the band between them, turned as it is, on every board shape; the fail names it as a slot: `J1.1's hole (a 1 × 4 mm slot) breaks through the board's edge by 0.3 mm at (0, 13.3)`. A rectangular hole from Circuit JSON made elsewhere is checked by its corners.
43
+
44
+ Upgrading: a shaped board with a rectangular pad or a slot that crosses its rim, which passed before, now fails `cad check` (and `checks()`) until the part is moved in. A board, of any shape, with a slot lying along its edge that used to fail as a hole through the edge may now pass. No printed size moves.
45
+
6
46
  ## 0.6.0: diodes are wired the right way round, with pad 1 as the cathode; routeStore keeps the autorouter's results where its caller says; pcb ships tscircuit's notice for the code it follows
7
47
 
8
48
  ### Fixed
package/README.md CHANGED
@@ -45,9 +45,19 @@ export function main(v) {
45
45
  keyboard recipe's corner holes (`mount_holes: 1`) are `mount('M2')`. A case reads them (`board_holes`) and puts an
46
46
  insert's boss under each (`v.fixings.insertBoss('M2', ...)`); an assembly then screws the board down with `fasten`
47
47
  and `"holes": "<item>.board"` (cad's EXAMPLES, chapter 6).
48
- - **Parts from KiCad:** `fromKicad(text)` turns a KiCad footprint (`.kicad_mod`) into pad data (y up) and its
49
- courtyard. Keep the result in a rule set's `"footprints"` with its source and pin names (`labels: { pin1: 'GND' }`),
50
- then place it with `footprint(name, data, x, y, o)`: a design reads rule sets, never files or the network.
48
+ - **Parts from KiCad:** `fromKicad(text)` turns a KiCad footprint (`.kicad_mod`, KiCad 6 or later; open a KiCad 5
49
+ one in KiCad and save it first) into pad data (y up) and its courtyard. Keep the result in a rule set's
50
+ `"footprints"` with its source and pin names (`labels: { pin1: 'GND' }`), then place it with
51
+ `footprint(name, data, x, y, o)`: a design reads rule sets, never files or the network. Oval pads, slotted holes
52
+ (a USB-C socket's shell legs, a barrel jack's pins) and holes set off a pad's centre come through as KiCad draws
53
+ them, and an SMD pad turned by any angle keeps its turn. A through-hole pad that isn't round can turn only by
54
+ quarter turns: one at another angle is refused by name. A slide switch's oval pad, as `fromKicad` gives it:
55
+
56
+ ```js
57
+ // (pad "1" thru_hole oval (at 0 0) (size 1.2 2) (drill oval 0.6 1.4) (layers "*.Cu" "*.Mask"))
58
+ { pin: '1', x: 0, y: 0, hole: 0.6, outer: 2, rect: { w: 1.2, h: 2, offset: [0, 0], slot: [0.6, 1.4] } }
59
+ // placed on a board: footprint('SW1', v.parts.footprints.switch, 10, 5)
60
+ ```
51
61
  - **Whole boards from KiCad (clones):** `fromKicadPcb(text)` reads a published board (`.kicad_pcb`, KiCad 6 or later)
52
62
  as a circuit: its parts (each with its pads, value and LCSC number, where the source put it), its nets, the nets it
53
63
  fills as planes, its outline and holes. `cad clone` keeps it in a rule set's `"circuit"` with its source and licence.
@@ -141,9 +151,11 @@ export function main(v) {
141
151
  `{ rect: { w, h, offset } }` is an oval (a rounded rectangle) round its hole, which can sit off-centre.
142
152
  - **Any board shape:** give `outline: [{ x, y }, ...]` in place of a centre and size. `shape.rounded(w, h, r)`,
143
153
  `shape.bevelled(w, h, b)`, `shape.circle(d)` and `shape.rect(w, h)` make common ones. The router keeps tracks
144
- inside the outline, and a check finds any pad outside it. Every hole, on a board of any shape, is checked as a circle
145
- against the edge: one that breaks through it fails, named, with how far it breaks out (`mounting hole 2 (3.4 mm)
146
- breaks through the board's edge by 1.2 mm at (14.5, 0)`), so that the fab doesn't mill a notch where a screw goes.
154
+ inside the outline, and a check finds any pad outside it, by its whole copper: a rectangular pad by its corners, a
155
+ round one as a circle. Every hole, on a board of any shape, is checked against the edge by its whole shape (a round
156
+ hole as a circle, a slot as its two end circles and the band between them): one that breaks through it fails, named,
157
+ with how far it breaks out (`mounting hole 2 (3.4 mm) breaks through the board's edge by 1.2 mm at (14.5, 0)`, or
158
+ `J1.1's hole (a 1 × 4 mm slot) ...`), so that the fab doesn't mill a notch where a screw goes.
147
159
  - **Copper of any shape:** a pad `{ pin, smd: true, x, y, points: [[x, y], ...] }` (x, y: where tracks join it), such
148
160
  as a ring from `shape.ring(r0, r1)` (a rotary contact, a touch pad). The router sees it as strips that follow its shape.
149
161
  - **Nets:** each net's pins are joined by the shortest set of links between them, at `board.track` (or the net's own
@@ -170,6 +182,8 @@ export function main(v) {
170
182
  }
171
183
  ```
172
184
 
185
+ pcb needs Node 24 or later: two of the libraries it draws with, `circuit-to-svg` and `jscad-electronics`, ask for it.
186
+
173
187
  ```sh
174
188
  npm install @rulecad/pcb
175
189
  npx cad check macropad/board # tscircuit's checks, JLCPCB's limits, the matrix
@@ -183,8 +197,7 @@ npx cad export macropad/board # <name>-fab.zip for JLCPCB, KiCad files, the
183
197
  vias the router may make (`via_hole`, `via_pad`; the recommended ring unless it says) and what silkscreen it draws
184
198
  (`silk_line`, `silk_text`); the keyboard recipe takes them from the fab's rules.
185
199
  - The board is also a solid, so it takes part in fit checks: switches on the board, plate over it, board in the case.
186
- - A Pico under the board has its connections autorouted (that needs Node 22 or newer; boards drawn wholly by rule build on
187
- Node 20 too). That takes minutes; then the build cache keeps it.
200
+ - A Pico under the board has its connections autorouted. That takes minutes; then the build cache keeps it.
188
201
  Everything else is drawn by rule.
189
202
  - The autorouter and footprint versions are pinned, so a board builds the same until rulecad moves them on; each move is
190
203
  checked against boards built before it (same tracks, same checks, same fab files). Nothing to add to your