@rulecad/pcb 0.5.5 → 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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,71 @@
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
+
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
47
+
48
+ ### Fixed
49
+
50
+ - A net or track joined to a diode's `cathode` now reaches the diode's cathode. The board engine used to name a diode's two ports by the order of its pads, the first one the anode, whatever the pads said they were. On a DO-35 diode (`do35()`) the first pad is the square cathode pad, so every net joined to `D.cathode` went to the round anode pad instead, against the band printed on the board. A pad named `cathode` or `anode` (or `K`, `A`) is now that end; a diode whose pads are only numbered has pad 1 as its cathode, as KiCad and assemblers number a diode's pads.
51
+ - A diode's cathode is now its pin 1 in every file the board makes: the KiCad board and schematic, and the placement file. The keyboard's SOD-123 diodes (`keyboard()`) are turned half round on the back so that pad 1, the cathode, is on the row's side. Their copper and the bar printed by each one do not move; the KiCad files and the placement file change (each diode is placed at 180° rather than 0°).
52
+ - A diode with other than two pads, or with both pads at the same end, is refused with a message saying how to name them.
53
+
54
+ ### Changed
55
+
56
+ - A diode's ports are `pin1` (also `cathode`, `neg`, `K`, `1`) and `pin2` (also `anode`, `pos`, `A`, `2`). The names `left` and `right`, which meant the first and second pad, are gone: use `cathode` and `anode`.
57
+
58
+ ### Boards made before this change
59
+
60
+ - **thin-picro macropads** (`examples/thin-picro`, `macropad:front` and `macropad:rear`), and any other board with `do35()` diodes: every diode was wired backwards. Fitted by the band on the board, no key reads with COL2ROW firmware. To tell: on the old board, the row's track (the one running along to the next diode in the row) goes to the round pad. A board already made works if each diode is fitted with its band at the round pad, the opposite of the band printed on the board, or with firmware set to ROW2COL.
61
+ - **Keyboards made with `keyboard()`**, hand-soldered by the printed bar: these were right, and still are. Assembled by a fab from the old placement file, or drawn from the old KiCad files, every diode may be reversed, because those files gave the anode as pad 1. To tell: in the old KiCad board, each diode's pad 1 is on its switch's net. Check an assembled board's diodes: the band (cathode) should be on the side of the row track; if it is on the switch's side, set the firmware to ROW2COL.
62
+ - Build the boards again to get new Gerbers, KiCad files and placement files. The macropads' tracks to their diodes move; no printed size moves.
63
+
64
+ ### Added
65
+
66
+ - `routeStore({ get, put })` sets where the autorouter's results are kept, in place of the `RULECAD_ROUTE_CACHE` folder: `get(key)` gives a route's JSON text or nothing, `put(key, text)` keeps one, each key the 64 hex digits of a SHA-256 of the router's input and version, as the folder's file names are. `routeStore(null)` goes back to the folder. cad uses it to run board designs in its sandbox, which can't write files: the routes found there go back to cad, which writes them.
67
+ - Upgrading: nothing to do; without a store the folder is used as before. No printed size changes.
68
+
69
+ - A note, THIRD-PARTY.md, shipped with the package and linked from a new Licence section in the README: `fixedTraces` in circuit.mjs follows `withFixedTraces` in tscircuit's core, which is under the MIT licence, and the note carries that licence's copyright notice and text, as the licence asks. It also says that `@tscircuit/copper-pour-solver`, one of pcb's dependencies, is published without a licence although its repository is MIT. The code is unchanged: no board, and no printed size, changes.
70
+
6
71
  ## 0.5.5: tracks finished for the fab, a route cache, a footprint for MX or Choc switches
7
72
 
8
73
  ### Added
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,7 +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.
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.
145
159
  - **Copper of any shape:** a pad `{ pin, smd: true, x, y, points: [[x, y], ...] }` (x, y: where tracks join it), such
146
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.
147
161
  - **Nets:** each net's pins are joined by the shortest set of links between them, at `board.track` (or the net's own
@@ -168,6 +182,8 @@ export function main(v) {
168
182
  }
169
183
  ```
170
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
+
171
187
  ```sh
172
188
  npm install @rulecad/pcb
173
189
  npx cad check macropad/board # tscircuit's checks, JLCPCB's limits, the matrix
@@ -181,8 +197,7 @@ npx cad export macropad/board # <name>-fab.zip for JLCPCB, KiCad files, the
181
197
  vias the router may make (`via_hole`, `via_pad`; the recommended ring unless it says) and what silkscreen it draws
182
198
  (`silk_line`, `silk_text`); the keyboard recipe takes them from the fab's rules.
183
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.
184
- - A Pico under the board has its connections autorouted (that needs Node 22 or newer; boards drawn wholly by rule build on
185
- 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.
186
201
  Everything else is drawn by rule.
187
202
  - The autorouter and footprint versions are pinned, so a board builds the same until rulecad moves them on; each move is
188
203
  checked against boards built before it (same tracks, same checks, same fab files). Nothing to add to your
@@ -190,3 +205,8 @@ npx cad export macropad/board # <name>-fab.zip for JLCPCB, KiCad files, the
190
205
  the newest, and since its 0.0.3032 that has pulled in an old circuit-json that the design checks can't load
191
206
  (tscircuit/circuit-json-to-gerber#200).
192
207
  - Ordering is your click: `cad export` makes the fab zip and never places an order.
208
+
209
+ ## Licence
210
+
211
+ MIT (see [LICENSE](LICENSE)). `fixedTraces` in circuit.mjs follows tscircuit's MIT-licensed `withFixedTraces`: its
212
+ copyright notice is in [THIRD-PARTY.md](THIRD-PARTY.md), which goes with any copy of the package.
package/THIRD-PARTY.md ADDED
@@ -0,0 +1,42 @@
1
+ # Code in @rulecad/pcb that follows someone else's
2
+
3
+ Most of `@rulecad/pcb` is rulecad's own work, under the MIT licence in [LICENSE](LICENSE). One part is not.
4
+
5
+ ## `fixedTraces` in circuit.mjs
6
+
7
+ `fixedTraces`, in `circuit.mjs`, turns the tracks already drawn on a board into obstacles the autorouter keeps clear
8
+ of: each piece of track a box a track wide, each via a square. It follows the function `withFixedTraces` in tscircuit's
9
+ core (https://github.com/tscircuit/core), so that a board is routed around its drawn tracks in the same way there. That
10
+ code is under the MIT licence, whose notice follows. It asks only that the notice goes with any copy.
11
+
12
+ ```
13
+ MIT License
14
+
15
+ Copyright (c) 2024 tscircuit Inc.
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ of this software and associated documentation files (the "Software"), to deal
19
+ in the Software without restriction, including without limitation the rights
20
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ copies of the Software, and to permit persons to whom the Software is
22
+ furnished to do so, subject to the following conditions:
23
+
24
+ The above copyright notice and this permission notice shall be included in all
25
+ copies or substantial portions of the Software.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ SOFTWARE.
34
+ ```
35
+
36
+ ## The packages pcb installs
37
+
38
+ pcb uses many of tscircuit's packages, installed from npm with their own licences; they are not copied into pcb. One
39
+ of them, `@tscircuit/copper-pour-solver`, is published without a licence field or file, though its repository
40
+ (https://github.com/tscircuit/copper-pour-solver) is under the MIT licence. The repository's test
41
+ `test/notices.test.mjs` lists every installed package's licence that is not one of the usual permissive ones, with the
42
+ reason it is accepted.