@rulecad/pcb 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/README.md +12 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -15,19 +15,19 @@ them, unused; rulecad's tests fail if it's ever loaded.
15
15
  nets, and let the autorouter draw the tracks:
16
16
 
17
17
  ```js
18
- // projects/node/objects/carrier.js: a radio module, two Qwiic sensor sockets, a battery socket and its diode
18
+ // projects/macropad/objects/pcb.js: four keys wired straight to a XIAO, and a Qwiic socket for a small display
19
19
  export function main(v) {
20
- const { xiao, qwiic, jstph, part } = v.pcb;
20
+ const { xiao, mx, qwiic } = v.pcb, p = v.mx.pitch;
21
+ const keys = Array.from({ length: v.keys }, (_, i) => mx(`K${i + 1}`, (i - (v.keys - 1) / 2) * p, v.key_y, v.mx));
21
22
  return {
22
- center: { x: 7.5, y: -2.2 }, width: 35.5, height: 25.4, thickness: v.thickness, track: v.track, autoroute: true,
23
+ center: { x: 0, y: 0 }, width: p * v.keys + v.margin * 2, height: v.height, thickness: v.thickness, track: v.track, autoroute: true,
23
24
  parts: [
24
- xiao('U1', 0, 0, v.xiao), // pins labelled D0..D10, 3V3, GND, 5V from the xiao rules
25
- qwiic('J1', v.qwiic_x, v.qwiic_y, v.qwiic), // plug in from the top edge
26
- qwiic('J2', v.j2_x, 0, v.qwiic, { rotation: v.j2_turn }), // turned to face the right edge
27
- jstph('J3', v.qwiic_x, v.bat_y, v.jstph, { labels: { pin1: 'BAT', pin2: 'BATGND' } }),
28
- part('D1', 'sod123', v.qwiic_x, v.diode_y, { mpn: 'B5819W' })
25
+ ...keys, // one MX switch per key, from the mx rules
26
+ xiao('U1', 0, v.mcu_y, v.xiao), // pins labelled D0..D10, 3V3, GND, 5V from the xiao rules
27
+ qwiic('J1', v.qwiic_x, v.mcu_y, v.qwiic, { rotation: v.qwiic_turn }) // turned to face the board's edge
29
28
  ],
30
- nets: { GND: ['U1.GND', 'J1.GND', 'J2.GND', 'J3.BATGND'], SDA: ['U1.D4', 'J1.SDA', 'J2.SDA'], /* ... */ },
29
+ nets: { GND: ['U1.GND', 'J1.GND', ...keys.map((k) => `${k.name}.pin2`)], SDA: ['U1.D4', 'J1.SDA'], SCL: ['U1.D5', 'J1.SCL'],
30
+ ...Object.fromEntries(keys.map((k, i) => [`KEY${i + 1}`, [`${k.name}.pin1`, `U1.D${i}`]])) },
31
31
  traces: [], silk: [], holes: []
32
32
  };
33
33
  }
@@ -43,13 +43,13 @@ export function main(v) {
43
43
  `shape.bevelled(w, h, b)`, `shape.circle(d)` and `shape.rect(w, h)` make common ones. The router keeps tracks
44
44
  inside the outline, and a check finds any pad outside it.
45
45
  - **Copper of any shape:** a pad `{ pin, smd: true, x, y, points: [[x, y], ...] }` (x, y: where tracks join it), such
46
- as a contact ring from `shape.ring(r0, r1)`. The router sees it as strips that follow its shape.
46
+ as a ring from `shape.ring(r0, r1)` (a rotary contact, a touch pad). The router sees it as strips that follow its shape.
47
47
  - **Nets:** each net's pins are joined by the shortest set of links between them, at `board.track` (or the net's own
48
48
  `{ pins, width }`); pins are named `part.pin` by label, name or number. The schematic labels them by net.
49
49
  - **What a board tells the parts around it:** `board_x`, `board_y`, `board_w`, `board_d`, its mounting holes, where
50
50
  each part is (`parts(json)`: `{ U1: { x, y, w, h, layer, rotation } }`) and a shaped board's outline, so a case can
51
- read it (`"uses": ["node/carrier"]` in @rulecad/cad: bosses under its holes, openings over its socket, light and
52
- button) and a holes fit can check the screws find their inserts.
51
+ read it (`"uses": ["macropad/pcb"]` in @rulecad/cad: bosses under its holes, openings over its USB socket and
52
+ buttons) and a holes fit can check the screws find their inserts.
53
53
  - **Routing:** connections no rule draws go to tscircuit's capacity autorouter. Its tracks come back as pieces of each
54
54
  net, named here by the pads they end on; where a piece ends on a one-sided pad from the other layer, a via is added
55
55
  clear of the pad; and the build fails if any pad is left without a track. Drawn tracks can name their `layer`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulecad/pcb",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Circuit boards from rules: parts from rule sets or any standard footprint, quarter-turn rotation, nets and autorouting; keyboards with every matrix track drawn by rule. Gerbers, KiCad files and a JLCPCB BOM. Circuit JSON written directly: no React.",
5
5
  "type": "module",
6
6
  "exports": "./pcb.mjs",